Commit Graph

157 Commits

Author SHA1 Message Date
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Timm Bäder
720c298786 snapshot: Use collect_default directoy in push_debug()
Instead of going through collect_debug and then doing a collect_default
anyway if the message is NULL.
2020-07-17 05:49:12 +02:00
Benjamin Otte
6f8e9bf3a9 snapshot: Use GdkArray for the state stack 2020-07-16 18:09:58 +02:00
Benjamin Otte
65359dcc59 snapshot: Port node list to GdkArray 2020-07-16 18:09:57 +02:00
Benjamin Otte
ac8b398c50 snapshot: Move structs into .c file
They aren't used anywhere else.
2020-07-16 18:09:57 +02:00
Corentin Noël
076b2f11d2 docs: Fix several missing references in the documentation
This fixes several typos and missing references
2020-05-11 19:26:20 +02:00
Timm Bäder
f4acde371e snapshot: Avoid a save/restore pair if we can 2020-04-17 15:21:00 +02:00
Emmanuele Bassi
59852d3425 Add missing transfer annotation 2020-04-08 15:40:15 +01:00
Timm Bäder
4cfac3b91c snapshot: Remove new_with_parent
Unneeded now that we have push_collect()/pop_collect()
2020-02-07 13:16:32 -05:00
Timm Bäder
bf8fb2c1a5 snapshot: Add _push_collect() and _pop_collect()
These will replace the previous gtk_snapshot_new_with_parent(), which
allocated an entirely new GObject just to push()/pop() some state. This
is already a problem but will be more important in the future as we
start using this more.
2020-02-07 13:16:32 -05:00
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