Commit Graph

91 Commits

Author SHA1 Message Date
Sebastian Dröge
a252aadadf gsk: Move new 4.10 GskRenderNodeTypes to the end instead of inserting them in the middle 2023-02-14 21:04:41 +02: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
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
b695ef9168 gsk: Add a shortcut for a common transform case
Add a private getter for the translation part of a
transform node, to avoid pulling it out of the transform
over and over.
2021-07-24 18:48:09 -04:00
Matthias Clasen
7fb1389648 gsk: Add a private getter for container children
No need to get them one-by-one, in our inner loop.
2021-07-24 18:48:09 -04:00
Matthias Clasen
2d266d107b gsk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04:00
Matthias Clasen
2d5dd7b3d7 gsk: Make rendernode diffing smarter
Allow comparing container nodes to any other
node, by pretending the other node is a single
child container (if it isn't one already).

This fixes a glitch where we redraw the full
entry text when the blinking cursor goes to
opacity 0, since GskSnapshot then optimizes
away first the opacity node, and then the
single-child container.
2021-03-28 10:26:06 -04:00
Matthias Clasen
bf59ddd01d gsk: Add gsk_border_node_get_uniform_color
Maintain this bit of information separately,
it will be useful in the next commit.
2021-03-09 12:15:25 -05:00
Christian Hergert
161ddcfa92 gsk: make render node getters const
This also removes the return if fail macros from these as a good portion
of them didn't have them anyway. I think it's fair to say that access to
these incorrectly is a programmer error.

It significantly reduces the amount of code generated into generally a
movss,ret.
2021-02-08 11:29:36 -08:00
Matthias Clasen
9cec9e4ce2 gsk: Export the glyph serialization privately
We want to use the same serialization in the inspector,
so export this function.
2020-12-21 13:11:08 -05:00
Alexander Larsson
7ea755e206 Add GskGLShaderNode and GskGLShader
A GskGLShader is an abstraction of a GLSL fragment shader that
can produce pixel values given inputs:
 * N (currently max 4) textures
 * Current arguments for the shader uniform
Uniform types are: float,(u)int,bool,vec234)
There is also a builder for the uniform arguments which are
passed around as immutable GBytes in the built form.

A GskGLShaderNode is a render node that renders a GskGLShader inside a
specified rectangular bounds. It renders its child nodes as textures
and passes those as texture arguments to the shader. You also pass it
a uniform arguments object.
2020-09-29 09:51:16 +02:00
Timm Bäder
2fa9dddea6 gsk: Remember border node uniformity
Lots of border nodes have all the same width and the same color.
Renderers might be able to simplifty that, so keep an extra bit per
border node.
2020-07-28 05:34:11 +02:00
Emmanuele Bassi
e0323fcdc2 Add get_type() functions for GskRenderNode subclasses
The introspection scanner tries to match a type name with a get_type()
function, in order to correctly identify a type as a class.

If the function is not available, we have two choices:

 - add some special case inside the introspection scanner, similar to
   how GParamSpec subclasses are handled in GObject
 - add a simple get_type() function

The latter is the simplest approach, and we don't need to change that
much, since we still register all render nodes at once.
2020-04-08 16:07:04 +01:00
Emmanuele Bassi
d701a89281 Turn GskRenderNode into a derivable type
Language bindings—especially ones based on introspection—cannot deal
with custom type hiearchies. Luckily for us, GType has a derivable type
with low overhead: GTypeInstance.

By turning GskRenderNode into a GTypeInstance, and creating derived
types for each class of node, we can provide an introspectable API to
our non-C API consumers, with no functional change to the C API itself.
2020-04-08 15:40:15 +01:00
Timm Bäder
77e0d360ed Add pure and const annotations to various functions 2020-01-26 18:21:07 +01:00
Matthias Clasen
1038bc781a Revert "Cache glyph textures in render nodes"
This reverts commit c5af463843.
2019-10-22 07:16:41 -04:00
Matthias Clasen
d3431f569c Revert "inspector: Fix node recording"
This reverts commit ba7649b388.
2019-10-22 01:32:51 -04:00
Matthias Clasen
ba7649b388 inspector: Fix node recording
When attaching renderer-specific data, we need to
make sure that we key it off the renderer that is
in use, and cope with the absence of render data.

