Commit Graph

2231 Commits

Author SHA1 Message Date
Elias Naur 1672c88d9e go.*: update gio-shader version
Fixes the compute renderer on iPhone 6.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-22 16:03:11 +02:00
Elias Naur e4b96cb779 io/router: avoid a decode round for key ops
Like a previous change for pointer ops, process key ops during the
router decode of ops. This is a performance optimization and preparation
for processing future accessibility ops without without another decode
loop.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-22 15:17:05 +02:00
Elias Naur 60846d112b io/router: introduce pointerCollector to avoid an ops decode
The router package decodes the entire ops list thrice: once for pointer
ops, once for key ops, once for other ops. This change removes one
decode round by merging other ops and pointer ops decoding.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-21 18:16:12 +02:00
Elias Naur a4626d9304 io/router: make the zero value collectState the reset state
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-20 11:31:00 +02:00
Pierre Curto 6b0e00b9aa io/pointer: change Type to uint
This is to allow for future new Types.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-20 10:09:58 +02:00
Elias Naur aac53ad0b5 gpu: don't alias stroked paths with outline paths
The default renderer caches pre-processed paths for efficient re-use,
but failed to distinguish outline paths from stroke paths.

Fixes gio#294

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-20 10:07:22 +02:00
Pierre Curto 9c16954bef gesture: add Hover type
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-19 15:59:25 +02:00
Pierre Curto e6ed25bb1f io/router: deduplicate pointer handlers
When the same handler is added several times
and that handler sets pointer.Grabbed, it gets lost.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-19 15:00:29 +02:00
Pierre Curto e5d8a4b8d0 io/router: reuse scratch space in pointerQueue.Frame
This removes the allocation needed to drop all handlers except one.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-18 11:47:49 +02:00
Pierre Curto 9be171190e io/router: convert pointerQueue.dropHandlers to pointerQueue.dropHandler
dropHandlers is mainly used for single tag removal except in one instance.
In that case, simply use a loop.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-18 11:47:36 +02:00
Pierre Curto ae5219e4d4 io/pointer: print all types in Type.String
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-17 14:50:28 +02:00
Dylan Staley 4d22a926a9 app: [android] handle touch events from stylus
Fixes gio#291

Signed-off-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
2021-10-16 08:43:51 +02:00
Elias Naur 0048f7be1d internal/ops: hide Ops methods by converting them to package functions
Ops is in the internal package ops, but external clients can reach its
method through op.Ops.Internal. Hide them by converting them to internal
package functions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-12 14:50:15 +02:00
Elias Naur 87d050bcc7 internal/ops: remove Data, Version, Refs methods from Ops
They're only used internally.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-12 14:28:05 +02:00
Pierre Curto 05f0f5c20f f32: add Point.Div
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-11 20:30:43 +02:00
Elias Naur a4242d04d1 cmd/gogio: ensure compatible gioui.org module version
Fixes gio#286

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-09 16:58:57 +02:00
Elias Naur 960f3068a1 io/pointer: re-introduce PassOp
A previous change merged PassOp with AreaOp under the assumption that
the pass mode would be set on a particular area. That assumption turns
out not to hold, so this change brings back PassOp as an independent
stack operation.

This is an API change: replace AreaOp{Pass: true} with a separate
pointer.PassOp operation.

Fixes gio#288

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-09 16:31:54 +02:00
Elias Naur 61a3395879 internal/vk: ignore software Vulkan implementations
It's better to fall back on OpenGL than to accept a software Vulkan
implementation. More importantly, some software implementations such as
lavapipe doesn't even work[0].

[0] https://gitlab.freedesktop.org/mesa/mesa/-/issues/5473

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-09 16:31:47 +02:00
Elias Naur ebad5afdf3 app: [Vulkan] don't exit early on VK_SUBOPTIMAL_KHR
The mapErr helper may map the error to nil, in which case the caller
should continue, not exit.

This change split up error mapping into mapErr which never maps to nil,
and mapSurfaceErr which handles the VK_KHR_swapchain errors and may map
to nil.

