Commit Graph

240 Commits

Author SHA1 Message Date
Benjamin Otte
c322ab34c7 rendernode: Use cairo_set_device_offset()
Simplifies the code.
2023-06-05 05:33:07 +02:00
Benjamin Otte
8d528350b9 rendernode: clip when drawing shadows
Ensures the shadow stays small.
2023-05-16 18:53:27 +02:00
Benjamin Otte
e4040adbe7 rendernode: Implement texture diffing for scale nodes 2023-05-02 00:30:58 +02:00
Benjamin Otte
1883035d34 texture: Add gdk_texture_diff()
... and use it in rendernodes.

Setting up textures for diffing is done via gdk_texture_set_diff() which
should only be used during texture construction.

Note that the pointers to next/previous are allowed to dangle if one of
the textures is finalized, but that's fine because we always check both
textures' links to each other before we consider the pointer valid.
2023-05-01 22:24:14 +02:00
Benjamin Otte
3198330188 rendernode: Add diffing for affine transforms
This will be needed most importantly for inverted textures,
like in GLArea.
2023-04-29 05:10:51 +02:00
Matthias Clasen
74c0171edf gsk: Don't misuse bitwise operators
We should use && for booleans, not &=.
2023-04-25 16:43:02 +02:00
Matthias Clasen
2263db6259 gsk: Don't misuse bitwise operators
We should use || for booleans, not |=.
2023-04-25 13:45:37 +02:00
Benjamin Otte
4d86954fb5 rendernode: Cosmetics
Simplify a function.
2023-04-03 19:27:58 +02:00
Benjamin Otte
6e8c3fc3ff rendernode: Get rid of GskRenderNodeTypeInfo
Instead, use class_init functions.
2023-04-03 19:27:58 +02:00
Benjamin Otte
0d139a81c7 rendernode: Remove instance_init() function
It's not used.
2023-04-03 19:27:58 +02: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
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
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
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
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
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
b937c19dd4 gsk: Introduce GskTextureScaleNode 2023-02-11 15:09:38 -05:00
Matthias Clasen
c0b5b4b8c1 gskrendernodeimpl.c: Use folding
Instead of homegrown markup.
2023-02-11 09:00:07 -05:00
Carlos Garnacho
b9448b06b4 gsk: Extend the blur radius for outset shadow extents
By dividing the blur radius to obtain the clip radius, we may end up
with halved values that result in an overshunk clip mask. Extend this
so that we ensure to cover the last pixel.

Fixes artifacts seen with the cairo renderer in X11 when resizing
windows horizontally, a black 1px high line would be seen in the
top of the window due to these outset bounds being used in clipping.

More mysteriously, also seems to fix resize lag in the GL renderer
(also X11), if e.g. the bottom-right corner of a window is resized
diagonally in bottom-left -> top-right direction, or
bottom-right -> top-left.

Related: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175#note_1599335
2022-11-23 19:27:49 +01:00
Carlos Garnacho
35744d87a2 gsk: Also ceil() top side when converting graphene to cairo rectangles
The outset border for all sides is ceil()ed, except for the top side.
Most often values are already nicely rounded here, but this seems an
oversight.
2022-11-23 18:56:45 +01:00
Matthias Clasen
ce57150203 gsk: Add an assertion to help static analysis
clang gets wild ideas about negative radii otherwise.
2022-11-18 00:04:23 -05:00
Matthias Clasen
b12d31d189 Fix spelling errors
These were pointed out by codespell.
2022-11-17 22:49:45 -05:00
Matthias Clasen
a8af7caae1 Rename gdk-private.h to gdkprivate.h
The extra - does not add any value.
2022-09-23 23:23:27 -04:00
Matthias Clasen
9818ec4ad9 gsk: Use the new debug macros 2022-09-23 18:11:48 -04:00
Sebastian Dröge
0cc2d5559b Mark gsk_rounded_clip_node_new() return value as (transfer full)
Like all the other constructors for nodes already do. Without this,
newly created rounded clip nodes are leaked in bindings.
2022-08-10 11:07:51 +03:00
Matthias Clasen
38eb182947 gsk: Collect opacity information
Collect information about whether to use offscreens
for opacity during node construction, so we don't
need to walk the tree repeatedly, later.
2022-04-05 14:57:38 -04:00
Matthias Clasen
0eba21b2b5 gsk: Track disjointness of container nodes
This can be used to optimize some things in the
GL renderer.
2022-04-05 14:57:38 -04:00
Matthias Clasen
bf852bea24 Fix up preconditions of gsk_gl_shader_node_new
These were not quite right, and implied that args
may be NULL, when it really can't.

