Track whether requestAnimationCallback has been called when SetAnimating
changes the animated state of the window. Multiple callbacks result in wasteful
redraws.
Without this change, my browser becomes unresponsive when Window.Invalidate
is called every frame. Calling Invalidate every frame is a misuse (InvalidateOp
should be used for animation), but it's nice to have reasonable behaviour.
This change might also fix the issues described in
https://github.com/gioui/gio/pull/7.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Now, it's possible to compile to Windows (`-target windows`) without
having `windres`. The PNG icon, manifest and version info will be
generated and include using `gogio`.
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
This CL handles rounding errors arising when splitting quads into linear
segments.
Rounding errors would lead to a pair of quad triplets (from,ctl,to) not
exactly matching.
ie: to(n-1) wouldn't exactly match from(n).
Signed-off-by: Sebastien Binet <s@sbinet.org>
This PR implements an image comparison algorithm in the NTSC YIQ color
space, as described in:
Measuring perceived color difference using YIQ NTSC
transmission color space in mobile applications.
Yuriy Kotsarenko, Fernando Ramos.
An electronic version is available at:
- http://www.progmat.uaem.mx:8080/artVol2Num2/Articulo3Vol2Num2.pdf
This should allow the image comparison to be a tad more robust than
comparing plain uint8 pixel values.
Signed-off-by: Sebastien Binet <s@sbinet.org>
The new compute renderer is much less tolerant of discontinuous paths.
In particular, it requires that clip outlines form a closed loop.
Fixes TestPaintArc when GIORENDERER=forcecompute.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The old renderer is still the default, so the new compute renderer will only be
used in the rare case the old renderer is not supported but the new is. That
happens on the Samsung J2 Prime and Moto C Android phones. Or set the
GIORENDERER environment variable to "forcecompute" to disable the old renderer:
$ GIORENDERER=forcecompute go run ...
Missing features:
- Gradients are not supported yet, and render as a solid color.
- Draw timers are not added, and profile.Events are not emitted.
- Stroked paths may in some cases appear corrupted because their clip
outlines are not continuous when generated by Gio. Sebastien is
working on a fix.
- The new renderer shares most CPU-side logic with the old renderer,
resulting in several inefficient conversion steps between the old
operations representation and the new. This is slower, but minimizes
divergence in features and bugs between the two renderers.
Roadmap:
- The compute renderer supports features that Gio does not yet
exploit: stroked paths with round caps, transformations, lines,
cubic beziér curves.
- More stroke styles and maybe dashed strokes natively in shaders.
- Metal and Direct3D ports.
The most important feature is porting the renderer to run on the CPU. A
CPU renderer will both support Gio on devices with insufficient GPU
support, and allow us to remove the old renderer. Two renderers is twice
the maintenance but the feature set of the weakest implementation.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The piet-gpu project is dual licensed under the Apache 2.0 and MIT, and the
shaders themselves are also offered under the UNLICENSE terms. See
https://github.com/linebender/piet-gpu#license-and-contributions, as of commit
72e2dfab3da8ae1adf7a0fb056b71ccbc4cfa29a:
"The piet-gpu project is dual-licensed under both Apache 2.0 and MIT licenses.
In addition, the shaders are provided under the terms of the Unlicense. The
intent is for this research to be used in as broad a context as possible."
Signed-off-by: Elias Naur <mail@eliasnaur.com>
While here, merge BeginFrame and EndFrame; the split was done for
performance reasons, yet never measured.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Modern graphics APIs have immutable objects, with mutable data. For example,
a texture's dimensions are immutable, while the texture contents is not.
Change the GPU API abstraction to match.
Clearing a Texture is convenient to do with a plain []byte. Generalize
Texture.Upload to take a plain byte slice and introduce a helper function for
uploading *image.RGBA data.
Add TextureFormatRGBA8, a format for the linear RGB colorspace.
Add OpenGL ES 3.1 functions for compute programs.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Modern graphics APIs have immutable objects, with mutable data. For example,
a texture's dimensions are immutable, while the texture contents is not.
Change the GPU API abstraction to match.
Clearing a Texture is convenient to do with a plain []byte. Generalize
Texture.Upload to take a plain byte slice and introduce a helper function for
uploading *image.RGBA data.
Add TextureFormatRGBA8 a format for the linear RGB colorspace.
Add OpenGL ES 3.1 functions for compute programs.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The size is unchanged, but a corner is no longer encoded as two
16-bit ints (2*2 bytes); it is encoded as a float32 (1*4 bytes).
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Before this change, the entire byte buffer would be passed to WebGL, even
though its size may be (much) larger than the source data.
Remakably, this hasn't resulted in any problems until the use of
glBufferSubData, which require the passed data fits the buffer size.
As a bonus, this fix should speed up the wasm port by virtue of passing
much less data across the wasm<->js barrier.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
NewBackend was recently changed to take a context, which must only
be specified on GOOS=js.
Fixes gio#189
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The new compute backend shares drawOps but not GPU.Collect. This
change moves the common path cache code to drawOps.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Currently, on iOS, the keyboard can block the content since it doesn't
trigger the "resize". Now, the `insets` will provide the size of the
keyboard (on iOS) and scrollbars. It's compatible with the Android (and
desktop), but Chrome automatic resizes the windows, so the `Inset` will
be 0.
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
The Mesa software OpenGL implementation strays enough from the
reference values that tests fail. Relax the tests to make them
pass again.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The mesa surfaceless renderer doesn't support configs, but does
support EGL_KHR_no_config_context so no config is required. Don't
fail context creation in this setup.
With this change, the headless tests work on a headless linux with the
EGL_PLATFORM environment variable set to "surfaceless".
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Apparently, darwin/arm64 cgo doesn't match the types of YES and BOOL:
os_macos.go:235:40: cannot use _Ciconst_YES (type untyped int) as type _Ctype__Bool
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Remove padding from the sides of the Slider to align them with
other components.
However, since sliders still need to be used with fingers try to
enforce a minimum finger height, if there is sufficient room.
The sides don't need similar treatment since after grabbing it's
possible to move the finger beyond the touch area, without losing
interaction.
To not enforce finger size, the theme can be adjusted:
theme.FingerSize = unit.Px(0)
Signed-off-by: Egon Elbre <egonelbre@gmail.com>