Commit Graph

1922 Commits

Author SHA1 Message Date
Elias Naur ebf2dcea50 gpu/shaders: update piet-gpu
Changes:
- faster implementation of RGBA output
- fix stroked clips and images

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-31 19:56:50 +02:00
pierre 5e1a662b94 io/pointer: support nested scrollables
Fixes #185.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-03-31 09:57:13 +02:00
Elias Naur f3d75f38a9 app/internal/wm: [macOS/iOS] don't release nil strings in nsstringToString
Fixes gio#210

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-29 09:20:24 +02:00
Elias Naur 217f3f4de6 cmd/gogio: dump child program outputs to test log
Without logging, a failing child result in nondescript errors such as

windows_test.go:126: exit status 2

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-28 16:18:47 +02:00
Elias Naur e49afe7fa1 .builds: silence apt-get, curl commands
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-28 15:45:13 +02:00
Elias Naur c2e0910c8b .builds: don't pass -v to go test
Some tests are so verbose they hide the relevant error messages.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-28 14:17:04 +02:00
Elias Naur 17ba8e28af io/router: drop the correct handlers when a pointer grab is requested
Fixes gio#208

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-27 13:18:30 +01:00
Inkeliz 07802569f7 app: [js] move redraw out of js.FuncOf
Currently, the redraw is called inside js.FuncOf. That PR moves the
redraw to the main function, using channels inside the FuncOf, instead.

The current method (of calling inside the FuncOf) seems to be responsable
to generate `deadlock` errors. It happens even when the wrapped in
goroutines.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-03-26 15:48:15 +01:00
Inkeliz 416094a82c app: [js] support for fullscreen mode
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-03-26 08:15:42 +01:00
pierre 3e525a0393 io/router: move static conditions out of the loop
Signed-off-by: pierre <pierre.curto@gmail.com>
2021-03-25 11:11:30 +01:00
pierre b796dd8e3b layout: make list example use List.Position.Count
Counting the number of displayed elements via the ListElement function is incorrect.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-03-25 11:11:25 +01:00
Inkeliz b7dc407dbe cmd/gogio: [android] add support for AAB
That patch makes possible to generate Android App Bundle (`.aab`) instead
of APK. In order to generate AAB use `-o outputfile.aab`.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-03-25 08:19:41 +01:00
pierre 238dd1aa86 app: added support for fullscreen mode
The option field WindowMode allows changing the window mode of an application in either Windowed or Fullscreen.
Only macOS, Windows and X11 platforms are currently supported.

Updates gio#89.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-03-23 23:26:46 +01:00
Elias Naur bc2c3db43e op/clip,gpu: move approximation of complex strokes to op/clip.Op.Add
Before this change, the two renderers both had special case code for
approximating strokes they don't support natively. This change moves
that conversion to clip.Op.Add, for several reasons:

- The compute renderer no longer need fallback logic and caches for
  strokes it doesn't support.
- The approximation logic is slow. Moving it to clip.Op.Add will not
  speed it up, but will make the cost easier to spot in profiles. Until all
  strokes are supported natively, users can use macros to cache
  expensive strokes.
- Reduced garbage: Op.Add takes an op.Ops anyway, and can use that for
  storing the approximated stroke outline.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-23 19:37:45 +01:00
Elias Naur 06c53c3777 internal/ops: expose PC and ResetAt
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-23 16:21:11 +01:00
Elias Naur 0a4b6549da internal/stroke,gpu: move stroking of path data to package internal/strokg
Pure refactor, preparing for use in op/clip.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-23 15:42:43 +01:00
Elias Naur 7825bda8f8 internal/stroke,op/clip: don't import op/clip from internal/stroke
To avoid an import cycle in a future change, internal/stroke can no
longer import op/clip. Move required op/clip functionality to
internal/stroke and duplicate the remaining types.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-23 15:28:52 +01:00
Elias Naur f9cf6ff20a op/clip: separate function for approximating arcs with quadratic curves
Both Path.Arc and the internal stroke package needs to support arcs;
this change isolates the approximation computation into a function we
can move to internal/stroke in a follow-up.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-23 15:01:00 +01:00
Elias Naur 8c8d1dc16f internal/stroke,gpu: create internal package for stroke to path conversion
Complex strokes are not yet supported in either of the current renderers,
so they are converted to filled outlines in package gpu.

We're about to move that complexity up to the op/clip package, so we're
going to need the converter available from outside package gpu. This
change extracts the conversion code and related types to the separate,
internal package stroke.

