Commit Graph

2422 Commits

Author SHA1 Message Date
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
Matthias Clasen
2bfd4a88d6 Fix some more static analysis warnings 2023-11-24 16:36:46 -05:00
Matthias Clasen
36314f28e2 gsk: Some more rect inlining 2023-11-24 10:35:57 -05:00
Matthias Clasen
b7a1b1d7ee Fix some static analysis warnings 2023-11-24 10:35:57 -05:00
Matthias Clasen
a90a6c4517 Address various static analysis complaints
These were picked out of the scan_build logs in ci.
2023-11-22 00:07:47 -05:00
Matthias Clasen
160fa969d4 subsurface: Replace place_above/below
Instead, do it all in attach(), which becomes more and more like
ConfigureWindow. This is good, because it will let us take the
above-ness into account when making decisions about attaching.
2023-11-21 13:24:04 -05:00
Matthias Clasen
fb969f5431 offload: Raise all subsurfaces that can be
If two subsurfaces don't overlap and aren't otherwise obstructed,
we can just raise them  both.

Tests included.
2023-11-18 08:19:43 -05:00
Matthias Clasen
ef6ed31853 offload: Drop unused api 2023-11-18 08:19:43 -05:00
Matthias Clasen
c57245b73c diff: Take above-ness into account
We need to include the full area if a subsurface
above-ness changes, since we only punch holes if
it is above.

Fixes: #6214
2023-11-18 08:19:43 -05:00
Matthias Clasen
f9fd78b67e offload: Keep was-raised for each subsurface
We need this information for proper diffing.
2023-11-18 08:19:43 -05:00
Benjamin Otte
1b08fda93e renderer: Remove offload argument from render()
It turns out it's not needed, because all relevant information for
subsurfaces is already available by querying the subsurface itself.
2023-11-14 21:54:35 +01:00
Benjamin Otte
f6b6176ec0 gl: Handle subsurfaces without GskOffload 2023-11-14 21:51:07 +01:00
Benjamin Otte
ef77a6fa73 gl: Don't punch hole if the subsurface is above
Saves some work.
2023-11-14 20:22:24 +01:00
Benjamin Otte
653bf46494 offload: Refactor texture finding
It's the same code, but with way more debose debug messages.
2023-11-14 15:04:38 +01:00
Benjamin Otte
4920ac4a57 offload: Move a debug message
If we fail to attach a buffer, we don't want to print this.
2023-11-14 15:04:38 +01:00