This fixes recording nodes in the inspector.
2019-10-18 09:33:45 -05:00
Matthias Clasen
c5af463843 Cache glyph textures in render nodes
This is a quick implementation that avoids many
glyph cache lookups. We keep an array of direct
pointers in the text render node, and throw those
cached pointers away whenever any atlases have
been dropped (since that may invalidate the cached
glyphs).
2019-10-15 19:44:26 -04:00
Benjamin Otte
fda643952d rendernode: Remove unused function 2019-05-25 23:50:46 +02:00
Timm Bäder
fb63364f30 rendernode: Remove old GVariant (de)serialization code
We're doing the CSS thing now.
2019-05-05 07:18:39 +02:00
Benjamin Otte
3cc84d2860 transform: Make category public API
Also rename it from GskMatrixCategory to GskTransformCategory.
2019-03-04 23:15:24 +01:00
Benjamin Otte
3a3c2d14ab rendernode: Make the transform node take a GskTransform
This is an attempt to push GskTransform deeper into the stack.
2019-03-04 23:15:07 +01:00
Benjamin Otte
0d119f81c8 snapshot: Refactor text rendering
The code didn't change, it was just shuffled around to make the
with_bounds() versions of the text rendering unnecessary and instead
pass through the generic append_node() path.
2019-02-21 19:47:28 +01:00
Benjamin Otte
70a1233a28 gsk: Add GskMatrixCategory
We'll use that soon.
2019-02-21 19:47:27 +01:00
Benjamin Otte
b49dccb86d rendernode: Remove gsk_render_node_set_name()
And of course, gsk_render_node_get_name() is gone, too.
The replacement is of course debug nodes.

As a side effect, GskRenderNode is now *really* immutable.
2018-04-24 04:06:58 +02:00
Timm Bäder
4f3c7cd48a gsk: Make gsk_text_node_new_with_bounds private
We pulled out the bounds calculation for performance reasons, but the
caller can't know how to properly compute them. Inside gtk+, we can do
that but it's not good enough for public API.
2018-04-21 11:20:15 +02:00
Benjamin Otte
271820b677 rendernode: Add gsk_render_node_diff()
... and gsk_render_node_can_diff(). Those are vfuncs to compute a region
containing all the pixels that differ between the two nodes.

This is just the plumbing that chains into node classes. No node
implements it yet.
2018-04-05 14:56:38 +02:00
Benjamin Otte
52b1cd40d1 gsk: Remove gsk_render_node_set_scaling_filters()
This is a leftover from the very early rendernode that we forgot to delete.

This can be seen by the fact that it is settable on an immutable object.
2017-12-03 21:57:21 +01:00
Matthias Clasen
243bd4f0c8 gsk: Tweak cairo node apis
Rename the surface getter to peek, following other render
node getters, and make the surface-based constructor private,
since it is not something we want to encourage.

Update all callers.
2017-10-20 13:54:01 +02:00
Matthias Clasen
eee89587c3 Make render node getter public
Keeping these private does not really buy us anything.
2017-10-20 13:54:01 +02:00
Umang Jain
a933c7c4bd gsk: Move gsk_cairo_node_new_for_surface into public API
https://bugzilla.gnome.org/show_bug.cgi?id=788534
2017-10-08 18:22:34 +05:30
Matthias Clasen
e45ab76664 gsk: remove gsk_blend_node_get_blend_mode from public api
We don't have any other such getters in the public api at
this point, so leave this one out as well.
2017-09-28 19:39:16 -04:00
Matthias Clasen
b0e8d8483d More work on text nodes
This commit takes several steps towards rendering text
like we want to.

The creation of the cairo surface and texture is moved
to the backend (in GskVulkanRenderer). We add a mask
shader that is used in the next text pipeline to use
the texture as a mask, like cairo_mask_surface does.
There is a separate color text pipeline that uses the
already existing blend shaders to use the texture as
a source, like cairo_paint does.

