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>
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>
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>
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>
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>
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>
Continuing the previous change to minimize Device, in preparation
for supporting foreign Direct3D contexts.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Add support to Router so that the cursor can be changed with CursorNameOp without any mouse movement.
Enter and Leave events are also delivered as areas change.
Signed-off-by: pierre <pierre.curto@gmail.com>
Post a dedicated message upon Window.SetCursor calls.
Make sure that the cursor is only changed if the cursor is in the window.
Signed-off-by: pierre <pierre.curto@gmail.com>
Gio UI may be overlaid on top of custom graphics such as in the glfw example.
That will only work if Gio doesn't clear the screen (to white).
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Tweak a test color to avoid an off-by-1 rounding error after changing
the conversion formula.
Fixes gio#192
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Android can re-create our Activity and GioView at any time, losing view
and activity state such as the current cursor. Further, setting state
while there is no GioView attached is lost.
Track the current and unapplied state, and apply it when a GioView is
available.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
We're about to remove all references to window from runOnMain callbacks.
The JNI methods are constant and can be moved out of window.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Using Window.Invalidate for animation with, say
var w Window
var e FrameEvent
w.Invalidate()
e.Frame(...)
stops and immediately starts animation mode which is inefficient
and may cause jitter in the redraw timing.
InvalidateOp is the efficient and sure way to achieve smooth animation,
and Invalidate only exists for external events where there is nowhere to
add an InvalidateOp.
We can do better, so this change makes Invalidate almost as efficient as
InvalidateOp by checking for Invalidates at the same time we check for
InvalidateOps.
Note that we can't avoid the inefficiency in all cases, for example
when the calls above are swapped,
e.Frame(...)
w.Invalidate()
the Invalidate may not be registered before the check during Frame.
While here, add a note to Invalidate that it's meant for externally
triggered redraws.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Track whether requestAnimationCallback has been called when SetAnimating
changes the animated state of the window. Multiple callbacks result in wasteful
redraws.
Without this change, my browser becomes unresponsive when Window.Invalidate
is called every frame. Calling Invalidate every frame is a misuse (InvalidateOp
should be used for animation), but it's nice to have reasonable behaviour.
This change might also fix the issues described in
https://github.com/gioui/gio/pull/7.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
While here, merge BeginFrame and EndFrame; the split was done for
performance reasons, yet never measured.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Modern graphics APIs have immutable objects, with mutable data. For example,
a texture's dimensions are immutable, while the texture contents is not.
Change the GPU API abstraction to match.
Clearing a Texture is convenient to do with a plain []byte. Generalize
Texture.Upload to take a plain byte slice and introduce a helper function for
uploading *image.RGBA data.
Add TextureFormatRGBA8 a format for the linear RGB colorspace.
Add OpenGL ES 3.1 functions for compute programs.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
NewBackend was recently changed to take a context, which must only
be specified on GOOS=js.
Fixes gio#189
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Currently, on iOS, the keyboard can block the content since it doesn't
trigger the "resize". Now, the `insets` will provide the size of the
keyboard (on iOS) and scrollbars. It's compatible with the Android (and
desktop), but Chrome automatic resizes the windows, so the `Inset` will
be 0.
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>