Commit Graph

2436 Commits

Author SHA1 Message Date
Benjamin Otte
96a71d515b gl: Track if mipmap generation is allowed
... and if it isn't, switch to a format that does allow mipmaps.
2024-01-03 16:56:43 +01:00
Benjamin Otte
b830ca8fab gl: Pass correct format/type to function
Instead of querying the format again and potentially coming out with a
different format, use the one we queried in the calling function.
2024-01-03 16:56:31 +01:00
Matthias Clasen
c56360f20b Merge branch 'matthiasc/for-main' into 'main'
gsk: Mark some subsurface node apis as skip

See merge request GNOME/gtk!6702
2024-01-03 14:09:38 +00:00
Matthias Clasen
726d5b25e8 Merge branch 'bilelmoussaoui/add-missing-annotations' into 'main'
gi: Add missing Since annotations

See merge request GNOME/gtk!6701
2024-01-03 13:35:44 +00:00
Matthias Clasen
681aac7317 gsk: Mark some subsurface node apis as skip
These are not usable outside of GTK, so lets not burden bindings
with them.

I'll keep the get_child() function exposed, since it is needed to
iterate over node trees containing subsurface nodes.
2024-01-03 07:53:27 -05:00
Bilal Elmoussaoui
2cd550cdbc gi: Add missing Since annotations 2024-01-03 08:49:39 +01:00
Benjamin Otte
63615c05bc rendernode: Allocate right amount of memory
asan randomly failed when this almost correct code wasn't quite correct.

Hopefully this is the correct incantation to compute the size.

Related: glib#205
2024-01-03 05:01:08 +01:00
Benjamin Otte
cdf5d08294 rendernode: Fix a memleak 2024-01-03 04:58:08 +01:00
Benjamin Otte
7742434dde rendernode: Allow drawing oversized textures
Create surfaces for tiles of the image and then combine those tiles.

Use an offscreen and OPERATOR_ADD to avoid seams.
2024-01-03 04:11:35 +01:00
Benjamin Otte
09882701c2 rendernode: Fix various places where clip was double applied
This is mostly untested and a result of reading the code.

The main effect here happens when a node was drawn that didn't start on
an integer boundary, which is very rare.
However, with specially crafted tests and when using fractional scaling,
this can happen.

This happened most often when clipping by the node bounds to restrict a
push_group() call. Enlarge that rectangle to fall on a pixel boundary.
2024-01-03 04:11:35 +01:00
Benjamin Otte
a19bc6620a rendernode: Apply the same radius for begin and end
Somebody fixed the end() call but not the begin() call when the too
large blur radius was fixed.
2024-01-03 04:11:35 +01:00
Benjamin Otte
da5de1ba99 nodeparser: Fix SEGV in shadows parsing code
Testcase included

The code was writing invalid memory, so this might not have always
crashed, but I did my best to write the test so it causes a SEGV.

Also included is a fix for the testsuite where the expected result was
wrong.
2024-01-03 04:11:35 +01:00
Benjamin Otte
28b552ad8c rendernode: Remove unnecessary save/restore 2023-12-28 07:35:47 +01:00
Benjamin Otte
c7b4347342 roundedrect: Fix an intersection cornercase
These 2 rectangles used to intersect fine:
  0 0 50 50 / 50 0
  0 0 50 50 / 0 50
But the computed result was:
  0 0 50 50 / 50
which is not a valid rectangle, because the corners overlap.

Make sure such rectangles return NOT_REPRESENTABLE.

The above rectangle has been added to the testsuite.
2023-12-28 07:35:46 +01:00
Benjamin Otte
ed8bca1548 path: Make gsk_path_to_string() work in non-US locales 2023-12-28 07:35:46 +01:00
Benjamin Otte
0c3c8a6a85 stroke: Turn stroke copy intialization into a macro
That way I can use it in static initializers.
2023-12-28 07:35:46 +01:00
Matthias Clasen
ea5768cb42 Merge branch 'wip/otte/for-main' into 'main'
rendernode: Use different hilights

See merge request GNOME/gtk!6694
2023-12-27 22:15:05 +00:00
Matthias Clasen
906b88067a Merge branch 'matthiasc/for-main' into 'main'
Add a few annotations

