Commit Graph

2930 Commits

Author SHA1 Message Date
Benjamin Otte
d7308f2d73 gsk: Rename GSK_DEBUG=glyphcache to GSK_DEBUG=cache
1. I mistype it all the time
2. It's shorter
3. We use it for all caching these days, not just glyphs.
2024-07-07 05:24:45 +02:00
Benjamin Otte
012c4b9425 gpu: Remove the ubershader
It didn't bring any noticable benefits and it isn't compatible with the
way we intend to do colorstate support.

And nobody seems to want to spend time on it, so let's get rid of it.

We can bring it back later if someone wants to work on it.
2024-07-07 05:19:32 +02:00
Benjamin Otte
16c2e0a642 gl: Use GdkTextureDownloader
Cairo surfaces are so outdated.
2024-07-05 13:55:18 +02:00
Benjamin Otte
32625381fa gsk: Deprecate GskGLShader and the rendernode
The new renderers don't support them due to the required complexity of
integrating them with Vulkan and the assumptions those nodes make about
the renderer (the GL renderer exports its internal APIs into the
GLShader).

There haven't been any complaints that I'm aware of since 4.14 was
released where the default renderer does not support the nodes, so usage
in public seems to be close to nonexistant.

The 2 uses I know of were workarounds about missing features in GTK that
have stopped since GTK now supports them:

1. GStreamer used in to do premultiplication when the old GL renderer
   did not do so in hardware but on the CPU.
2. Adwaita used it for masking before the mask node wa added in 4.10.
2024-07-04 21:28:06 +02:00
Benjamin Otte
0f55b3bc18 Merge branch 'wip/otte/for-main' into 'main'
gpu: Split out the cache

See merge request GNOME/gtk!7411
2024-07-03 19:51:10 +00:00
Benjamin Otte
9c249fefc3 gpu: Improve periodic cache debug message
I was watching the log in my terminal and nothing happened.
And I wasn't sure if that was because nothing was printed or because the
same thing was printed every few seconds.

