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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>