See merge request GNOME/gtk!6695
2023-12-27 12:34:50 +00:00
Matthias Clasen
062902c003 Add a few annotations
Add a few pure, const and malloc annotations. These were suggested
by the gcc -Wsuggest-attribute option.
2023-12-26 21:57:04 -05:00
Matthias Clasen
6d57bbe7dd Fix a typo 2023-12-26 21:54:48 -05:00
Benjamin Otte
af014007f4 gl: Remove old Cairo fallback drawing code
We use gsk_render_node_draw_fallback() now which does all of that for
us.
2023-12-26 17:28:08 +01:00
Benjamin Otte
3f97ba2041 gsk: Clarify debug category messages a bit
After discussion on IRC about debug messages:

 - FALLBACK is meant to be used for printing stuff about fallbacks
   (Cairo, offscreens, conversion when uploading, etc)
 - CAIRO is for overdrawing everything drawn with Cairo
2023-12-26 17:28:08 +01:00
Benjamin Otte
4ce08a7b89 rendernode: Use different hilights
When hilighting Cairo nodes, use a different hilight color than when
hilighting other nodes.

This allows differentiating application use of Cairo (via nodes) from
renderer use of Cairo (via fallback).
2023-12-26 17:28:08 +01:00
Benjamin Otte
914e9bc316 Merge branch 'wip/otte/lots-of-tests' into 'main'
Lots of rendering tests and fixes

See merge request GNOME/gtk!6692
2023-12-26 15:22:35 +00:00
Benjamin Otte
1385ffd2c2 gsk: Repurpose GSK_DEBUG=cairo
Use it to overlay an error pattern over all Cairo drawing done by
renderers.

This has 2 purposes:
1. It allows detecting fallbacks in GPU renderers.
2. Application code can use it to detect where it is using Cairo
   drawing.

As such, it is meant to trigger both with cairo nodes as well as when
renderers fallback for regular nodes.

The old use of the debug flag - which were 2 not very useful print
statements - was removed.
2023-12-26 05:31:05 +01:00
Benjamin Otte
57a4500bae rendernode: Don't mark impure functions as pure
Functions with out arguments can never be pure, because they write to a
pointer.

But pure functions must have no side effects.
2023-12-26 05:03:24 +01:00
Benjamin Otte
b01ed4ce39 rendernode: Set better size for mask nodes
Mask nodes are transparent outside of the intersection of source and
mask, unless the mask ode is inverted alpha.

Set the bounds accordingly.

Tests have been updated accordingly.
2023-12-26 05:03:24 +01:00
Benjamin Otte
6ab6109149 rendernode: Redo repeat handling
The previous approach could lead to offscreens that were too large and
cause errors.
2023-12-25 19:12:57 +01:00
Maximiliano Sandoval R.
e857f0a3af Add Since annotations to enums
Doing this in a way that is picked up by gobject-introspection
requires splitting off new enum members into separate doc
comments, which is a bit unfortunate.
2023-12-22 08:47:47 -05:00
Benjamin Otte
d2a85abf79 Merge branch 'wip/otte/dmabuf-refactoring' into 'main'
dmabuf refactoring

See merge request GNOME/gtk!6678
2023-12-20 10:25:29 +00:00
Benjamin Otte
74620ffc46 dmabufdownloader: Add a close() function
We need to unrealize renderers before unreffing them. This vfunc takes
care of that.
2023-12-20 10:59:25 +01:00
Benjamin Otte
ce04dfad41 renderer: Move function into only caller
The convert_texture() path only works for the GL renderer, the new
renderers potentially use dmabuf textures as result of render_texture(),
so they need to be smarter here.
2023-12-20 10:59:25 +01:00
Benjamin Otte
568eed9477 dmabuf: Turn the downloader into an interface
This way, we can move the actual downloader code into GSK - by just
implementing the interface in the GskGLRenderer.
2023-12-20 10:59:25 +01:00
Matthias Clasen
9166e90bd4 Merge branch 'gles-glyph-upload' into 'main'
gsk: Fix icon and glyph upload with GLES

Closes #6216

See merge request GNOME/gtk!6674
2023-12-18 12:34:58 +00:00
Matthias Clasen
6ad15fe6d0 gsk: Fix icon and glyph upload with GLES
We can't avoid a copy here, unfortunately.

