Commit Graph

736 Commits

Author SHA1 Message Date
Matthias Clasen
c8133ecb50 gsk: Plug a memory leak 2023-06-09 22:40:38 -04:00
Matthias Clasen
957fa87fce gsk: Support straight alpha textures
This is not the optimal way of doing it: we're
reuploading the texture with client-side conversion.
But it fits nicely into our current handling of mipmaps.

We can do better once we use shaders for colorspace
conversions.
2023-05-31 14:37:33 -04:00
Matthias Clasen
0f61c52593 gdk: Simplify gdk_memory_format_gl_format
Make the callers of this function check for
straight alpha themselves, and only do the
version compatibility check here. This makes
the function usable in contexts where straight
alpha is acceptable.
2023-05-30 14:49:45 -04:00
Matthias Clasen
a4bae6a62d gsk: Use matching memory format
memory_format_gl_format returns the new memory
format if it made a change, we should not drop
that on the floor.
2023-05-30 14:41:01 -04:00
Sophie Herold
ef8c835762 gsk: Support swizzle for gray and alpha formats
Swizzling is needed to display one channel memory formats
as gray etc.
2023-05-30 14:41:01 -04:00
Matthias Clasen
c2a8620660 gsk: Mark some variables as unused
Hopefully that shuts up clang.
2023-05-18 13:29:28 -04:00
Matthias Clasen
4d66598f31 Merge branch 'matthiasc/for-main' into 'main'
gsk: Cosmetics

See merge request GNOME/gtk!5983
2023-05-17 00:58:48 +00:00
Matthias Clasen
2ec1bd7248 Merge branch 'gl-renderer-more-defensive' into 'main'
gsk: Stop setting uniforms when we are out of batches

See merge request GNOME/gtk!5981
2023-05-17 00:29:40 +00:00
Matthias Clasen
4a8a6e9f70 gsk: Don't build unused functions
The only caller is #if 0 ed, so don't build
these functions.
2023-05-16 20:13:57 -04:00
Matthias Clasen
0a9d25c9e8 gsk: Cosmetics
Get the context from the driver.
2023-05-16 20:13:57 -04:00
Matthias Clasen
71a231b71d gsk: Stop setting uniforms when we are out of batches
When the command queue is out of batches, there is
no point in doing further work like allocating uniforms.

This helps us avoid assertions in the uniform code
that we would hit when we run out of uniform space
too.
2023-05-16 20:03:19 -04:00
Benjamin Otte
112fe06323 glrenderer: Remove unused function
Thanks, macos CI.

(We should have a Fedora clang build.)
2023-05-17 01:52:42 +02:00
Matthias Clasen
9dd83ab354 gsk: Fix a crash
When we start ignoring batches, we must do it everywhere,
or we may run into assertions. This was triggered by an
enormous text node tree produced by tests/rendernode-create.
2023-05-16 17:33:21 -04:00
Matthias Clasen
9faf1a0377 gsk: Comment out some debug code
The calls of these functions are #ifdef'ed out,
so no point in compiling these functions.
2023-05-11 06:13:42 -04:00
Matthias Clasen
aee214b09d gsk: Fix some renderer gotchas
unrealize() needs to clean up the surface that was set
in realize(), and both need to emit property change
notification.
2023-05-10 20:21:54 -04:00
Matthias Clasen
1a93efecf3 gsk: Dispose the driver when the display is closed
This was the intention, but the object data by itself
does not achieve that: We do run dispose on the display
when it is closed, but object data is only cleared in
finalize. So listen to the ::closed signal and remove
the driver ourselves.

Fix up the drivers dispose implementation enough for
that to actually work.
2023-05-10 20:21:12 -04:00
Matthias Clasen
97bc4f77c6 gsk: Fix a refcounting mishap
This may fix #5823
2023-05-09 06:56:09 -04:00
Matthias Clasen
e9f5a3e9e2 gsk: Introduce a constant
We need this number in a couple of places,
so pull it out as a constant.
2023-05-05 12:05:10 -04:00
Matthias Clasen
2b85c49fb1 gsk: Add a few assertions
Make sure we don't overflow our fixed-size arrays.
2023-05-05 12:05:10 -04:00
Matthias Clasen
d7c3235cd0 gsk: Add some debug helpers 2023-05-05 12:05:09 -04:00
Matthias Clasen
81fd9741ff gsk: Better handling of offscreens
Take the scale into account for sizing the
offscreens for masks, blends and cross-fades.
2023-05-05 11:37:23 -04:00
Matthias Clasen
ce6569d1a6 gsk: Avoid some offscreens
We don't have to be too conservative when checking
if a rect is contained in a rounded rect, we have
a precise api for this.
2023-05-04 22:30:12 -04:00
Matthias Clasen
b79d4a3a22 gsk: Fix rendering big textures with offsets
When slicing the texture, the GL renderer was
forgetting to apply the viewport origin. This
shows up when rendering things with negative
scales, leading to negative origins.
2023-05-01 14:46:30 -04:00
Matthias Clasen
319762b908 gsk: Extract scales properly from 2D transforms
We have the code to do it properly.
2023-05-01 13:45:20 -04:00
Matthias Clasen
e453a989df Improve rounded rect intersection
Move the rounded rect/rect intersection code to
gskroundedrect.c, make it more precise, and add
tests for it.