The text node api is simplified to have just a single
offset, which determines the left end of the text baseline,
like all our other text drawing APIs.
2017-09-10 14:36:26 -04:00
Matthias Clasen
e2869853dc gsk: Add a blur node
For now, this has just a fallback implementation using
the typical box filter approximation.
2017-09-04 14:28:16 -04:00
Benjamin Otte
84c1204853 rendernode: Add getters for box-shadow nodes 2017-01-18 04:13:56 +01:00
Benjamin Otte
b186bce7ff vulkan: Add shader for border rendering 2017-01-11 18:33:09 +01:00
Benjamin Otte
b993acfe2c gsk: Add GskRepeatNode
Also add gtk_snapshot_push_repeat() and use that to draw backgrounds.

With that change, CSS background snapshots are created without Cairo
nodes.
2017-01-01 19:53:36 +01:00
Benjamin Otte
7540702cf0 gsk: Add GskColorMatrixNode
This node essentially implements the feColorMatrix SVG filter. I got the
idea yesterday after looking at the opacity implementation.

It can be used for opacity (not sure if we want to) and to implement a
bunch of the CSS filters.
2016-12-31 02:49:47 +01:00
Benjamin Otte
af917c4ade vulkan: Handle linear gradients
Note: We interpolate premultiplied colors as per the CSS spec. This i
different from Cairo, which interpolates unpremultiplied.

So in testcases with translucent gradients, it's actually Cairo that is
wrong.
2016-12-26 17:22:02 +01:00
Benjamin Otte
4bb0c70c11 gsk: Add docs and error handling to serialization API 2016-12-23 08:11:01 +01:00
Benjamin Otte
735846cc82 gsk: Export gsk_render_node_get_bounds()
I'll need it in tests/testsuite soon.
2016-12-23 08:11:00 +01:00
Benjamin Otte
c88d279416 gsk: Add gsk_render_node_serialize/deserialize()
This does a conversion to/from GBytes and is intended for writing tests.

It's really crude but it works.
And that probably means Alex will (ab)use it for broadway.
2016-12-23 08:11:00 +01:00
Alexander Larsson
230d27b079 GskRenderNode: Use C99 flexible arrays to avoid extra allocation
Instead of a separate allocation for any arrays in the render node
we allocate these as part of the render node itself, using C99
flexible arrays.

This leads to less allocations, which is nice, but the major reason
for this is that it allows us to change the allocation scheme further
in the future. For instance, we want to do stack-like allocation so
that all the render-nodes for an entire frame are allocated in one
(or a few) chunks.
2016-12-21 14:01:34 +01:00
Alexander Larsson
22110ef5a4 gsk: Add bounds member to RenderNode
Instead of constantly recalculating this (especially recursively for
parents!) we do it only on construction, because everything is
immutable anyway. Also, most nodes had a bounds already and can
use the new parent member instead.

We also do direct access to the node bounds rather than calling
gsk_render_node_get_bounds in various places, which means
we do less copying.
2016-12-21 14:01:34 +01:00
Alexander Larsson
2d4b46f4f9 gsk: Drop gsk_render_node_make_immutable, nodes are always immutable 2016-12-21 14:01:34 +01:00
Benjamin Otte
2480e0d575 gsk: Add GskShadowNode
... and make the icon rendering code use it.

This requires moving even more shadow renering code into GSK, but so be
it. At least the "shadows not implemented" warning is now gone!
2016-12-20 18:01:12 +01:00
Benjamin Otte
75b76af221 gsk: Add GskBorderNode
The node draws a solid CSS border, which can be used to cover everything
but dashed and dotted borders (double, groove, inset, ...).

For different border styles, we overlay multiple nodes and set their
colors to transparent for sides with non-matching styles.
2016-12-20 18:01:11 +01:00
Benjamin Otte
30438c6e8b gsk: Add cross-fade node
And implement stack crossfades with it.
2016-12-20 18:01:11 +01:00