Commit Graph

147 Commits

Author SHA1 Message Date
Timm Bäder
45455f1bdb Remove GtkCssShadowsValue
Previously, we wrapped all GtkCssShadowValues in a GtkCssShadowsValue,
even if it was just one shadow. This causes an unnecessary bloat in
css values.

Make each GtkCssShadowValue able to handle multiple shadows instead, and
use gtk_css_shadow_value* API everywhere.
2020-01-18 08:49:52 +01:00
Timm Bäder
67991ed0f4 Remove GtkCssRgbaValue
The differenciation between a literal color value and an RGBA value
caused problems in various situations. Just treat the two the same but
don't allow access to the rgba value of a non-literal color value.

This gets rid of around 1.6k rgba values in the widget-factory.
2020-01-18 08:49:51 +01:00
Timm Bäder
21a7dfae96 snapshot: Only normalize rectangle if we have to
We can even replace the comment this way.
2020-01-07 17:27:18 +01:00
Timm Bäder
4788f88840 snapshot: Repeat color nodes by creating a larger color node 2020-01-07 17:27:17 +01:00
Timm Bäder
05e9a9b572 snapshot: Reorder color matrix nodes containing a transform node
A color matrix node that contains a transform node can also be expressed
the other way around, as a transform node containing a color matrix
node.

In the general case, the color matrix node will have to draw its
child to a texture so it can color every pixel of that texture, but the
renderers can short-cut this if the child of the color matrix node is
already a texture node. So if we have a node tree like

Color Matrix
    - Transform
        - Texture

The renderer would have to either check the grandchild of the color
matrix or simply fall back to rendering the transform node to a texture.

In the new configuration:

Transform
    - Color Matrix
        - Texture

The renderer can easily see that the child node of the color matrix node
is a texture, and skip rendering it to a texture.

This is for example happening in current Adwaita for spinners, which are
rotated symbolics.
2019-12-03 08:40:34 +01:00
Timm Bäder
bc7b37d307 snapshot: Factor out color matrix merging
We will use that elsewhere in the next commit.
2019-12-03 08:40:34 +01:00
Timm Bäder
f4f060c843 snapshot: Don't move shadows too much
dx/dy are relative to the node bounds, which are already moved by x/y.
2019-10-11 13:47:40 +02:00
Timm Bäder
78a376aa7f snapshot: Try to avoid some linear gradient nodes 2019-09-25 17:51:52 +02:00
Timm Bäder
ffab342fc4 snapshot: Stop exporting _append_node_internal
Unused outside of gtksnapshot.c
2019-09-09 17:36:23 +02:00
Timm Bäder
a93745238f snapshot: Annotate child_bounds parameter of push_repeat as nullable 2019-08-10 19:51:45 +02:00
Timm Bäder
ac333d712d snapshot: Make append_node_internal transfer-full
There is only one case where we do *not* directly unref the node again
after calling this.
2019-06-04 16:48:08 +02:00
Benjamin Otte
a1d08b4b52 rendernode: Take a graphene_point_t for the offset
... instead of 2 floats.
2019-05-21 06:43:59 +02:00
Matthias Clasen
ed52c029a0 gtk: Small documentation fixes 2019-05-01 23:24:14 -04:00
Benjamin Otte
3a3b325f8e transform: Add perspective()
This commit adds gsk_transform_perspective(), gtk_snapshot_perspective()
and support for perspective() in the CSS syntax.
2019-03-05 20:46:00 +01:00
Benjamin Otte
bd113aa85c transform: Redo querying API
Make the API expect a tranform of the proper category instead of
doing the check ourselves and returning TRUE/FALSE.

The benefit is that the mai use case is switch (transform->category)
statements and in those we know the category and don't need to check
TRUE/FALSE.

Using the wrong matrix will now cause a g_warning().
2019-03-04 23:41:51 +01:00
Benjamin Otte
b391aea2b3 widget: Make transform a GskTransform
This concludes pushing transforms down into GskTransform.

