Commit Graph

686 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
0f02040292 gsk: Cache scaled texture
Keep the texture we create for texture scale nodes.

Fixes: #5642
2023-03-10 21:09:27 +01: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
Matthias Clasen
0b4d41698b mask: Fix glsl 2023-02-17 06:26:42 -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
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
Matthias Clasen
d916659781 gl: Handle GskTextureScaleNodes 2023-02-11 15:09:38 -05:00
Matthias Clasen
82c02574f1 gl: Make texture slicing more flexible
Allow to specify the filtering to use for the slices,
and allow forcing the number of slices. This will be
used in the next commit.
2023-02-11 15:09:38 -05:00
Matthias Clasen
26e6d2106b gl: Pass filters down from visit_texture_node
For now, we always pass GL_LINEAR.
2023-02-11 15:09:38 -05:00
Matthias Clasen
b937c19dd4 gsk: Introduce GskTextureScaleNode 2023-02-11 15:09:38 -05:00
Matthias Clasen
cc43f5dcde gsk: Generate mipmaps when requested
If the min_filter requires it, call
glGenerateMipmap for our textures.
2023-02-11 09:29:03 -05:00
Matthias Clasen
c74d7afce5 gsk: Don't limit filters too much
GL does not allow mipmapping for mag filters,
but it doesn't have a problem with it for min
filters.
2023-02-11 09:29:03 -05:00
Matthias Clasen
1da4782262 gsk: Fix a compiler warning 2023-02-02 17:15:28 +01:00
Matthias Clasen
c43e1f3d0a gsk: Quiet a compiler warning 2023-01-28 21:13:10 -05:00
Christian Hergert
fb12ad807a gsk/gl: fix warning when join_sources() is unused 2023-01-12 13:22:25 -08:00
Matthias Clasen
b441c684ab gsk: Avoid a crash with negative scales
Don't crash when both scale_x and scale_y are -1.

A test is included.
2022-11-20 12:13:02 -05:00
Matthias Clasen
b12d31d189 Fix spelling errors
These were pointed out by codespell.
2022-11-17 22:49:45 -05:00
Matthias Clasen
4aabc45685 Drop gdkintl.h
This header was merely including gi18n-lib.h.
Just do that directly.
2022-09-23 23:33:42 -04:00
Matthias Clasen
9818ec4ad9 gsk: Use the new debug macros 2022-09-23 18:11:48 -04:00
Matthias Clasen
511a4ec475 gsk: Make glyph upload more similar to icons
When uploading glyphs to the atlas, clear
the padding bytes so that no dirt remains there.
2022-09-10 15:25:59 -04:00