Commit Graph

1854 Commits

Author SHA1 Message Date
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
Elias Naur 8ff6546285 gpu,gpu/backend: implement generic backend.NewDevice
NewDevice creates a Device given an API, which is the necessary GPU
resources for a backend.

Convert gpu.New to take an API instead of a backend.Device directly.

In turn, this frees us to later unexport the backend package along with
the backend implementations (for now just gioui.org/gpu/gl for OpenGL).
It also allows programs that embed Gio (such as gioui.org/example/glfw)
to freely choose a backend, not just OpenGL.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:24:09 +01:00
Elias Naur 0e723fa192 app/internal/d3d11: change NewBackend to only require a ID3D11Device
Completing the goal of allowing foreign Direct3D contexts for our
D3D backend, slim down the constructor to take only the device handle.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:23:45 +01:00
Elias Naur c3dde562df app/internal/d3d11: only use passed in ID3D11Device in NewBackend
We're about to enable drawing into foreign Direct3D contexts. In
preparation, NewBackend should only need a device handle.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:22:58 +01:00
Elias Naur 932465d891 app/internal/d3d11: move features from Device to Backend
Continuing the previous change to minimize Device, in preparation
for supporting foreign Direct3D contexts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:21:51 +01:00
Elias Naur 840b9ffa9b gpu/backend,gpu,app/internal/d3d11: move device state to backend
We'd like to allow Gio to share a Direct3D context with an embedding
program like the GLFW example does for OpenGL. To do that, d3d11.Device
needs to carry only the minimal information needed (ID3D11Device).

This change moves the caches of ID3D11DepthStencilState and
ID3D11BlendState from from d3d11.Device to d3d11.Backend. It also adds a
Release method for freeing them.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:21:51 +01:00
Elias Naur 44991f355c app/internal/d3d11: include depth buffer in current framebuffer query
Fixes rendering on Windows. Thanks to Egon Elbre for noticing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:21:15 +01:00
Egon Elbre 9793fcfcd0 widget: add Fit and Position to Image for image placement
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-03-05 10:45:58 +02:00
Egon Elbre 2c5daf10a2 widget: add Fit for scaling widgets
Currently adds four different variants Unscaled, Contain, Cover, ScaleDown and Fill.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-03-05 10:25:57 +02:00
Egon Elbre 9e85b43b0c layout: expose Direction.Position calculation
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-03-05 10:19:10 +02:00
Elias Naur 3627df7efa app/internal/d3d11,gpu/gl: simplify BeginFrame implementations
BeginFrame returns the output framebuffer, and need not be as general
as the newly unexported currentFramebuffer methods.

No functional change.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-04 14:08:39 +01:00
Elias Naur be04dfae83 app/headless: bind output framebuffer at render, not creation
Bind the framebuffer as late as possible to lessen the risk of
confusing global state (current framebuffer). Commit
25a19481e3 removed the assumption
that the framebuffer current at gpu.New would always be the output
framebuffer

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-04 14:08:39 +01:00
Elias Naur b1dfc94a9b app/internal/window: use golang.org/x/window UTF-16 routines
Less code, no functional change.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-04 14:08:39 +01:00
Elias Naur 2bd539d2de widget/material: use simpler clip.Rect for Clickable clip region
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-03 20:04:46 +01:00
Elias Naur b39d1bdac7 widget: handle hovering of the empty Enum key
Before this change, a radio button with the empty key ("") would be
displayed as hovering if no other button were.

It's still not possible to have no radio buttons selected when one of
them is the empty key. If that's becomes necessary, Enum.Value can be
converted to a *string.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-03 18:12:39 +01:00
Elias Naur de7a5985d5 widget/material: remove bogus minimum cosntraint from checkable
checkable.layout forces the label to take up at least constraints.min
space. However, for min == max, the total checkbox plus label would then
overflow. The minimum constraint doesn't seem necessary anymore, so drop
it.