Maybe fixes gio#287

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-09 10:46:37 +02:00
Elias Naur bd1ef92dc4 op/clip: remove complex stroke support
In a discussion with Raph Levien, the author of our compute renderer
implementation, it became clear to me that it's not at all certain that
complex strokes will ever be efficiently supported by a GPU renderer.

At the same time, the machinery for converting a complex stroke to a
GPU-friendly outline has a significant maintenance cost. Further, it is
surprising to users that complex strokes are significantly slower and
allocate memory.

This change removes support for complex strokes, leaving only
round-capped, round-joined strokes supported by the compute renderer.
The default renderer still converts all strokes to outline, but it also
caches the result.

This is an API change. The complex stroke conversion code has been moved
to the external gioui.org/x/stroke package, with a similar API.

Updats gio#282 (Inkeliz brought up the allocation issue)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-08 18:10:47 +02:00
Elias Naur 391725b9d0 op: move Ops internal methods and state to internal package ops
Merge package opconsts into ops as well; it only existed to break
import cycles.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-08 17:21:56 +02:00
Elias Naur 936c266b03 all: [API] split operation stack into per-state stacks
The op.Save and Load methods exist to support the need for
transformation, clip, pointer area state to behave as stacks. For
example, layout needs to apply an offset to its children but not
subsequent operations.

Before this change, op.Save and Load were used to save and restore the
state:

    ops := new(op.Ops)
    // Save state.
    state := op.Save(ops)
    // Apply offset.
    op.Offset(...).Add(ops)
    // Draw with offset applied.
    draw(ops)
    // Restore state.
    state.Load()

A drawback with the op.Save mechanism is that there is no direct
connection between the state change and the saving and loading of state.
This causes confusion as to when a Save/Load is needed and who is
responsible for performing them, which leads to subtle bugs and over-use
of Save/Loads.

This change gets rid of the general state stack and replaces it with
per-state stacks. There is now a stack for transformation, clip, pointer
areas, and they can only be restored by the code pushing state to them.
The example above now becomes:

    ops := new(op.Ops)
    // Push offset to the transformation stack.
    stack := op.Offset(...).Push(ops)
    // Draw with offset applied.
    draw(ops)
    // Restore state.
    stack.Pop()

For convenience, transformation also be Add'ed if the stack operation is
not required.

Simple state such as the current material no longer has a way to be
restored; it is assumed the client of a PaintOp adds their desired
material operation before it.

API change: replace op.Save/Load with explicit Push/Pop scopes for
op.TransformOps, pointer.AreaOps, clip.Ops.

To ease porting, this change retains a version of op.Save/Load that
saves and restores the transformation and clip stacks. It also retains
an Add method for clip.Op.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-08 17:21:56 +02:00
Elias Naur 6f80b94b4a io/pointer,io/router: [API] make pass-through a property of AreaOp
We're about to make operation scopes explicit, which would result in
both AreaOp and PassOp be scoped. However, PassOp seems to light to have
its separate stack, so this change instead makes pass-through a property
of an area. We're assuming that clients that want pass-through are also
aware of the affected hit area.

API change: replace PassOps with the AreaOp.PassThrough field.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-08 15:54:50 +02:00
Elias Naur 62daadb37c op/clip: add absolute Path.ArcTo for completeness
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-07 17:36:36 +02:00
Elias Naur 794b7854ea gpu/internal/rendertest: add missing license headers
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-07 17:03:28 +02:00
Elias Naur c1298cd755 font/opentype,text,widget: use clip.Op for text shapes, not a macro
This change avoids a macro wrapping every text shape, and prepares text
shaping for scoped clip operations.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-07 15:01:17 +02:00
Elias Naur cd5a78f3d8 widget: make Fit.scale a pure function
Most importantly, return dimensions and transformation instead of adding
operations. Makes the function easier to test, and supports scoped
transform and clip stacks.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-07 15:01:17 +02:00
Elias Naur cccb8d2c2b io/router: remove redundant state field
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-07 15:01:17 +02:00
Elias Naur c657f974c5 gpu: [compute] move encoderState.intersect to clip state
We're about to split state into a clip stack and a transform stack. The
intersect fields belongs to clip state.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-07 15:01:17 +02:00
Elias Naur 8ebea5ad1f gpu: move drawState.clip to pathOp
The clip field tracks the intersection of the clip stack, and belongs in
the clip stack entries. This is a refactor that makes it easier to
implement scoped clip operations.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-07 15:01:06 +02:00
Elias Naur a96c68fed1 gpu: move drawState.rect to pathOp
The rect field tracks whether the clip stack can be represented by a
pixel-aligned rectangle. It is easier to track as part of pathOp instead
of the global drawState.