Fix that by printing a timestamp, so that in a few seconds something
else will be printed.
2024-07-03 20:36:56 +02:00
Benjamin Otte
eae7ee6c25 gpu: Track atlas differently
Previously we tracked the dead pixels, but that meant we didn't know the
alive pixels (because there's also unused pixels never accounted for).
And we would free the current atlas randomly due to that.

Now we track if any pixels are alive, and if so, we never gc the current
atlas.
2024-07-03 20:36:56 +02:00
Benjamin Otte
bf7f302ff5 gpu: gc atlas, too
After 60s, we gc the atlas, too. This ensures that after that time, we
free all cache resources, so if an application gets moved to the
background, it will no longer use GPU resources. (Well, at least the
cache won't.)
2024-07-03 19:55:18 +02:00
Benjamin Otte
0d6981bd54 gpu: Make the cache track if it's empty
Only if a non-stale item is in the cache do we consider the cache not
empty.

Once the cache is empty, the device frees it and stops running the
periodic GC.
2024-07-03 19:55:18 +02:00
Benjamin Otte
148d7bcc25 gpu: Don't remove gc timeout unless cache is empty
If the cache isn't empty, we want to rerun the GC.
2024-07-03 19:55:18 +02:00
Benjamin Otte
71161b6352 gpu: Split cache and device
This is for 3 reasons:

1. Separation of concerns
   The device is meant to manage the Vulkan/GL device and check stuff
   like image sizes.
   Caching is not part of that.

2. Refcounting
   Images etc want to reference the device, but the cache wants to
   reference images. If the cache is the device, that's a refcycle.

3. Flexibility
   It's now easier to implement >1 cache, say one per depth or one per
   color state.
2024-07-03 19:55:15 +02:00
Benjamin Otte
dd33a2f280 rendernode: Make sure depth variable has enough bits
This will be relevant when we add new values to it.
2024-07-03 19:55:15 +02:00
Emmanuele Bassi
554045de6e Use the appropriate annotations for a callback closure
The (closure) annotation with an parameter is meant to be used on the
callback argument, and point to the user data argument.
2024-07-03 17:21:04 +01:00
Matthias Clasen
f9856d547f gsk: Avoid a crash
The subsurface in subsurface nodes can be NULL, so check before
poking at it.
2024-07-02 15:52:51 -04:00
Benjamin Otte
9f7254a2d0 gl: Fix wrong drawing of mask node corner case
An empty mask with inverted-alpha means the source is visible.
2024-07-02 02:04:06 +02:00
Benjamin Otte
43c2b53811 rendernode: Remove default empty draw function
No node ever wants to draw nothing. So make sure code crashes if the
draw func is not set instead of silently drawing nothing.
2024-07-01 20:30:25 +02:00
Benjamin Otte
33d87bc22e gdk: Add GDK_N_DEPTHS to the enum
We are indexing arrays by the number of depths, and when adding depths
we don't want to forget to grow those arrays.
2024-07-01 20:07:22 +02:00
Maximiliano Sandoval
9126bf2c9d
docs: gsk: Add docstring for BroadwayRenderer 2024-06-29 15:14:33 +02:00
Maximiliano Sandoval
c73ff197e0
gsk: meson: Document renderers
These contain docstrings.
2024-06-29 15:14:32 +02:00
Benjamin Otte
72a4fae8dc vulkan: More slight refactoring
This applies the same refactoring as commit
5fbdec2a29 to another function.
2024-06-29 07:13:27 -04:00
Matthias Clasen
36c7d05445 gpu: Keep actual clear values in clear op
Keeping the GdkRGBA requires doing later conversions, which isn't
necessary if we just keep the already converted float[4].

It also prepares for future color states, where the color will need to
be converted using the colorstate.
2024-06-29 07:12:28 -04:00
Matthias Clasen
f3d5683f67 rendernode: Fix container nodes preferred depth
The current code injects an implicit GDK_MEMORY_U8 into this.
It is harmless now, but may not be in future. So avoid it.
2024-06-29 07:12:10 -04:00
Benjamin Otte
120887979d rendernode: Set proper values for fill and stroke nodes
Fill and stroke nodes were not reporting proper offscreen-for-opacity
and preferred depth.

This was unlikely to have been noticed as their child is usually a solid
color.
2024-06-29 07:12:10 -04:00
Matthias Clasen
51012c1802 ngl: Export dmabuf textures from render_texture
We want dmabufs because we can import them into Vulkan, amongst
other things.
2024-06-22 08:02:31 -04:00
Matthias Clasen
6f5c610858 gsk: Give up automatic font subsetting
Despite my best effort, it seems impossible to make ci and local
builds agree on what font subsetter and fonts to use, so make this
opt-in for now: If you want to produce a node file with embedded
fonts, set GSK_SUBSET_FONTS=1.
2024-06-21 18:45:32 -04:00
Matthias Clasen
b1a840bec0 Try to avoid aliasing with system fonts
The rendernode parser creates its own fontmap for the fonts that
we deserialize from blobs. But we were using the system fontconfig
configuration for it, leading to system fonts still being found.
This is bad, and causes test failures in ci. Try with an empty
fontconfig configuration instead.
2024-06-21 18:17:11 -04:00
Benjamin Otte
5fbdec2a29 vulkan: Slight refactoring for future changes
No functional changes.
2024-06-21 19:53:46 +02:00
Matthias Clasen
d1d4d80a1d Simply some internal api
The only caller of gdk_memory_texture_from_texture doesn't use
the second argument.
2024-06-19 02:06:14 -04:00
Matthias Clasen
a63a201812 Fix a crash in rendernode serialization
This snuck in with a6ffd6b3b2.
2024-06-17 22:09:30 -04:00
Matthias Clasen
f09caced9b Drop debug spew 2024-06-17 21:44:33 -04:00
Matthias Clasen
36993ac707 gpu: Print some more details
Print the variations of mask and blendmode operations.
Just because we can.
2024-06-15 14:00:46 -04:00
Matthias Clasen
34fb08af6e Fix a copy-paste error
This was obviously meant to compare two different colors.
2024-06-14 12:30:06 -04:00
Matthias Clasen
0ec29c4176 gsk: Pass the memory format for back buffer
We can now get this information from the Vulkan context,
so use it to accurately represent the back buffer.

Related: #6767
2024-06-09 15:59:56 -04:00
Matthias Clasen
18b3b4feed gpu: Print more info for images
Show the memory format.

This helps debugging our depth selection.
2024-06-09 15:59:32 -04:00
Matthijs Velsink
721be8fe9f gsktransform: Document consuming functions
Since GskTransform is immutable, a lot of the documented "methods" are
more like "functions", in the sense that they don't keep the instance
alive but rather consume it.

This is annotated with `(transfer full)`, but since these functions are
listed as methods, their first argument is not shown.

Instead, let's add a line to the docs of each consuming function that
clarifies this behavior.
2024-06-05 15:59:49 +02:00
Matthias Clasen
bf1a434d5c Merge branch 'font-subsetting-in-node-files' into 'main'
Use font subsetting in serialized nodes

See merge request GNOME/gtk!7227
2024-06-03 12:47:59 +00:00
Matthias Clasen
9256b5b552 rendernode tool: Add an extract command
This lets one extract the data urls from a node file.
2024-06-03 08:28:21 -04:00
Matthias Clasen
577e4afb3c Improve font deserialization
Even if we disable font fallback, after adding Cantarell Regular
to the custom fontmap, fontconfig will helpfully synthesize
Cantarell Bold for us. So, just don't check for the font at all.
If there is a url, add it to the fontmap and leave it up to the
serializing code to ensure that we don't end up with duplicate
fonts.
2024-06-03 07:45:57 -04:00
Matthias Clasen
2a05c04db7 Use the hb face as key when tracking fonts
The hb face is is a wrapper around the font file, which is what
we need to track here, since we want to subset and serialize each
used font file exactly once.
2024-06-03 07:44:16 -04:00
Matthias Clasen
a6ffd6b3b2 nodeparser: Subset fonts
When serializing nodes, collect the glyphs that are used from
each font, subset the font to that set of glyphs, and embed it
into the node file. We are careful to preserve the glyph IDs,
so our text nodes transparently work with the subsettted fonts.
2024-06-03 07:38:51 -04:00
Matthias Clasen
5ffa2b757c Merge branch 'less-vulkan' into 'main'
Don't use Vulkan without dmabufs

See merge request GNOME/gtk!7220
2024-06-02 23:58:24 +00:00
Matthias Clasen
cfcc5c5c0b Merge branch 'docs-add-missing-returns-args' into 'main'
docs: Add missing returns and parameter annotations

See merge request GNOME/gtk!7325
2024-06-02 15:26:50 +00:00
Maximiliano Sandoval
0bacde8e0a
gskpathbuilder: Document add_cairo_path path arg 2024-06-01 10:01:19 +02:00
Maximiliano Sandoval
949cd45bb7
gskstroke: Add missing return annotations 2024-06-01 10:01:19 +02:00
Maximiliano Sandoval
a931335f24
gskglshader: Correct typo in source property 2024-06-01 09:04:00 +02:00
Maximiliano Sandoval
1ef320a9ec
gsktransform: Document constructor 2024-06-01 09:04:00 +02:00
Matthias Clasen
4961241f26 gsk: Use gdk_rgba_print when suitable 2024-05-31 21:39:04 -04:00
Matthias Clasen
90e1ce0906 Merge branch 'new-docstrings' into 'main'
Add missing docstrings

See merge request GNOME/gtk!7321
2024-05-31 19:57:53 +00:00
Maximiliano Sandoval
3d1f914271
gskglrenderer: Document GL renderers 2024-05-31 11:47:30 +02:00
Maximiliano Sandoval
7bb0639a75
gskrendernode: Document serialization error quark 2024-05-31 11:47:29 +02:00