Remove a superfluous layout.W layout as well.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-03 17:32:31 +01:00
Elias Naur 57dee8e61a cmd/gogio: bump Wine timeout for window movement
The Windows tests on builds.sr.ht are still flaky:

    TestEndToEnd/Windows: e2e_test.go:130: retrying after 400ms
    TestEndToEnd/Windows: e2e_test.go:130: retrying after 800ms
    TestEndToEnd/Windows: e2e_test.go:130: retrying after 1.6s
    TestEndToEnd/Windows: e2e_test.go:130: retrying after 2s
    TestEndToEnd/Windows: e2e_test.go:130: last error: encountered 6 color mismatches:
	5,5   got 0xffffffffffff, want 0xffff00000000
	395,5   got 0xffffffffffff, want 0xffff00000000
	5,305 got 0xffff00000000, want 0x000000000000
	395,305 got 0xffff00000000, want 0x000000000000
	405,305 got 0xffffffffffff, want 0xffff00000000
	795,305 got 0xffffffffffff, want 0xffff00000000
    TestEndToEnd/Windows: e2e_test.go:130: hit timeout of 4s after 6 tries

Bump the window movement delay in the hope that it helps.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-03 11:15:13 +01:00
Elias Naur ffb26b0e17 io/pointer: rename button names to reflect their meaning, not placement
For example, ButtonLeft may be the right-most button for a left-handed user.
Rename the button names to match their intended use.

This is an API change. Use the following commands to update your
projects:

    $ gofmt -r 'pointer.ButtonLeft -> pointer.ButtonPrimary' -w .
    $ gofmt -r 'pointer.ButtonRight -> pointer.ButtonSecondary' -w .
    $ gofmt -r 'pointer.ButtonMiddle -> pointer.ButtonTertiary' -w .

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-03 11:08:41 +01:00
Elias Naur f36ed04380 app/headless,app/internal/window: unexport embedded Device fields
There is no need for the fields to be embedded nor exported.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-02 20:51:28 +01:00
Elias Naur fc56d438f3 app/internal/d3d11: don't track the Backend for a Device
A previous commit removed the assumption that the output framebuffer
is constant across frames. Thus it is no longer necessary to track
and update a backend's current framebuffer when the window is resized.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-02 20:44:56 +01:00
Elias Naur 25a19481e3 gpu,gpu/backend: don't assume constant output framebuffer
Return the output framebuffer from BeginFrame, to make it clear that
it may change between frames. Delete CurrentFramebuffer which is no
longer needed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-02 20:43:59 +01:00
Elias Naur 3d3ff575e3 app/internal/windows,app/internal/d3d11: ensure error is returned
d3d11Context.Present would return a nil error if the underlying error
d3d11.ErrorCode.

While here, use defer for a resource cleanup.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-02 20:02:59 +01:00
Egon Elbre 8571433707 internal/cmd/convertshaders: parallelize compilation
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-03-01 09:59:32 +01:00
Chris Waldon 54cddf5ca3 app/permission: update doc to reference app.ViewEvent
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2021-03-01 08:24:06 +01:00
Egon Elbre e1248651c8 layout: automatically add system inset for NewContext
Currently every user needs to manually adjust for system insets.
This is rather verbose and most don't need to deviate from this behavior.

To disable the automatic adjustment, use:

  e.Insets = system.Insets{}
  ctx := layout.NewContext(ops, e)

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-02-28 19:08:43 +01:00
Chris Waldon 6faed7e724 widget: fix image scaling
Commit 94d242d broke the widget.Image's Scale field so
that it no longer had any effect on the actual size of
the displayed image. This commit fixes that, as well as
adding tests to confirm that the widget.Image type
scales appropriately with DPI changes and its own Scale
field.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2021-02-28 10:19:49 +01:00
Egon Elbre 60db802951 cmd/gogio: fix test work group handling
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-02-28 10:18:37 +01:00
Egon Elbre 2e15c3d5b9 cmd: fix hash to gioui.org
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-02-28 10:18:37 +01:00
Egon Elbre f6fba73885 internal/cmd/convertshaders: add Windows comp shader compilation
Use dxc (DirectXShaderCompiler) for compiling, which is newer than fxc
and doesn't not fail compilation with dynamically uniform flows with
barriers.