Remove an obsolete comment while here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-07 15:00:55 +02:00
Pierre Curto 3c34a39d88 io/router: remove panics in clipboardQueue
Since the Process* methods on clipboardQueue are called while decoding
the ops, no need to recheck for the op type.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-06 09:40:27 +02:00
Pierre Curto e11ac9784c gesture: add the Pressed method to Drag
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-06 08:21:55 +02:00
Pierre Curto c1bd206ece io/router: removed unused field
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-06 08:21:48 +02:00
Elias Naur 30ecf75a0f gpu/internal/opengl: save and restore GL state only for shared contexts
Most Gio programs have exlusive access to their OpenGL contexts, where
saving and restoring of the GL state is not required.

This change applies to all OpenGL platforms, but matters most for WASM
where syscalls are slow.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-05 08:41:12 +02:00
Elias Naur 3abc891680 gpu/internal/opengl: [OpenGL] respect render target when emulating sRGB
Before this change, the sRGB emulation target would always be the
current framebuffer. Now it's the render target passed to BeginFrame.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-05 08:22:52 +02:00
Pierre Curto bfd1e76b78 io/router: refactor pointer.Push for clearer flow
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-03 17:38:39 +02:00
Pierre Curto 5860818537 io/router: merge cancelHandlers and dropHandlers
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-03 17:32:00 +02:00
Inkeliz 50476239f6 cmd/gogio: compile when no icon is found
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-10-03 15:48:02 +02:00
Elias Naur d6e6ca848a app: don't miss driver defers
Fixes gio#281

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-30 18:21:18 +02:00
Elias Naur 6c1f9c19f5 app,internal/vk: [Vulkan] skip frame with stale window dimensions
While here, add a missing nil check.

Updates gio#280

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-30 17:46:23 +02:00
Elias Naur 9e8fe5305b gpu/internal/opengl: don't panic when uniforms are optimized out
glGetUniformLocation can return -1 (not found) for uniforms that have
been optimized out during linking of a GPU program. This happens because
the default renderer compile multiple program from the same generic
template.

Updates gio#280

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-30 16:39:22 +02:00
Elias Naur 41f3a7e74e gpu: [compute] restore relative transformation correctly on state load
Fixes gio#277

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-25 12:06:15 +02:00
Elias Naur 3434bf8af1 internal/ops: don't run deferred macros twice
Discovered while debugging #277.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-24 15:14:45 +02:00
Elias Naur 72c67ff180 internal/opconst: add OpType.String
For gio#277

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-24 14:57:48 +02:00
Elias Naur 8b4758947f internal/scene: add color to OpFillColor String representation
For gio#277

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-24 14:57:41 +02:00
Elias Naur 868ea76acf app: [X11] avoid deadlock when sending initial ConfigEvent
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-24 12:48:10 +02:00
Elias Naur bdafb3564f gpu,app: [Metal] don't store CFTypeRef values in pointer types
CFTypeRefs may not always contain valid pointers, so they must not be
stored in pointer types lest the Go runtime treats them as such.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-23 15:32:58 +02:00
Elias Naur 8c6e3c5fdf app: [Metal] don't wait for completion of presentation command
There's no need to wait; the Metal backend performs the required
synchronization.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-23 15:26:56 +02:00
Elias Naur 94f7fa3218 app: [Vulkan] keep VkSurfaceKHR ownership to platforms
Before this change, it was unclear who owned the platform specific
VkSurfaceKHR object, leading to a double-free in the error path for
devices with no Vulkan support. This change moves the ownership to the
platform specific code.

Add vk.EnumeratePhysicalDevices while here (refactor was part of
debugging of the double-free).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-23 12:35:26 +02:00