What's remaining is potentially pushing it further into the renderers.
2019-03-04 23:41:51 +01: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
0e1a50366a transform: Move to GSK
The renaming of the prefix makes this a large patch.
2019-03-04 23:09:02 +01:00
Matthias Clasen
d3c45cb979 docs: Miscellaneous doc fixes
Additions and correction all over the place,
in GDK and GTK docs.
2019-02-24 16:53:12 -05:00
Benjamin Otte
4052bb2535 snapshot: Remove the old APIs
It's all using transforms now.
2019-02-21 19:47:28 +01:00
Benjamin Otte
51fac44ba5 snapshot: Introduce transform APIs
Instead of gtk_snapshot_offset(), provide a full set of functions
kept in sync with GtkTransform APIs.

On top of that, add gtk_snapshot_save() and gtk_snapshot_restore()
mirroring cairo_save()/restore() that allow saving a snapshot's
transform state.
2019-02-21 19:47:28 +01:00
Benjamin Otte
2bdc0748e5 snapshot: Remove gtk_snapshot_get_offset()
We use append() functions for everything now, thank you very much.
2019-02-21 19:47:28 +01:00
Benjamin Otte
1ef250f44a snapshot: Add functions to append shadows 2019-02-21 19:47:28 +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
e1570e9ebc snapshot: Add gtk_snapshot_append_border()
This is adding functions for the remaining render nodes.
2019-02-21 19:47:28 +01:00
Benjamin Otte
4a293aa762 snapshot: Store an actual GtkTransform
Instead of just tracking 2 integer translate_x/y coordinates, tracka a
full GtkTransform.

When creating actual nodes, if the transform is simple enough, just
create the node in a way that makes use of the transform. If the
node, can't represent the transform, just push a transform node instead
and automatically pop that node with the next gtk_snapshot_pop() call.
2019-02-21 19:47:28 +01:00
Benjamin Otte
f0142b9c4b snapshot: Remove dead code
Seems to be leftovers from way too long ago.
2019-02-21 19:47:28 +01:00
Benjamin Otte
6a4bf2b993 gsk: Remove offset nodes
They were a neat idea while they lasted. But now, it's time for
categorized transform nodes, where matrices with
GSK_MATRIX_CATEGORY_2D_TRANSLATE are the exact replacement.

Renderers have not been adapted for this purpose, so they (continue to)
run slow paths.
2019-02-21 19:47:28 +01:00
Benjamin Otte
f5b44c11c8 widget: Store category of widget transform
And pass that category through to the transform node that we create for
it.
2019-02-21 19:47:28 +01:00
Benjamin Otte
c44c44ee25 css: Pass boxes to the render functions
Instead of style + rect_of_one_box, pass the new GtkCssBoxes object.
This has the nice side effect that when drawing background + border +
outline, we only compute all the boxes we need once.
2019-02-15 06:53:22 +01:00
Timm Bäder
cf1526cca6 snapshot: Add gtk_snapshot_from_parent
Most of the time, the GtkSnapshot objects we create while snapshotting
widgets don't end up containing all that many nodes or states in their
respective node or state stack. This undermines the amortized allocation
behavior of the G(Ptr)Array we use for the stacks. So instead, use the
(until now unused) parent_snapshot GtkSnapshot* passed to
gtk_widget_create_render_node and reuse its node and state stack.

We do not avoid allocating a new GtkSnapshot object, but we do avoid
allocating a ton of G(Ptr)Array objects and we also avoid realloc'ing
their storage.
2019-01-16 19:01:40 +01:00
Timm Bäder
f4f0f0e6a0 snapshot: Get new GArray item directly
Instead of building it up ourselves, then coping it into the GArray and
then getting the last element of that array.
2019-01-11 17:02:23 +01:00
Timm Bäder
9959ea98cd Revert "snapshot: merge container nodes"
This reverts commit 622a150bb4.
2018-07-08 21:50:59 +02:00
Benjamin Otte
0b1f0984f5 Revert "Use aligned allocators for GtkSnapshot"
This reverts commit c02bc22cc5.