Fixes: #4739
2022-03-03 22:40:10 -07:00
Benjamin Otte
20dcc31d19 rendernode: Limit diff region
Limit the diff region to 30 rectangles (randomly chosen because it
looked big enough to not trigger by accident and small enough to not
cause performance issues).

If the diff region gets more complicated, we abort to the parent node
and use its bounds as the diff region instead and then continue diffing
the rest of the node tree.

Fixes: #4560
Fixes: #2396
2021-12-20 18:40:02 +01:00
Benjamin Otte
4e6ee28bcb gsk: Allow diffing code to abort
Now the vfuncs can decide they don't want to diff anymore, not just the
actual diff function.
2021-12-20 17:08:15 +01:00
Benjamin Otte
291c50202a rendernode: Simplify conic gradient code 2021-11-30 14:12:10 +01:00
Bilal Elmoussaoui
40c08954db g-i: add missing since annotations 2021-11-13 17:50:53 +01:00
Timm Bäder
085f0171c1 Ensure blur nodes have a positive blur radius 2021-10-17 12:15:34 +02:00
Matthias Clasen
2a08641f59 gsk: Add high depth rendernode api
Add private api to find out if the content
of a render node should be considered 'deep'.

The information is collected at creation time,
so there is no tree-walking involved when we
are using this information in the renderer.

Currently, this comes down to whether there are
any texture nodes with high depth textures in the subtree.
In the future, we may want to allow marking gradient
nodes in this way as well.
2021-10-06 21:35:25 -04:00
Matthias Clasen
7e4b2b971f Revert "gsk: Stop enlarging text bounding boxes"
This reverts commit 87af45403a.

I've found that this change is needed to ensure that the
bounding boxes of text nodes encompass all the glyphd drawing.
Without it, we overdraw the widget boundaries and cut off
glyphs.
2021-09-17 19:11:06 -04:00
Matthias Clasen
87af45403a gsk: Stop enlarging text bounding boxes
This should not be necessary and only serves
to make the actual bugs harder to find.
2021-09-17 12:37:36 -04:00
Benjamin Otte
9f2b847835 rendernode: Write the whole node
It turns out g_output_stream_write_bytes() does not write the bytes.
It should be renamed to g_output_stream_write_some_of_the_bytes() maybe.
2021-09-11 22:28:40 +02:00
Matthias Clasen
65ce3eb207 Avoid hand-rolled color glyph information
Followup to b244f31337. Pango provides color glyph
information for us now, so we don't need to steal a
bit anymore.
2021-09-05 10:58:50 -04:00
Matthias Clasen
ce2b2128bb Revert "gsk: Add font options to text nodes"
This reverts commit f1347f5841.
2021-09-04 15:42:05 -04:00
Matthias Clasen
f1347f5841 gsk: Add font options to text nodes
Since font options affect how the glyphs get rendered,
we need to pass the font options down from the gtk level
to where the glyph cache is populated.

Add a new gsk_text_node_new_full api that takes a
cairo_font_options_t in addition to the other parameters.
2021-09-03 12:43:35 -04:00
Matthias Clasen
b244f31337 Use color glyph information from Pango
Pango now sets a bit in PangoGlyphVisAttr for
color glyphs, so we don't need to do that
ourselves anymore.
2021-09-01 01:47:06 -04:00
Benjamin Otte
0b7a36ce33 rendernode: Add (de)serialization support for render nodes
This includes our own new mime type for render nodes, too.
2021-08-30 06:02:15 +02:00
Matthias Clasen
916886312a Merge branch 'wip/exalm/shadow-extents' into 'master'
Shrink shadow extents

See merge request GNOME/gtk!3825
2021-08-05 16:39:52 +00:00
Alexander Mikhaylenko
46a9538b6a Shrink shadow extents
Long time ago, Cairo shadows in both GTK3 and 4 were drawn at a size about
twice their radius. Eventually this was fixed but the shadow extents are
still calculated for the previous size and appear unreasonably large: for
example, 141px for a 50px radius shadow. This can get very noticeable in
places such as invisible window frame which gets included into screenshots.

https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/3419 just divides the
radius by 2 when drawing a shadow with Cairo, do the same when calculating
extents.

See https://gitlab.gnome.org/GNOME/gtk/-/issues/3841
2021-08-04 14:47:17 +05:00
Matthias Clasen
915c229396 gsk: Use harfbuzz for color fonts
harfbuzz has all the information we need, so we
can avoid poking directly at freetype apis. Also
drop the caching of color glyph information until
it turns out to be a problem.
2021-07-31 16:34:38 -04:00