Commit Graph

1899 Commits

Author SHA1 Message Date
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
Elias Naur 5894127204 internal/unsafe: get rid of GoString
The only users were GOOS=windows code, which can use
golang.org/x/sys/windows.BytePtrToString instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 11:19:53 +01:00
Elias Naur 884e7d27e2 op/clip: don't accept open Paths for Outline
Outline represents a clipping operations that clips all drawing outside
a closed path. Before this change, paths not closed we're patched up by
adding an implicit line from the endpoint to the beginning.

These fixups are inefficient for a rare case, but acceptable because the
old renderer post-processes all paths anyway. However, the new compute
renderer don't need post-processing in most cases, making fixups too
expensive.

Given that clipping to an open path is fundamentally undefined and that
implicit fixup with a closing line segment is merely a way to force the
clip to be well-defined, this change adds a panic to Outline for Paths
that are not closed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 08:57:27 +01:00
Elias Naur 4b377aa896 gpu: resize compute output when it becomes smaller
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-09 18:27:10 +01:00
Elias Naur 3a3ec711d3 gpu: [compute] cache rendered materials
This change tracks materials so that only the updated materials needs to
be rendered.

Materials are likely cheap to render each frame, at least compared to
the rest of the compute pipeline. However, the CPU fallback must
transfer all changed materials to CPU memory, and a cache is a great
improvement over fetching all materials every frame.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-09 13:25:24 +01:00
Elias Naur 1b142c07e0 gpu: separate the construction and placing of material quads
We're about to cache the transformed materials. It's easier to do when
quads can be constructed before determining their atlas position.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-08 20:10:11 +01:00
Elias Naur 57750fc8a0 gpu/headless,gpu/internal: rename "backend" files and names to "driver"
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-08 18:20:11 +01:00
Elias Naur 69cff4b96b gpu/internal/driver,gpu/headless: don't y-axis flip OpenGL ReadPixels images
The CPU fallback of the compute renderer needs ReadPixels data in OpenGL
format (origin at bottom left). Unfortunately, the OpenGL driver
automatically mirrors images in the Y-axis to match the top left origin
image.RGBA.

Remove the mirroring from the driver and introduce a DownloadImage to
restore the old behaviour.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-08 18:12:33 +01:00
Peter Sanford 2aa1cc8112 Add new permission: networkstate
For android this provides ACCESS_NETWORK_STATE

Signed-off-by: Peter Sanford <psanford@sanford.io>
2021-03-08 08:19:22 +01:00
Egon Elbre 5393a05110 gpu/internal/rendertest: test depth buffer overlaps
Regression test for 44991f355c

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-03-06 15:43:37 +01:00
Elias Naur cb1defbc63 gpu/internal/rendertest: move rendertest package below gpu
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:32:43 +01:00
Elias Naur 7059b6284a app/internal/wm: rename confusing app/internal/window
Package wm (for "window manager") is a better fit for the package, and
distinguishes it from the low-level package windows for the Windows API.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:28:57 +01:00
Elias Naur 26d9e7fe5f gpu/headless: rename "backend" to "dev"
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:27:44 +01:00
Elias Naur 91a14c7fa2 app/internal/window: rename "backends" to "drivers"
"driver" is the new more specific name for gpu backends.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:27:44 +01:00
Elias Naur 7bc0603d7e internal/gl: rename internal/glimpl
Now that the OpenGL driver package is named "opengl", we can finally get
rid of the ugly "glimpl" name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:27:44 +01:00
Elias Naur a722768da9 gpu/internal/opengl: rename and make internal the OpenGL driver
It is no longer necessary for outside users of package gpu to explicitly
initialize a specific driver. The Direct3D driver is already internal,
this moves the OpenGL driver internally as well. The rename to opengl is
to avoid the name clash with the low-level "gioui.org/internal/glimpl"
package that we're about to rename.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:27:44 +01:00
Elias Naur c799452c57 gpu/internal/driver: rename gpu/backend
There are no longer any importers of package backend outside of
gioui.org/gpu. Move it internally, and rename it to the slightly more
specific "driver" while we're at it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:27:34 +01:00
Elias Naur 2c7aba9e7c gpu/internal/convertshaders: move internal/cmd/convertshaders
The convert program is only used by the shaders from package gpu, and
we're about to make the backend package imported by the program internal
to package gpu. Move the converter below package gpu.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur 2a66bfb2b4 gpu/headless: move package app/headless
Package headless is more about rendering that windows. Move it
accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur 18a6dcf571 gpu/internal/d3d11: make the Direct3D backend internal to package gpu
The package app/internal/d3d11 now contains only the GPU backend on
Direct3D. Move it below package gpu to reflect that.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur 5a9edc9af8 internal/cocoainit: move app/internal/cocoainit
We're about to move app/headless to gpu/headless, and it imports
cocoainit.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur 3af4e6accf internal/egl: move app/internal/egl
We're about to move package app/headless to gpu/headless, and it needs
the egl package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur 86d17efc2c internal/srgb: move app/internal/srgb
We're about to move app/headless to gpu/headless, and it imports
package srgb indirectly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur e17dd5bd30 internal/d3d11: extract Direct3D API to separate package
We're about the merge the Direct3D backend into package gpu. Extract the
raw Direct3D API to its own package, just like package glimpl.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:25 +01:00