Commit Graph

1623 Commits

Author SHA1 Message Date
Egon Elbre 21ef492cc9 all: use color.NRGBA in public API
color.RGBA has two problems with regards to using it.

First the color values need to be premultiplied, whereas most APIs
have non-premultiplied values. This is mainly to preserve color components
with low alpha values.

Second there are two ways to premultiply with sRGB. One is to premultiply
after sRGB conversion, the other is before. This makes using the API more
confusing.

Using color.NRGBA in sRGB makes it align with CSS.e

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-19 11:30:11 +01:00
Inkeliz 9469d18907 widget/material: fix hint when Editor is single-line
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-11-18 11:42:41 +01:00
Elias Naur 01e8308a83 app/internal/window: add missing period after sentence
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-16 16:51:12 +01:00
Elias Naur aee87baefe text: represent laid out text as strings to facilitate caching of layouts
Commit https://gioui.org/commit/b331407e81456 added text layout and shaping
based on io.Reader and changed Editor to use it. Unfortunately, as ~inkeliz
discovered, caching of shapes were also lost.

~inkeliz suggested fix,

https://lists.sr.ht/~eliasnaur/gio-patches/patches/15059

adds caching of shapes to Editor to regain lost performance.

This change repairs the cache to work on io.Reader API, in hope that the
already complicated Editor won't need additional caching.

Before this change, text layouts were represented as a slice of (rune, advance)
pairs. Unfortunately, this representation doesn't lend itself to caching of
shaping results, so change the representation of a line of text to be a pair
of text and advances:

	package text

	type Layout {
		Text string
		Advances []fixed.Int26_6
	}

The Text field can then be used in a cache key, assuming Advances is
consistent with it.

The end result is that the two shaper variants of text.Shaper is reduced to
just one, and the Len field field of text.Line is no longer needed.

The changed representation adds a bit of extra work to package opentype.
Cleaning that up is left as a future TODO.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-16 16:02:30 +01:00
Elias Naur 67594636e7 text: offset Weight constants so the zero value is normal text weight
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-16 14:54:44 +01:00
Elias Naur 23fa3480c6 op/paint: update documentation to match the removal of PaintOp.Rect
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-16 12:54:58 +01:00
Sebastien Binet c15415b0d9 app/permission/camera: fix documentation typo
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-11-13 15:06:51 +01:00
Walter Werner SCHNEIDER 3c739323cb cmd/gogio: group buildInfo related code
Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
2020-11-12 15:52:35 +01:00
Sebastien Binet 7eb32360e5 gpu,op/clip: implement stroked paths with miter joins
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-11-11 16:14:49 +01:00
Elias Naur 7de8ce51a5 gpu: fix off-by-a-half clipping
I don't know why the 1/2 factor is there, but it leads to images being
rendered with a 0.5 pixel offset.