Currently requires -directcompute to enable generating the shaders.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-02-25 13:01:18 +01:00
Inkeliz 8227f7ab04 cmd/gogio: [android] update target sdk version
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-02-25 12:44:28 +01:00
Elias Naur f973b3f384 gpu,gpu/backend: [compute] handle loss of buffer contents during download
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-24 18:48:03 +01:00
Egon Elbre e66979a8c0 io/router: fix negative areas
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-02-24 17:12:36 +01:00
Elias Naur cfb6f477de gpu: [compute] remove even more unused commands
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-24 13:42:39 +01:00
Elias Naur 53763a3410 cmd/gogio: raise end-to-end test timeout
Windows tests often flake:

TestEndToEnd/Windows: e2e_test.go:113: last error: encountered 6 color mismatches:
          5,5   got 0xffffffffffff, want 0xdedeadadbebe
        395,5   got 0xffffffffffff, want 0xdedeadadbebe
          5,305 got 0xdedeadadbebe, want 0x000000000000
        395,305 got 0xdedeadadbebe, want 0x000000000000
        405,305 got 0xffffffffffff, want 0xbbbbbbbbbbbb
        795,305 got 0xffffffffffff, want 0xbbbbbbbbbbbb

Bump the timeout as a quick workaround.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-24 12:52:12 +01:00
pierre cfb16083a2 io/router: improve areaOp methods performance
name             old time/op  new time/op  delta
AreaOp_Decode-8  10.5ns ± 2%   6.2ns ± 3%  -41.50%  (p=0.000 n=10+10)
AreaOp_Hit-8     4.44ns ± 4%  3.57ns ± 2%  -19.59%  (p=0.000 n=10+10)

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-02-24 12:42:34 +01:00
Inkeliz 212f7809cb cmd/gogio: [android] allow custom signature-key
That change makes possible to provide custom PKCS#12 (JKS/PFX) using `-signkey` and the password with `-signpass`.

By default the gogio will use the `debug.keystore`, if no key is provided.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-02-24 12:34:43 +01:00
pierre 60d48014d4 io/router: avoid event copy for filtered events in pointerQueue
Signed-off-by: pierre <pierre.curto@gmail.com>
2021-02-24 12:32:01 +01:00
pierre 14595dde9f internal/opconst: removed unused TypeLayer
Signed-off-by: pierre <pierre.curto@gmail.com>
2021-02-24 10:11:50 +01:00
Elias Naur 51ba55071b gpu: [compute] remove more unused commands
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-24 10:04:34 +01:00
Elias Naur 284659d3ea gpu/shaders: [compute] remove unused command from kernel4
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-22 18:25:43 +01:00
Elias Naur c849c5b77f gpu: [compute] use correct usage flags for output image
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-22 17:19:15 +01:00
Inkeliz 2a7295750d cmd/gogio: fix icon/resources for Android
Previously that patch, gogio unzip the `link.apk` (generated by AAPT2) to an temporary folder and then compress it again to a new `app.ap_` file.

For some unknown reason, that unzip-then-zip doesn't work. The resources are included but is corrupted in somehow. That PR aims to fix that by avoid the extraction to an temporary folder.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-02-22 12:10:36 +01:00
Elias Naur 9d1e3370f4 app/internal/window: fix Wayland clipboard reading
The Wayland protocol implicitly dup(2)s the pipe write end descriptor passed to
wl_data_offer_receive. As long as we also have an open descriptor for the write
end, the pipe will not close and signal the completion of the clipboard read.

This change explicitly and immediately closes our write descriptor. Before this
change, reading the Wayland clipboard worked with some delay because the Go
garbage collector closed the write end of the transfer pipe after some time.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-21 14:36:36 +01:00
Elias Naur 2feec23561 gpu: [compute] fix path gaps by eliminating redundant path points
See https://github.com/linebender/piet-gpu/issues/62 for description
of the issue. The fix is the Gio copy of the piet-gpu fix.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-18 10:30:05 +01:00
Elias Naur b5d21b209c gpu: [compute] use array type for scene elements
All scene elements have a fixed size in uint32s. Model them accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-18 10:30:05 +01:00
Elias Naur c9a8265126 gpu: [compute] pre-transform images before rendering
We're about to change the last stage of the compute pipeline to only
accept images, not sampled textures. This change prepares materials
for pixel-aligned image copying by pre-rendering images to a texture,
applying transforms.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-18 10:30:05 +01:00