Fixes: #6216
2023-12-17 21:53:10 -05:00
Matthias Clasen
79009d4158 gsk: Handle straight-alpha dmabufs
This omission was noticed by Benjamin Otte. Add a premultiply
uniform to the external shader, and add a separate premultiply
shader for the non-external case.
2023-12-15 07:40:27 -05:00
Benjamin Otte
4dfc07ef57 memoryformat: Fix variable types
Use the same types that GL uses.
2023-12-12 01:49:41 +01:00
Benjamin Otte
cf4b0a27f8 glcontext: Only swizzle when we can
Don't use the recently added swizzle optimization if we're using a GL
version that is too old to support swizzling (GLES 2).
2023-12-12 01:49:41 +01:00
Benjamin Otte
393ee574b6 gl: Print debug for CPU conversions of textures
When the GL renderer cannot upload a given format, print a FALLBACK
debug message with the failed format and the alternative that was
picked, for example:

Unsupported format b8g8r8a8, converting on CPU to b8g8r8a8-premultiplied

Makes it easier to figure out what's happening, especially when using
old GLES versions that don't support all formats.
2023-12-12 01:49:41 +01:00
Benjamin Otte
e3c85be53f memoryformat: Add gdk_memory_format_get_fallbacks()
Track fallback formats to use in the memoryformat directly instead of
using in the GL uploading code.

First of all, this allows sharing the code and ensuring all our
renderers use the same fallback mechanism.

But also, this allows tracking fallbacks per-format which is useful
because the fallback formats aren't really a tree. We want to make
FLOAT16 fall back to FLOAT32 when not available, but we also want
FLOAT32 fall back to FLOAT16.
By tracking the fallbacks per-format, we can achieve that.
2023-12-12 01:49:40 +01:00
Benjamin Otte
0f5fda2277 memoryformat: Introduce new (private) API
Add gdk_memory_format_get_premultiplied() and
gdk_memory_format_get_straight() which return the matching
premultiplied/straight format.

Use this to pick the premultiplied format when uploading GL textures.

And remove the duplication in the dmabuf code, where we can now use
these functions instead of tracking both the premultiplied and straight
alpha versions.
2023-12-12 01:49:40 +01:00
Benjamin Otte
5688b7b4bb gl: Add a new alternative format
Add an "RGBA" format that just maps to the swizzled version of the
default format.

This way, BGR gets mapped to RGB + swizzling first before trying to map
it to the default format for the depth.

The benefit here is that this format has the same memory width, so
uploading/downloading code can treat it equivalent to the original
format and there's no conversion neccessary later.
2023-12-12 01:49:40 +01:00
Benjamin Otte
3a1349e8ef gl: Make gdk_memory_format_gl_format() no longer check support
Now that we have gdk_gl_context_get_memory_flags() and code can use that
function, make the code do that.

Remove support checks from gdk_memory_format_gl_format().

This is an initial naive port that doesn't try to make use of the finer-grained
flags yet.
2023-12-11 07:33:26 +01:00
Benjamin Otte
c341da32aa gsk: Set correct blur radius for cairo shadows 2023-12-11 07:33:26 +01:00
Benjamin Otte
d39ec8c09e gsk: Quality of life improvements for Cairo rendering
1. Check for an empty clip region before push/pop_group() calls

2. Remove save/restore() pairs as the vfunc invocation does so already.
2023-12-11 07:33:26 +01:00
Benjamin Otte
e3299e38df cairo: Handle clipped blur content
This is the result of experimenting with corner cases when blurring.

The result is a test that tests when the child of a blur node is
clipped out but the blurred child is not, the blurred parts are still
visible.

This immediately broke the cairo renderer, so the fix is included.
2023-12-11 07:33:24 +01:00
Matthias Clasen
00ebd51d06 gsk: Be more careful about texture slice formats
We need to make sure that all our textures have the same memory
format, or we'll run into trouble in the upload code, at least
on GLES, which isn't as forgiving about format mismatches.

Related: #6238
2023-11-28 14:16:21 -05:00
Matthias Clasen
108eb43b01 gsk: Add some more proiler marks
These should help us determine if time is spent converting or
uploading textures.
2023-11-27 17:50:28 -05:00
Maximiliano Sandoval R.
71c2ee3530
gskenums: Add Since to missing enum values
Use same Since annotation as elsewhere
2023-11-25 15:01:53 +01:00
Maximiliano Sandoval R.
5e415ee916
gskenums: Don't break the docstring 2023-11-25 15:00:40 +01:00