No functional changes; a follow-up moves the stroke conversion.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-23 12:35:41 +01:00
Elias Naur 8750828c69 gpu,gpu/shaders: [compute] add alpha to output
Fixes the glfw example where Gio content is composited (alpha blended)
on top of custom content.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-22 16:27:26 +01:00
Elias Naur 1dde94d8dd gpu: [compute] use support for simple strokes
In the old renderer, all strokes are converted to filled paths. The new
renderer can draw simple strokes natively. Do that, and avoid the costly
conversions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-19 21:46:32 +01:00
Elias Naur 13da40f601 gpu,op/clip: [compute] get rid of stroke vs fill flags
The fill mode is now controlled by a SetFillMode command, not by flags
on each path segment and fill command.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-19 21:46:31 +01:00
Elias Naur 60bab15164 gpu/internal/rendertest: test textured strokes, including clipping
The new compute renderer can draw simple strokes. Test that clipping
works with a stroke basis, and that images can be drawn into strokes.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-19 21:46:31 +01:00
pierre ac800a9d8f op/clip: optimize zero corner radius in RRect if pixel-aligned
Signed-off-by: pierre <pierre.curto@gmail.com>
2021-03-16 19:00:47 +01:00
Elias Naur eeb045c59f internal/gl: use dlsym(3) to load ES 3 symbols
There was a special case for optional symbols for macOS/iOS. It turns out
dlsym(3) works as expected, so this change deletes the special case.

The change is required to make Gio work with ANGLE, which emulates
OpenGL ES on top of Metal.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-16 18:15:37 +01:00
Elias Naur 8128d6371d gpu: [compute] clear material texture before reusing it
Otherwise the padding we leave around rendered materials may contain
content from reclaimed materials.

Fixes icon "shimmering" when the kitchen example is transforming.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-15 19:17:22 +01:00
pierre 4d4b3a627a widget: fixed missing sides in Border
Signed-off-by: pierre <pierre.curto@gmail.com>
2021-03-15 15:38:25 +01:00
Elias Naur 258033d0b0 gpu: eliminate gaps by ensuring consistent transformations
This is another attempt at fixing the issue described in [0], the
previous attempt was reverted[1].

This change fixes the issue by tracking resolved transformations and
ensure that all segments within a path share a single transformation.

[0] https://github.com/linebender/piet-gpu/issues/62
[1] https://gioui.org/commit/2b21b48a7c5c4451deb642c164548a134bb9ad06

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-15 14:05:15 +01:00
Egon Elbre 9cb9e67a8e op/clip: remove Border
Border can be expressed in-terms of clip.Stroke:

  clip.Stroke{
      Path: clip.UniformRRect(r, rr).Ops(ops),
      Style: clip.StrokeStyle{Width: width},
  }.Add(ops)

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-03-14 13:28:21 +01:00
Egon Elbre fecfbbb050 op/clip: expose Circle.Path and RRect.Path.
These can be nicely used together with clip.Stroke.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-03-14 13:28:21 +01:00
Elias Naur a50a0db3a2 cmd/gogio: bump screenshot retry timeout
Hoping to fix Wayland flakes:

 TestEndToEnd/X11_using_go_import_path: e2e_test.go:102: starting driver and gio app
    TestEndToEnd/Wayland: e2e_test.go:113: retrying after 200ms
    TestEndToEnd/Wayland: e2e_test.go:113: retrying after 400ms
    TestEndToEnd/Wayland: e2e_test.go:113: last error: encountered 12 color mismatches:
          5,5   got 0xffffffffffff, want 0xdedeadadbebe
        395,5   got 0xffffffffffff, want 0xdedeadadbebe
          5,295 got 0xffffffffffff, want 0xdedeadadbebe
        395,295 got 0xffffffffffff, want 0xdedeadadbebe
          5,305 got 0xffffffffffff, want 0x000000000000
        395,305 got 0xffffffffffff, want 0x000000000000
          5,595 got 0xffffffffffff, want 0x000000000000
        395,595 got 0xffffffffffff, want 0x000000000000
        405,305 got 0xffffffffffff, want 0xbbbbbbbbbbbb
        795,305 got 0xffffffffffff, want 0xbbbbbbbbbbbb
        405,595 got 0xffffffffffff, want 0xbbbbbbbbbbbb
        795,595 got 0xffffffffffff, want 0xbbbbbbbbbbbb

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-14 11:51:51 +01:00
Egon Elbre d994d092ae op/clip: use absolute coordinates in RRect
This avoids issues with floating point drift.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-03-14 10:10:00 +01:00
Egon Elbre b9f2e0fb41 widget/material: use clip.Circle to draw circles
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-03-14 10:08:58 +01:00
Egon Elbre ee8e267d22 op/clip: add Circle and Path.CubeTo
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-03-14 10:08:50 +01:00
Elias Naur 2b21b48a7c gpu,gpu/shaders: revert attempt to fix path gaps
This is effectively a revert of [0], reintroducing the path gaps
described in [1]. A follow-up change will implement another attempt.