Update the callers in the GL renderer.
2023-05-01 13:45:20 -04:00
Matthias Clasen
f56328a6cc gsk: Fix mask transform handling
We must reset the modelview transform when
offscreen, or else we end up applying
it twice.
2023-05-01 13:45:20 -04:00
Matthias Clasen
552df197c4 gsk: Fix blend transform handling
We must reset the modelview transform when
rendering offscreen, or else we end up applying
it twice.
2023-05-01 13:45:20 -04:00
Matthias Clasen
4214067d52 gsk: Fix cross-fade transform handling
We must reset the modelview transform when
rendering offscreen, or else we end up applying
it twice.
2023-05-01 13:44:55 -04:00
Matthias Clasen
d9a2b74b4a gsk: More fixes
Work towards handling negative scales and
denormalized rects everywhere.
2023-05-01 13:43:33 -04:00
Matthias Clasen
4e501d2d44 gsk: Transform rounded rects better 2023-05-01 13:43:33 -04:00
Matthias Clasen
ad65db901a gsk: Normalize rects in GLSL
Our coverage computation only works for well-behaved
rects and rounded rects. But our modelview transform
might flip x or y around, causing things to fail.

Add functions to normalize rects and rounded rects,
and use it whenever we transform a rounded rect in GLSL.
2023-05-01 13:43:33 -04:00
Matthias Clasen
2f96a08b3f gsk: Plug a few memory leaks 2023-04-30 18:21:23 -04:00
Benjamin Otte
76777cdd18 Merge branch 'wip/otte/texturebuilder' into 'main'
Add GdkGLTextureBuilder

See merge request GNOME/gtk!5862
2023-04-28 15:58:10 +00:00
Matthias Clasen
92a9f8cd7e gldriver: Add a sync when creating textures 2023-04-28 06:23:45 +02:00
Matthias Clasen
051b463c9a Fix various bitfield warnings
clang rightly complains about using gboolean
as type for bitfields, since it is signed.
Avoid that.
2023-04-27 13:42:03 +02:00
Matthias Clasen
8292b846d5 gsk: Synchronize when using textures
Pass the GLsync object from texture into our
command queue, and when executing the queue,
wait on the sync object the first time we
use its associated texture.
2023-04-27 06:57:02 +02:00
Benjamin Otte
76e5fd0ece glrenderer: Port to GdkGLTextureBuilder 2023-04-27 06:40:47 +02:00
Benjamin Otte
3aefed39b1 glcontext: Use GdkGLVersion elsewhere
... and add a convenience API to generate GL versions from strings to
make the gdk_gl_context_check() API nicer.
2023-04-27 02:13:32 +02:00
Matthias Clasen
83091c4f15 gsk: Use explicit switches
This makes it harder to forget to add new
node types here.
2023-04-19 09:19:12 +02:00
Matthias Clasen
503a5de7d1 gsk: Mask nodes support 2d transforms
When adding mask nodes, I overlooked that
we have two separate functions for determining
what transforms a node supports without offlines.

Since we claim that mask nodes support general
transform, they must certainly support 2d transforms
as well.
2023-04-19 08:13:55 +02:00
Benjamin Otte
8965d6c7f8 gl: Only allow RGB(A)8 on GLES2
GLES2 has no idea what 16bit textures even are, let alone floating point.
2023-04-17 05:57:44 +02:00
Benjamin Otte
d7309a009c glrenderer: Don't try to use float framebuffers on GLES2
GLES doesn't know what that is.
2023-04-17 05:57:44 +02:00
Benjamin Otte
d37b9619e2 gles: Don't use vertex array objects
They're not needed and GLES doesn't technically support them, even
though GTK had been using them via epoxy sneakily using the
GL_OES_vertex_array_object extension behind our back.
2023-04-15 17:55:20 +02:00
Matthias Clasen
4746ffc4eb Make fractional scaling for GL opt-in
Fractional scaling with the GL renderer is
experimental for now, so we disable it unless
GDK_DEBUG=gl-fractional is set.

This will give us time to work out the kinks.
2023-04-02 11:05:57 -04:00
Matthias Clasen
fa58dd9256 Use fractional scale for the GL renderer
This commit combines changes in the Wayland backend,
the GL context frontend, and the GL renderer to switch
them all to use the fractional scale.

In the Wayland backend, we now use the fractional scale
to size the EGL window.

In the GL frontend code, we use the fractional scale to
scale the damage region and surface in begin/end_frame.

And in the GL renderer, we replace gdk_surface_get_scale_factor()
with gdk_surface_get_scale().
2023-04-02 09:22:56 -04:00
Matthias Clasen
519cde95f0 gsk: Cosmetics
Rename scale_factor to scale in various places,
now that it is no longer an int but a float.
2023-04-02 09:06:56 -04:00
Matthias Clasen
01108d4148 gsk: Pass scale as float to the command queue 2023-04-02 09:06:56 -04:00
Georges Basile Stavracas Neto
70e6bcce16 Merge branch 'gbsneto/mildly-mid-vulkan-fixes' into 'main'
Vulkan transform / scale fixes

See merge request GNOME/gtk!5757
2023-04-01 18:23:12 +00:00
Georges Basile Stavracas Neto
f3b8bd8a98 gsk/gl/renderjob: Decompose matrix for 3D transforms
While this can be more expensive, it's also correct.
2023-04-01 14:47:29 -03:00
Matthias Clasen
a1c5a806b3 Convert headers to #pragma once
The conversion was done by guard2one.
2023-03-31 15:11:10 -04:00