Commit Graph

1805 Commits

Author SHA1 Message Date
sumibi-yakitori
cf9c49dcb1 glrenderer: Fix to prevent creation of GL_TEXTURE_MAG_FILTER filters with incorrect values 2023-03-27 04:53:04 +09:00
Matthias Clasen
22ea1af569 gsk: Avoid copying GL texture in more cases
When the GL texture already has a mipmap, we don't
have to download and reupload it to generate one.

We differentiate the handling for texture scale nodes,
where we do want to force the mipmap creation even if
it requires us to reupload the GL texture, and plain
texture nodes, where we just take advantage of a
preexisting mipmap to allow trilinear filtering for
downscaling, or create one if we have to upload the
texture anyway.
2023-03-23 23:17:54 -04:00
Matthias Clasen
9dcc1943b3 gsk: Improve slice handling
Upload slices in chunks, instead of copying
enormous amounts of memory.
2023-03-22 00:15:32 -04:00
Matthias Clasen
c3ee8d2699 gsk: Add more flexible texture upload
Add a command queue function to create a
GL texture by uploading several GdkTextures
at given positions.
This lets us 'piece together' textures.
2023-03-22 00:15:04 -04:00
Matthias Clasen
50969d7923 gsk: Drop debug code 2023-03-22 00:15:04 -04:00
Matthias Clasen
5de8e9ec6e gsk: Drop some unused arguments
All callers of the slice apis pass 0 for
min_rows and min_cols. So just drop these.
2023-03-22 00:14:43 -04:00
Matthias Clasen
d1fc44d3a6 gsk: Use overlapping slices
Store texture coordinates for each slice
instead of assuming 0,0,1,1, and generate
overlapping slices to allow for proper mipmaps.

This almost fixes trilinear filtering with
sliced textures.
2023-03-22 00:14:43 -04:00
Matthias Clasen
8f73a7c690 gsk: Cosmetics 2023-03-22 00:14:16 -04:00
Matthias Clasen
a19cf02b16 gsk: Use mipmaps when it is beneficial
If a texture node ends up getting scaled
down a lot, it helps to use trilinear filtering.
2023-03-19 21:45:30 -04:00
Benjamin Otte
17c877659c glrenderer: Support GL without samplers
We cheat and just set the texture parameters instead and hope nothing
explodes.
So far it didn't.

This is only needed to support GLES 2.0 so it's quite a limited set of
hardware these days.
2023-03-18 21:33:17 -04:00
Benjamin Otte
b5345b7f25 glrenderer: Handle filters differently
Instead of uploading a texture once per filter, ensure textures are
uploaded as little as possible and use samplers instead to switch
different filters.

Sometimes we have to reupload a texture unfortunately, when it is an
external one and we want to create mipmaps.
2023-03-18 21:33:17 -04:00
Matthias Clasen
d31ba5f551 gsk: Drop texture subsetting
We don't do this for unfiltered textures either,
and with working slicing, it isn't needed.
2023-03-18 00:10:38 -04:00
Matthias Clasen
8aa095c4d7 gsk: Avoid reuploading textures too much
When filtering changes for an already-cached
texture, we need to clear the render data
before setting the new one, otherwise it
does not take and we end up reuploading
the texture every frame.
2023-03-17 22:31:10 -04:00
Matthias Clasen
3877a2e533 gsk: Drop texture subsetting
We don't do this for unfiltered textures either,
and with working slicing, it isn't needed.
2023-03-17 11:25:38 -04:00
Matthias Clasen
b14a134a46 gsk: Add slicing to texture scale nodes
This makes it possible to use large textures
with filtering.

Fixes: #5664
2023-03-17 00:51:05 -04:00
Matthias Clasen
f3b0aa27ea gsk: Be more careful when slicing
We can only reuse existing slices if they
have the right filtering.
2023-03-17 00:50:01 -04:00
Benjamin Otte
9a4decc30f gldriver: Quick workaround for filter mismatch
We should really use texture views or samplers to handle this case for
shared textures, but this at least makes NEAREST not break.
2023-03-17 00:43:21 +01:00
Matthias Clasen
d1256648f4 gsk: Use linear filtering for sliced textures
We use linear for unsliced textures, so we need
to do the same for sliced ones.
2023-03-15 17:50:01 -04:00
Matthias Clasen
2322fecf3b gsk: Fix texture slicing
We were just returning NULL for slices
here, which wasn't the intention.
2023-03-15 15:45:01 -04:00
Matthias Clasen
2e2c41cef6 gsk: Fix handling of large textures
When the texture is too large, actually
shrink the size to max_texture_size.
2023-03-15 15:33:32 -04:00
Matthias Clasen
895d427c6a gsk: Add a way to limit texture sizes
Allow to set max texture size using the
GSK_MAX_TEXTURE_SIZE environment variable.

We only allow to lower the max (for obvious
reasons), and we don't allow values smaller
than 512 (since our atlases use that size).
2023-03-15 14:35:57 -04:00
Matthias Clasen
9f88dba162 gsk: Stop using g_slice 2023-03-14 14:56:42 -04:00
Matthias Clasen
c035384fc8 gsk: Mark mask nodes as 'supports transforms'
Just like blur nodes, the renderer can handle
these without creating an extra offscreen.
2023-03-14 01:14:57 -04:00
Matthias Clasen
dcc6cb8f1c gsk: Fix rotated texture scale nodes
This was causing us to render rotated texture scale
nodes to an unclipped offscreen, bringing 'giant
intermediate texture' problems back.
2023-03-14 05:36:08 +01:00
Matthias Clasen
7bdb146473 docs: Details about texture scale nodes
Add some more details about filtering, to
clarify things a bit.
2023-03-13 08:38:58 +01:00
Benjamin Otte
97d53b1e86 Merge branch 'wip/otte/rendernode-export' into 'main'
rendernode: Register SVG serializer

