Commit Graph

63 Commits

Author SHA1 Message Date
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
8f47e885f0 Add gtk_snapshot_push_mask 2023-02-12 08:35:25 -05:00
Matthias Clasen
67c53e46f9 Add gtk_snapshot_append_scaled_texture
This is the snapshot api corresponding to
gsk_texture_scale_node_new.
2023-02-11 15:09:38 -05:00
Matthias Clasen
60dafebd91 Deprecate gtk_snapshot_render apis
Move the implementations from gtksnapshot.c to
gtk/deprecated/gtkrender.c and deprecated these
functions. We want to get rid of them.

These functions are still used in some of our widgetry,
so use G_GNUC_BEGIN/END_IGNORE_DEPRECATIONS around
them.
2022-10-12 15:35:00 -04:00
Benjamin Otte
8706d69e60 snapshot: Add gsk_snapshot_append_conic_gradient() 2020-12-03 01:15:53 +01:00
Alexander Larsson
950cc41e15 GtkSnapshot: Add gtk_snapshot_push_glshader() 2020-09-29 09:51:16 +02:00
Matthias Clasen
c08df82d54 snapshot: switch to h/vradius 2020-09-18 15:39:07 +02:00
Matthias Clasen
66d16049c3 snapshot: Add api for radial gradients
These are the equivalents of the linear gradient apis.
2020-09-18 15:39:04 +02:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02: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
0e1a50366a transform: Move to GSK
The renaming of the prefix makes this a large patch.
2019-03-04 23:09:02 +01: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
e1570e9ebc snapshot: Add gtk_snapshot_append_border()
This is adding functions for the remaining render nodes.
2019-02-21 19:47:28 +01:00
Timm Bäder
662e2b1641 snapshot: Remove superfluous typedef
We're already doing this in gtktypes.h

Fixes #214
2018-05-19 10:18:50 +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
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
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
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
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
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
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
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
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
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
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
Benjamin Otte
ca3c23662c GskTexture => GdkTexture
We want this thing to replace GdkPixbuf, so it has to live in GDK.
2017-11-04 00:07:13 +01:00
Matthias Clasen
d6be42203b Add gtk_snapshot_push_blur()
This function is similar to the other push functions.
This one uses the newly created blur node.
2017-09-04 14:28:16 -04:00
Benjamin Otte
87497ca2e1 snapshot: Rename gtk_snapshot_translate_2d()
It's now called gtk_snapshot_offset().
2017-01-13 14:37:48 +01:00
Benjamin Otte
6055028c96 snapshot: Rename append APIs
Instead of having gtk_snapshot_append_foo_node(), just have
gtk_snapshot_append_foo(). Nobody needs to know that this internally
uses nodes.
2017-01-13 04:46:09 +01:00
Benjamin Otte
b58de2d16c snapshot: Redo pop() API
gtk_snapshot_pop() => removed
gtk_snapshot_pop_and_append() => gtk_snapshot_pop()

So now there is no way to get a rendernode out of the snapshotting API
until you gtk_snapshot_finish().
2017-01-13 03:38:36 +01:00
Benjamin Otte
bc3ba68641 snapshot: Add gtk_snapshot_push_blend()
and use it for backgrounds.
2017-01-13 03:38:36 +01:00
Benjamin Otte
d9b0685b49 Add gtk_snapshot_push_cross_fade()
... and use it.

The function is a bit awkward because it requires 2 calls to
gtk_snapshot_pop(), but once you accept that, it's very convenient to
use, as can be seen by the 2 implementations.
2017-01-13 03:38:36 +01:00
Alexander Larsson
c00f8dce9f GtkSnapshot: Always use int for the translation
We already take ints when setting the translation, so it can't
currently take any other values. Additionally, I was seeing large
costs in int -> double -> int for the rects in
gtk_snapshot_clips_rect(), as all callers really are ints (widget
allocations) and the clip region is int-based.

This change completely cleared a 2% rectangle_init_from_graphene from
the profile and is likely to have nice performance effects elsewhere
too.
2017-01-11 16:14:03 +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
8973191278 snapshot: Add gtk_snapshot_push_color_matrix()
So far, this is unused.
2016-12-31 02:49:47 +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
9822fe81a3 snapshot: Implement gtk_snapshot_push_opacity()
Use it in GtkWidget's opacity handling.
2016-12-20 18:01:11 +01:00
Benjamin Otte
23e35706b4 gsk: Add support for rounded clip rectangles
Also add support to GtkSnapshot, so people can push rounded clips.
2016-12-20 18:01:10 +01:00
Benjamin Otte
1137483d15 snapshot: Work on pushing and popping again
It is now possible to call push() subfunctions for simple container
nodes with just a single child. So you can for example
gtk_snapshot_push_clip() a clip region that all the nodes that get
appended later will then obey.

gtk_snapshot_pop() will then not return a container node, but a clip
node containing the container node (and similar for the transform
example).

This is implemented internally by providing a "collect function" when
pushing that is called when popping to collects all the accumulated
nodes and combine them into the single node that gets returned.

To simplify things even more, gtk_snapshot_pop_and_append() has been
added, which pops the currently pushed node and appends it to the
parent.

The icon rendering code has been converted to this approach.
2016-12-20 18:01:10 +01:00
Benjamin Otte
c258ee403a snapshot: Make gtk_snapshot_get_renderer() private
Public API doesn't need to be concerned with renderers. Worst case, they
can use NULL instead of the actual renderer.
2016-12-20 18:01:10 +01:00
Benjamin Otte
b120075698 snapshot: Add API for colors and textures 2016-12-20 18:01:10 +01:00
Benjamin Otte
02131d590e snapshot: Change how gtk_snapshot_push/pop works
Instead of appending a container node and adding the nodes to it as they
come in, we now collect the nodes until gtk_snapshot_pop() is called and
then hand them out in a container node.

The caller of gtk_snapshot_push() is then responsible for doing whatever
he wants with the created node.

Another addigion is the keep_coordinates flag to gtk_snapshot_push()
which allows callers to keep the current offset and clip region or
discard it. Discarding is useful when doing transforms, keeping it is
useful when inserting effect nodes (like the ones I'm about to add).
2016-12-20 18:01:10 +01:00
Benjamin Otte
67fb129ed7 gsk: gsk_render_node_set_transform() => GskTransformNode
Instead of having a setter for the transform, have a GskTransformNode.

Most of the oprations that GTK does do not require a transform, so it
doesn't make sense to have it as a primary attribute.

Also, changing the transform requires updating the uniforms of the GL
renderer, so we're happy if we can avoid that.
2016-12-20 18:01:10 +01:00