[0] https://gioui.org/commit/2feec23561cd84d6b8ddbab84a202df66b123208
[1] https://github.com/linebender/piet-gpu/issues/62

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-13 15:23:25 +01:00
Egon Elbre 65a2410bb9 op/clip: ensure that roundRect is always closed
Floating point error may accumulate and the round rect may not
necessarily close up entirely. Add an additional "Close" to ensure
it's properly closed.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-03-13 13:49:59 +02:00
pierre e0262c20e3 io/key: add NameSpace, report it on Linux
Fixes gio#204.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-03-12 13:18:08 +01:00
Elias Naur c5fb759aef op/clip: make RoundCap and RoundJoin the default stroke style
There's an argument that rounded caps and joins are the simplest stroke,
in that it can be defined to cover all pixels within lineWidth distance
from the supporting path.

However, the more important reason is that the compute renderer natively
supports this stroke style (without dashes), and users that don't care
(much) about the particular stroke style should get the efficient
implementation. A good example is op/clip.Border that strokes a closed
path, where the StrokeCap is irrelevant.

This is a (subtle) API change. If you have code that relies on the
default values of clip.StrokeStyle you may want to set Cap and Join
explicitly. See the test changes for examples. On the other hand, you
will get much better performance from the default Cap and Join values
once the compute renderer becomes the default.

Disablethe TestPaintClippedBorder test; dashes round-capped,
round-joined strokes doesn't seem to work correctly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-12 12:19:39 +01:00
pierre 8a7a5a4ca4 font/gofont: removed duplicated entry
Signed-off-by: pierre <pierre.curto@gmail.com>
2021-03-12 12:19:39 +01:00
Elias Naur c4850e876d internal/gl: remove redundant parentheses
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 19:04:34 +01:00
Elias Naur 9e79cee447 op/clip,gpu,internal/scene: encode cubic bézier curves natively
The compute renderer supports cubic curves, so encode them as such.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 18:54:12 +01:00
Elias Naur f1ae923a89 gpu,op/clip: encode lines as compute line commands, not quads
The new renderer supports lines natively; encode them as such and
convert them to a quadratic beziér.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 18:54:12 +01:00
Elias Naur a369c408f9 gpu: [compute] skip encoding roundtrip for path data
Since clip.Path now encodes paths in the format expected by
elements.comp, use that data directly instead of a roundtrip through
drawOps.buildVerts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 18:54:12 +01:00
Elias Naur eb9bf60b09 gpu,internal/ops: decode scene commands directly, not through quads
We're about to let clip.Path use more of the compute renderer features
(lines, cubic béziers). This change prepares the gpu package for reading
one of several commands types, not just the quadratic béziers of before.

The old Quad type is still the basis for the stroking algorithms, but
this change moves it into package gpu which is the only user.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 18:54:12 +01:00
Elias Naur 07572387e3 internal/ops: switch quad encoding to compute format
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 18:54:12 +01:00
Elias Naur 9366fce0f3 internal/scene: extract compute shader encoding to a separate package
We're about to encode clip.Paths with the format compatible with the
compute renderer. This change extracts the encoding to a re-usable
package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 18:54:12 +01:00
Elias Naur fdfa481082 internal/byteslice: add specialized Uint32 for []uint32 view
Uint32 is the garbage-free and more efficient version of Slice.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 18:54:12 +01:00
Elias Naur b8bdb96d35 op/clip,gpu,internal/opconst: remove quad count from Path op
The check for path segments in gpu is redundant; clip.Op.Add doesn't add
the Path op if there were no segments.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 18:19:31 +01:00
Elias Naur 2328ddfeca internal/byteslice: rename package unsafe
All functions left in the old package unsafe were provided byte slice
views of other types. Rename the package accordingly and avoid a name
clash with the standard library package unsafe.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 11:27:02 +01:00
Elias Naur 86f10e33d7 internal/unsafe: get rid of SliceOf
Move SliceOf to the package of the only user and unexport it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 11:20:07 +01:00