This code is not necessary.
The bug causing this problem ws prsent in the graphene library.
2018-06-19 19:52:52 +02:00
Benjamin Otte
8c8dc3aeab snapshot: Compute correct size in gtk_snapshot_to_paintable()
Also, do actually respect the passed in size argument if it isn't NULL.

Fixes text being cut off inside DND icons.
2018-06-19 19:44:17 +02:00
Руслан Ижбулатов
c02bc22cc5 Use aligned allocators for GtkSnapshot
Any data that is later fed to graphene must be
allocated with proper alignment, if graphene
uses SSE2 or GCC vector instructions.

This adds custom array code (a streamlined copy
of GArray with all unnecessary bells and whistles removed),
which is then used for the state_stack instead of GArray.

There's also a runtime check for the size of GtkSnapshotState
itself being a multiple of 16. If that is not so, any array
elements past the 0th element will lose alignment.
There are probably struct attributes that can
make GtkSnapshotState always have size that is a multiple
of 16, but we'll burn that bridge if we cross it.
2018-06-10 20:35:54 +00:00
Mohammed Sadiq
14e5218753 snapshot: Fix typo in documentation comment 2018-05-12 09:31:32 +05:30
Matthias Clasen
f5a2ab38f3 Miscellaneous docs improvements
Just the usual pre-release doc fixups.
2018-05-07 07:47:18 -04:00
Timm Bäder
622a150bb4 snapshot: merge container nodes
A container node inside another container node doesn't make a lot of
sense, we can instead just use the parent container node and add the
child container node's children to it directly.
2018-05-02 19:48:34 +02:00
Rico Tzschichholz
2cf55c1686 Fix some g-i annotation warnings 2018-05-01 12:35:32 +02:00
Benjamin Otte
1e0eed79b5 snapshot: Get rid of record_nodes flag
Instead, use GTK_DEBUG=snapshot for it.
2018-04-24 04:06:58 +02:00
Benjamin Otte
73b4a62f51 snapshot: Redo debug messages
Instead of every snapshot function having debug messages, have an
explicit gtk_snapshot_push_debug() function that appends a debug node.
2018-04-24 04:06:58 +02:00
Timm Bäder
840504b60a snapshot: Fix some documentation problems 2018-04-21 10:06:57 +02:00
Benjamin Otte
2db43edbd6 snapshot: Don't handle clip anymore
If widgets want to clip things, they now need to do it themselves.

By not taking care of clip, we avoid the need to track clip. And by not
tracking clip, we can avoid all unnecessary cache invalidations that we
were doing for render nodes whenever the clip changed.

And when you are scrolling, the clip changes *a lot*.
2018-04-17 23:21:37 +02:00
Timm Bäder
c18219c5a8 snapshot: don't create offset nodes inside offset nodes
It's pretty easy to make that one offset node.
2018-04-14 11:47:02 +02:00
Benjamin Otte
47ea3a9452 snapshot: Don't cause invalid reads
1. Pass clip rectangles to gtk_snapshot_push_state() that point into
   the state array.
2. g_array_set_size(len+1) the state array
3. Make that function realloc() the state array.
4. The clip rectangle now points into invalid memory
5. Use the clip array

This patch fixes things by moving step 5 to before step 2.
2018-04-05 18:41:34 +02:00
Benjamin Otte
ffc7b2bb0a snapshot: Allow passing the bounds of the created paintable
This allows being more specific about the size.
It's useful in particular when the resulting render nodes might be
too small for the size, not only when they are too large. For the
latter case, using a clip node would be enough.

It also requires adding a clip node when rendering the resulting
paintable, but that should be optimized out by GtkSnapshot when not
necessary.
2018-04-05 14:56:39 +02:00
Benjamin Otte
4bf90633ea widget: Cache clip from creating render node
When the clip changes that is passed to a snapshot function, we need to
create eventual cached render nodes because they might not have drawn
their whole area before.

Fixes issues with redrawing when scrolling.
2018-04-05 14:56:38 +02:00
Benjamin Otte
278ab3c4de snapshot: Track clip as a rect only 2018-04-05 14:56:38 +02:00