Remove the other useless checks while here: clipping 1px images shouldn't
be a problem and the destination rectangle is always non-zero (otherwise
it wouldn't be rendered).

Update the reference images that are subtly changed because of this fix.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-11 15:14:39 +01:00
Sebastien Binet 700cec440e gpu,op/clip: implement stroked paths with round joins
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-11-11 14:03:30 +01:00
Elias Naur f3f32ed7aa .builds: avoid the private applesdk repository
Should fix the automatic builds for patches sent to the mailing list.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-11 12:57:48 +01:00
Sebastien Binet 1106d90f11 gpu,op/clip: implement stroked paths with round caps
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-11-11 12:25:24 +01:00
Sebastien Binet ae256b5be8 op/clip: use stroked path to draw Border
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-11-10 16:41:14 +01:00
Sebastien Binet 8e4940e6a8 widget/material: use stroked path to draw loader widget
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-11-10 15:58:14 +01:00
Sebastien Binet 33c5fb63db gpu,op/clip: implement stroked paths
Flat and Square caps are implemented.
Bevel joins are implemented.

Round caps, Round joins and Miter joins are left for another PR.

Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-11-10 15:58:10 +01:00
Sebastien Binet 936eb52b7e all: rename clip.Path.End into clip.Path.Outline
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-11-10 15:58:07 +01:00
Elias Naur ade248311c example/go.*: update Gio version
Updates gio#171

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-10 15:28:36 +01:00
Elias Naur 9843176adb widget: don't process key releases as presses in Editor
Fixes gio#171

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-10 15:27:22 +01:00
Elias Naur 002a66f3f3 Revert "app/internal/xkb: fix duplicate edit events for special keys"
This reverts commit e84a2344cf.

The fix is wrong: it's supressing the release key.Event, not key.EditEvents.
The culprit is that Editor fails to ignore release events.

Updates gio#171
2020-11-10 15:27:17 +01:00
Elias Naur fb70fb1c95 example/go.*: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-09 11:01:45 +01:00
Rajiv Kanchan e84a2344cf app/internal/xkb: fix duplicate edit events for special keys
Edit events were being sent twice, once upon key press and again on key release for special keys such as Enter, Arrow keys etc, which resulted in duplicate inputs while pressing these keys. key.EditEvents for special keys now fire once on key press only.

Signed-off-by: Rajiv Kanchan <rajiivkanchan@gmail.com>
2020-11-09 11:00:52 +01:00
Elias Naur 8b5c0d8b0c op/paint: document that color.RGBA values are in the sRGB color space
Updates gio#169

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-08 19:31:38 +01:00
Elias Naur dbc0796d02 cmd/gogio,cmd/gogio/testdata: update Gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-06 20:56:54 +01:00
Elias Naur edaa112c40 example: update to latest Gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-05 16:33:38 +01:00
Elias Naur 94d242d18c op/paint: remove support for PaintOp.Rect
PaintOp.Rect is the wrong abstraction; it implies a clip operation
better handled by package clip, and not all paints need it (colors).
Furthermore, it's awkward to specify a PaintOp that fills up the
current clip area, regardless of its size.

Redefine PathOp to mean "fill current clip area".

API change. Replace uses of PaintOp.Rect with a TransformOp applied
before the PaintOp.

Leave a TODO for the PathOp infinity area.

Fixes gio#167

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-05 16:32:19 +01:00
Elias Naur afb52194d1 app/headless,internal/rendertest: replace PaintOps with Fill/FillShape
We're about to remove PaintOp.Rect. Replacing PaintOps with Fill or
FillShape where possible will ease the transition.

Using Fill in tests exposed a problem with the infinity in paint.Fill.
Adjust it for now; it will be removed later.

Updates gio#167

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-05 16:12:39 +01:00
Elias Naur 852958f4b5 gpu,widget,op/paint,gpu: remove support for ImageOp.Rect
This is effectively a revert of commit gioui.org/commit/69dfd2e3a5541.

ImageOp.Rect is the wrong abstraction; it implies a clipping operation that is
better handled by package clip.

API change. Uses of ImageOp.Rect should apply a clip.Rect before the PaintOp,
or use image.RGBA.SubImage (or similar).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-05 13:36:36 +01:00
Elias Naur 6d98eccad0 f32: add Affine2D.String
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-05 13:36:36 +01:00
Elias Naur c62a002d21 gpu: remove unused field
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-05 10:15:46 +01:00
Elias Naur efdd5ae602 op/paint: make the shape argument last in FillShape
FillShape is a generalization of Fill, so it seems more natural to
have the extra argument last.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-03 18:57:25 +01:00
Elias Naur 3107c95757 op/clip: remove unused parameter from Rect.Op
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-03 18:57:25 +01:00
Egon Elbre 88b3c84ef6 example: add gradients
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-03 15:39:06 +01:00
Egon Elbre f00f3a3359 gpu: add linear gradient
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-03 15:39:06 +01:00
Elias Naur 0641a34b24 internal/rendertest: lower test tolerances
Egon Elbre pointed out that a difference of 20 means a 10% difference.
Lowering the tolerance to 5 didn't work on my setup; leave it at 10.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-03 15:39:06 +01:00
Elias Naur 18869735db example/go.*: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-02 19:46:44 +01:00
Elias Naur 38cdd28681 gpu: fix depth buffer corruption on the Fairphone 2
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-02 19:44:56 +01:00
Egon Elbre a55302a498 app/internal/window: use keyed fields
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-01 17:13:00 +01:00
Josiah Niedrauer 42e568775c io/key: implement key.Release state
Implement key state for the following platforms:
js, wayland, windows, x11.

Unsupported platforms will continue to function as before, sending
key.Press for all key events.

Signed-off-by: Josiah Niedrauer <josiah@niedrauer.com>
2020-11-01 17:13:00 +01:00
Elias Naur ef652f4922 app: move ownership of GPU context to app.Window
The Window creates the context, and should also be responsible for
destroying it.

As a bonus, the wrong release ordering of loop.renderLoop is fixed.
Before this change, the context would be destroyed before the renderer
got a chance to destroy its resources.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-10-30 16:47:05 +01:00
Elias Naur 3740f89171 app/internal/window: [Windows] properly handle WM_QUIT
First, don't filter on HWND in GetMessage and PeekMessage, lest
thread-specific messages may get lost. See

https://devblogs.microsoft.com/oldnewthing/20050209-00/?p=36493

Second, replace the dead status with the detection of WM_QUIT; it's
what it's there for.

May update gio#168

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-10-27 17:57:06 +00:00
Elias Naur f9642447ec .builds: fix FreeBSD builders
For some reason, the FreeBSD 12 image doesn't have xorg-vfbserver.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-10-26 21:34:23 +01:00
Chris Waldon 672555d3d0 widget/material: remove unused fill helper
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-10-22 18:57:55 +02:00
Chris Waldon 3d042093a5 widget/material: update buttons to use new paint Fill API
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-10-22 18:57:52 +02:00
Chris Waldon fc307c1e71 op/paint: add Fill helpers for painting an area with a solid color
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-10-22 18:57:47 +02:00
Chris Waldon 685e0772a3 op/clip: add UniformRRect to create rects with uniform corner radii
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-10-22 18:57:43 +02:00
Chris Waldon 8bdca84c56 op/clip: export Op method of clip shapes
This allows passing the resulting clip.Op types into functions that
draw shapes.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-10-22 18:57:40 +02:00
Elias Naur d5bdf0756a cmd/gogio: use GOOS=ios to target iOS with Go 1.16 and newer
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-10-20 11:46:34 +02:00
Elias Naur 7a4b48f67b gpu: delete redundant drawOps.reset
Noticed by Steve Lam

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-10-18 18:22:16 +02:00
Elias Naur 2ddd4f1985 .builds: fix apple builder
The python package is gone, we may not need it and/or Debian installs
python3 by default.

curl is needed for automatically applying patches from the mailing list.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-10-13 15:31:19 +02:00