Commit Graph

114 Commits

Author SHA1 Message Date
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
Benjamin Otte
e3a717363b snapshot: Remove clip argument from gtk_snapshot_new()
It's not used anymore. And anybody who wants to have a clip on a
newly created snapshot can achieve that using gtk_snapshot_push_clip().
2018-04-05 14:56:38 +02:00
Benjamin Otte
29111a16d4 widget: Cache the render node
This requires a bunch of refactorings:

1. Don't pass the current clip region to gtk_widget_snapshot()
   so we don't create full widget contents
3. Have a widget->priv->draw_needed that we invalidate on every
   queue_draw() call and set on every snapshot()
2. In queue_draw(), walk the widget chain to invalidate the
   render nodes of all parents
2018-04-05 14:56:38 +02:00
Rico Tzschichholz
f2937f8c45 Fix some g-i annotation warnings 2018-04-01 09:15:08 +02:00
Timm Bäder
d9136fb944 snapshot: Plug memory leak when collecting rounded clip nodes 2018-03-31 14:45:03 +02:00
Benjamin Otte
f494d6ae1f snapshot: Generate better names for offset nodes 2018-03-26 19:43:06 +02:00
Benjamin Otte
7fdcc58532 snapshot: Add gtk_snapshot_to_paintable()
This is intended for DND icons
2018-03-26 18:16:36 +02:00
Benjamin Otte
9b83116fcb snapshot: Export gtk_snapshot_append_layout()
This is the equivalent snapshot function to pango_cairo_show_layout().

Not to be confused with gtk_snapshot_render_layout(), which is the
equivalent to gtk_render_layout().
2018-03-26 18:16:36 +02:00
Benjamin Otte
e6d24f4c15 snapshot: Make gtk_snapshot_append_node() take care of offset
Push an offset node when append_node is called. That resets the offset.
2018-03-26 18:16:36 +02:00
Benjamin Otte
1cfa88ed91 snapshot: Remove renderer
Now that there's no longer a need to keep the renderer around for Cairo
rendering, don't do that then.
2018-03-24 21:57:20 +01:00
Benjamin Otte
e84c6acc4f rendernode: Remove renderer argument
It's not needed to create Cairo nodes anymore.
2018-03-24 21:57:20 +01:00
Timm Bäder
3f367277fe snapshot: Limit cairo nodes to clip region
In certain cases, we might create large cairo nodes, resulting in
surfaces so large, cairo can't handle them. Fix this by limiting the
cairo node to the current clip region.
2018-03-20 09:40:10 +01:00
Benjamin Otte
ea84e974e6 snapshot: Turn into GObject
This makes GdkSnapshot the base class for GtkSnapshot and hopefully
stops confusing bindings.

C code should see no difference to before.
2018-03-18 19:21:33 +01:00
Timm Bäder
a25dcd0f74 snapshot: Fix some indentation 2018-03-17 14:13:42 +01:00
Timm Bäder
5f2283c0ab snapshot: Ignore 0 sized clip nodes
This may happen due to the intersection before.
2018-03-14 17:28:41 +01:00
Timm Bäder
417e8d6ca4 snapshot: Add missing (nullable) annotation 2018-03-13 23:43:29 +01:00
Matthias Clasen
7c18911c00 GtkSnapshot: Add getters
These getters can be useful when creating new snapshots
in a snapshot() vfunc.
2018-03-11 00:31:44 -05:00
Matthias Clasen
890cd45ce4 Document new snapshot api 2018-03-11 00:31:44 -05:00
Matthias Clasen
eed279ad91 GtkSnapshot: Drop init/finish
We are ont using stack-allocated snapshots anymore.
2018-03-11 00:31:44 -05:00
Matthias Clasen
e23f641e49 GtkSnapshot: Implement the builder pattern
Make GtkSnapshot a refcounted boxed type, and add
public API that follows the builder pattern described
here: https://blogs.gnome.org/otte/2018/02/03/builders/
2018-03-11 00:31:44 -05:00
Matthias Clasen
4c150d8eb5 The big versioning cleanup
Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
2018-02-06 01:16:32 -05:00
Timm Bäder
a61eecc22e snapshot: Don't create clip nodes with 0 width or height 2017-12-28 16:48:35 +01:00
Timm Bäder
19871cfd68 snapshot: Add & use API for linear gradient nodes
This way, we can also clip the created node bounds to the current clip
of the GtkSnapshot. This works as long as we don't modify the start and
end points, and happens all the time while rendering.
2017-12-21 18:25:52 +01:00
Timm Bäder
d9f1620b2f snapshot: Directly clip color nodes
Clipping a color node is trivial so we do it here directly since that
might later save the entire clip node as well as freeing the fragment
shaders from coloring lots of pixels that will be clipped away.
2017-12-21 18:25:52 +01:00
Timm Bäder
8107b1a2dd snapshot: Fix typo 2017-12-21 18:25:51 +01:00
Timm Bäder
329683f746 snapshot: Don't create blur nodes with radius 0 2017-12-09 13:14:51 +01:00
Timm Bäder
f6f1dfb55d snapshot: Collapse color matrix nodes
Color matrix nodes as the child of other color matrix nodes can happen
quite frequently as a result of CSS. To ease the renderer
implementations, collapse chains of color matrix nodes into one.
2017-12-09 13:14:44 +01:00
Alexander Larsson
478b1d56f8 Revert "gtksnapshot: Merge trivial clip duplicates"
This reverts commit d95cbb2757.

This is better solved by commit 94184eda42
2017-12-01 09:08:57 +01:00
Timm Bäder
c42e026058 snapashot: Optimize rounded clip nodes
If the rounded clip node is rectilinear, we can simplify it to a normal
clip node. If not, we really need to use a rounded clip node. In both
cases, we can do the same check we do when collecting normal clips and
avoid the clip node altogether if the child node does not get clipped
anyway.

This saves between 3 and 10 nodes in the widget factory, depending on
what page gets rendered.
2017-12-01 08:14:01 +01:00
Timm Bäder
94184eda42 snapshot: Only create clip nodes if we need to
Clip nodes have a clip rect and we only need to actually create a clip
node if any child node gets clipped at all. If the clip rect conains the
child node bounds entirely, we don't need a clip node.
2017-12-01 07:38:43 +01:00
Alexander Larsson
d95cbb2757 gtksnapshot: Merge trivial clip duplicates
I got a lot of "clip in clip" cases, for example a CellClip with a
CellTextClip inside. It is really trivial to merge these when we
pop and makes it easier for all backends, so lets do that.
2017-11-30 21:57:42 +01:00
Matthias Clasen
7b032a9862 Drop gtk_snapshot_render_icon
Its not used, and we are working towards removing
GdkPixbuf in the API.
2017-11-29 18:34:45 -05:00
Matthias Clasen
2aa52c7d00 Simplify the gtk_snapshot_icon_texture API
Instead of passing the color matrix in from the outside,
just pass a boolean and set up the matrix internally.
2017-11-08 22:21:42 -05:00
Emmanuele Bassi
481b5d1b89 Partially revert GskTexture → GdkTexture rename
Excessive use of sed when moving GskTexture to GDK; the GskTextureNode
should still live under the GSK namespace.
2017-11-04 15:06:00 +00:00