See merge request GNOME/gtk!5637
2023-03-11 00:26:18 +00:00
Benjamin Otte
fc74eed425 rendernode: Register PNG serializer
This allows dropping or copy/pasting rendernodes into apps that accept
images.
2023-03-11 00:08:44 +01:00
Benjamin Otte
0db9677b3a rendernode: Register SVG serializer
This allows dropping or copy/pasting rendernodes into apps that accept
SVGs.

Not sure how useful this is because we advertise text/plain from
rendernodes already and we prefer that.
2023-03-10 23:53:50 +01:00
Matthias Clasen
0f02040292 gsk: Cache scaled texture
Keep the texture we create for texture scale nodes.

Fixes: #5642
2023-03-10 21:09:27 +01:00
William Roy
aaeec84d75 Fix compile_resources present source directory
In certain scenarios, address the issue where gnome.compile_resources 
fails to transmit the present source directory. This is most notably 
visible with MSBuild.
2023-03-07 21:59:50 +00:00
Matthias Clasen
3a0152b65f gl: Respect clip wehn drawing scale nodes
Use the same approach and only create an offscreen
that is big enough for the clipped part of the scaled
texture.

If the clipped part is still too large for a single
texture, we give up and just render the texture without
filters (using the regular texture rendering code path
which supports slicing).

The following commit will add the texture-scale-magnify-10000x
test which fails without this fix.
2023-03-03 11:32:08 -06:00
Benjamin Otte
22ba6b1f33 rendernode: Respect clip when drawing scale nodes
Scale nodes can use large scale factors and we don't want to create
insanely huge Cairo surfaces.

A subsequent commit will add the texture-scale-magnify-10000x
test which fails without this fix.
2023-03-03 11:31:31 -06:00
Benjamin Otte
718b5d5fe7 rendernode: Clarify some Cairo stuff
Split out a function to make it more obvious what's going on.
2023-03-03 11:24:46 -06:00
Benjamin Otte
88dd64551c rendernode: Don't do unnecessary stuff
Cairo surfaces are created transparent.

And even if they weren't, overdrawing with transparency wouldn't erase
what's in the surface because it's a no-op.

It would require CAIRO_OPERATOR_CLEAR or CAIRO_OPERATOR_SOURCE.
2023-03-03 11:24:46 -06:00
Sebastian Dröge
323ba14dde Fix self-(type) annotations for TextureScaleNode methods 2023-02-19 19:00:34 +02:00
Sebastian Dröge
ca93512106 Add two missing Since markers 2023-02-19 11:18:15 +02:00
Matthias Clasen
0b4d41698b mask: Fix glsl 2023-02-17 06:26:42 -05:00
Matthias Clasen
351abadee7 Make make not fallback match GL
We were not handling the inverted-luminance
case the same way, and it caused a test to
fail. Yay for tests.
2023-02-14 21:47:54 -05:00
Matthias Clasen
951db28f71 rendernodeparser: Fix mask mode handling
I had forgotten inverted-luminance, and also
to print an error.
2023-02-14 21:01:12 -05:00
Benjamin Otte
40e7a265a7 rendernodeparser: Print an error when failing to parse an enum 2023-02-14 21:01:12 -05:00
Matthias Clasen
9a539cec57 Merge branch 'mask-modes' into 'main'
Make mask nodes more versatile

See merge request GNOME/gtk!5521
2023-02-15 00:57:17 +00:00
Matthias Clasen
0eb791eaaa Make mask nodes more versatile
Add a GskMaskMode enumeration and implement it
in the GL and cairo renderers.
2023-02-14 19:07:01 -05:00
Benjamin Otte
774696011d glrenderer: Use GdkTexureDownloader 2023-02-15 00:39:18 +01:00
Benjamin Otte
c9f54ca371 texture: Export gdk_texture_get_format()
The API docs outline why quite well.

This should make it possible to do saving of textures to image files
without any private API with the same featureset that GTK uses.

Also remove the gsktextureprivate.h include where
gdk_texture_get_format() was the only reason for it.
2023-02-15 00:39:18 +01:00
Sebastian Dröge
a252aadadf gsk: Move new 4.10 GskRenderNodeTypes to the end instead of inserting them in the middle 2023-02-14 21:04:41 +02:00
Kjell Ahlstedt
869ab1cd1b gskglrenderjob: Fix compilation with clang 2023-02-14 10:29:25 +01:00
Matthias Clasen
d3dfdd214f gl: Avoid a crash in the texture library
entry->texture can be NULL, so check before
using it.

Fixes: #5175
2023-02-12 10:01:11 -05:00
Matthias Clasen
b6c3cf4eee gl: Maintain state when truncating
When we truncate the command queue because it
is too big, we were messing up our state accounting
and running into criticals as a consequence.

This can be reproduced by opening a well-populated
fishbowl demo in the inspectors recorder.

Fixes: #5188
2023-02-12 09:56:32 -05:00
Matthias Clasen
a9f50f1f7a gl: Support mask nodes
Add a shader for masking.
2023-02-12 08:35:25 -05:00
Matthias Clasen
0d58e5365d gsk: Introduce mask nodes
Add GskMaskNode, and support it in the render node
parser, in the inspector and in GtkSnapshot.

The rendering is just fallback for now.

Based on old work by Timm Bäder.
2023-02-12 08:35:25 -05:00