Compare commits

...

1 Commits

Author SHA1 Message Date
Matthias Clasen
86a88f8869 gsk: Deprecate cairo render nodes
This is part of the ongoing preparation for shedding cairo in our
apis in the next major version of GTK.
2024-01-07 21:26:09 -05:00
18 changed files with 52 additions and 9 deletions

View File

@@ -65,8 +65,10 @@ plane_snapshot (GtkWidget *widget,
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height));
G_GNUC_END_IGNORE_DEPRECATIONS
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_rectangle (cr, 0, 0, width, height);

View File

@@ -131,7 +131,9 @@ drawing_area_snapshot (GtkWidget *widget,
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height));
G_GNUC_END_IGNORE_DEPRECATIONS
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);

View File

@@ -61,10 +61,12 @@ gtk_nuclear_snapshot (GtkSnapshot *snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height));
size = MIN (width, height);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT ((width - size) / 2.0,
(height - size) / 2.0,
size, size));
G_GNUC_END_IGNORE_DEPRECATIONS
gdk_cairo_set_source_rgba (cr, foreground);
cairo_translate (cr, width / 2.0, height / 2.0);
cairo_scale (cr, size, size);

View File

@@ -590,6 +590,7 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
}
return;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
case GSK_CAIRO_NODE:
if (add_new_node (renderer, node, BROADWAY_NODE_TEXTURE, clip_bounds))
{
@@ -625,6 +626,7 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
cairo_surface_destroy (image_surface);
}
return;
G_GNUC_END_IGNORE_DEPRECATIONS
case GSK_COLOR_NODE:
if (add_new_node (renderer, node, BROADWAY_NODE_COLOR, clip_bounds))

View File

@@ -381,11 +381,11 @@ float gsk_outset_shadow_node_get_blur_radius (const GskRender
GDK_AVAILABLE_IN_ALL
GType gsk_cairo_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_14
GskRenderNode * gsk_cairo_node_new (const graphene_rect_t *bounds);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_14
cairo_t * gsk_cairo_node_get_draw_context (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_14
cairo_surface_t * gsk_cairo_node_get_surface (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL

View File

@@ -3053,6 +3053,8 @@ gsk_cairo_node_class_init (gpointer g_class,
* Retrieves the Cairo surface used by the render node.
*
* Returns: (transfer none): a Cairo surface
*
* Deprecated: 4.14: Use a [class@Gsk.TextureNode] instead
*/
cairo_surface_t *
gsk_cairo_node_get_surface (GskRenderNode *node)
@@ -3074,6 +3076,8 @@ gsk_cairo_node_get_surface (GskRenderNode *node)
* You can draw to the cairo surface using [method@Gsk.CairoNode.get_draw_context].
*
* Returns: (transfer full) (type GskCairoNode): A new `GskRenderNode`
*
* Deprecated: 4.14: Use a [class@Gsk.TextureNode] instead
*/
GskRenderNode *
gsk_cairo_node_new (const graphene_rect_t *bounds)
@@ -3104,6 +3108,8 @@ gsk_cairo_node_new (const graphene_rect_t *bounds)
*
* Returns: (transfer full): a Cairo context used for drawing; use
* cairo_destroy() when done drawing
*
* Deprecated: 4.14: Use [class@Gsk.TextureNode] instead
*/
cairo_t *
gsk_cairo_node_get_draw_context (GskRenderNode *node)

View File

@@ -1726,6 +1726,7 @@ parse_texture_scale_node (GtkCssParser *parser,
return node;
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GskRenderNode *
parse_cairo_node (GtkCssParser *parser,
Context *context)
@@ -1769,6 +1770,7 @@ parse_cairo_node (GtkCssParser *parser,
return node;
}
G_GNUC_END_IGNORE_DEPRECATIONS
static GskRenderNode *
parse_outset_shadow_node (GtkCssParser *parser,
@@ -4023,6 +4025,7 @@ render_node_print (Printer *p,
g_assert_not_reached ();
break;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
case GSK_CAIRO_NODE:
{
cairo_surface_t *surface = gsk_cairo_node_get_surface (node);
@@ -4079,6 +4082,7 @@ render_node_print (Printer *p,
end_node (p);
}
break;
G_GNUC_END_IGNORE_DEPRECATIONS
case GSK_SUBSURFACE_NODE:
{

View File

@@ -149,9 +149,11 @@ gsk_pango_renderer_draw_trapezoid (PangoRenderer *renderer,
return;
pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (crenderer->snapshot,
&GRAPHENE_RECT_INIT (ink_rect.x, ink_rect.y,
ink_rect.width, ink_rect.height));
G_GNUC_END_IGNORE_DEPRECATIONS
set_color (crenderer, part, cr);
x = y = 0;
@@ -250,9 +252,11 @@ gsk_pango_renderer_draw_shape (PangoRenderer *renderer,
return;
pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (crenderer->snapshot,
&GRAPHENE_RECT_INIT (ink_rect.x, ink_rect.y,
ink_rect.width, ink_rect.height));
G_GNUC_END_IGNORE_DEPRECATIONS
shape_renderer = pango_cairo_context_get_shape_renderer (pango_layout_get_context (layout),
&shape_renderer_data);

View File

@@ -251,12 +251,14 @@ gtk_drawing_area_snapshot (GtkWidget *widget,
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT (
0, 0,
width, height
));
G_GNUC_END_IGNORE_DEPRECATIONS
priv->draw_func (self,
cr,
width, height,

View File

@@ -2524,8 +2524,10 @@ gtk_flow_box_snapshot (GtkWidget *widget,
vertical = priv->orientation == GTK_ORIENTATION_VERTICAL;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT (x, y, width, height));
G_GNUC_END_IGNORE_DEPRECATIONS
style = gtk_css_node_get_style (priv->rubberband_node);

View File

@@ -1592,12 +1592,14 @@ create_arrow_render_node (GtkPopover *popover)
snapshot = gtk_snapshot_new ();
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT (
0, 0,
gtk_widget_get_width (widget),
gtk_widget_get_height (widget)
));
G_GNUC_END_IGNORE_DEPRECATIONS
/* Clip to the arrow shape */
cairo_save (cr);

View File

@@ -503,8 +503,10 @@ snapshot_frame_stroke (GtkSnapshot *snapshot,
double double_width[4] = { border_width[0], border_width[1], border_width[2], border_width[3] };
cairo_t *cr;
cr = gtk_snapshot_append_cairo (snapshot,
&outline->bounds);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (snapshot, &outline->bounds);
G_GNUC_END_IGNORE_DEPRECATIONS
render_frame_stroke (cr, outline, double_width, colors, hidden_side, stroke_style);
cairo_destroy (cr);
}
@@ -667,7 +669,9 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
bounds = gtk_css_boxes_get_border_rect (boxes);
gtk_snapshot_push_debug (snapshot, "CSS border image");
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (snapshot, bounds);
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_border_image_render (&border_image, border_width, cr, bounds);
cairo_destroy (cr);
gtk_snapshot_pop (snapshot);

View File

@@ -200,7 +200,9 @@ snapshot_insertion_cursor (GtkSnapshot *snapshot,
graphene_rect_t bounds;
get_insertion_cursor_bounds (width, height, aspect_ratio, direction, draw_arrow, &bounds);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (snapshot, &bounds);
G_GNUC_END_IGNORE_DEPRECATIONS
draw_insertion_cursor (cr, 0, 0, width, height, aspect_ratio, &color, direction, draw_arrow);

View File

@@ -2214,6 +2214,8 @@ gtk_snapshot_append_node (GtkSnapshot *snapshot,
*
* Returns: a `cairo_t` suitable for drawing the contents of
* the newly created render node
*
* Deprecated: 4.14: Create a [class@Gdk.MemoryTexture] from a cairo surface instead
*/
cairo_t *
gtk_snapshot_append_cairo (GtkSnapshot *snapshot,
@@ -2230,12 +2232,13 @@ gtk_snapshot_append_cairo (GtkSnapshot *snapshot,
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &dx, &dy);
gtk_graphene_rect_scale_affine (bounds, scale_x, scale_y, dx, dy, &real_bounds);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
node = gsk_cairo_node_new (&real_bounds);
cr = gsk_cairo_node_get_draw_context (node);
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_snapshot_append_node_internal (snapshot, node);
cr = gsk_cairo_node_get_draw_context (node);
cairo_scale (cr, scale_x, scale_y);
cairo_translate (cr, dx, dy);

View File

@@ -156,7 +156,7 @@ void gtk_snapshot_perspective (GtkSnapshot
GDK_AVAILABLE_IN_ALL
void gtk_snapshot_append_node (GtkSnapshot *snapshot,
GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_14
cairo_t * gtk_snapshot_append_cairo (GtkSnapshot *snapshot,
const graphene_rect_t *bounds);
GDK_AVAILABLE_IN_ALL

View File

@@ -155,12 +155,14 @@ graph_renderer_snapshot (GtkWidget *widget,
gtk_widget_get_color (widget, &color);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT (
0, 0,
gtk_widget_get_width (widget),
gtk_widget_get_height (widget)
));
G_GNUC_END_IGNORE_DEPRECATIONS
cairo_set_line_width (cr, 1.0);

View File

@@ -3,6 +3,8 @@
#include <math.h>
#include <stdlib.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
hsv_to_rgb (GdkRGBA *rgba,
double h,

View File

@@ -10,6 +10,7 @@ replay_container_node (GskRenderNode *node, GtkSnapshot *snapshot)
replay_node (gsk_container_node_get_child (node, i), snapshot);
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
replay_cairo_node (GskRenderNode *node, GtkSnapshot *snapshot)
{
@@ -21,6 +22,7 @@ replay_cairo_node (GskRenderNode *node, GtkSnapshot *snapshot)
cairo_set_source_surface (cr, surface, 0, 0);
cairo_paint (cr);
}
G_GNUC_END_IGNORE_DEPRECATIONS
static void
replay_color_node (GskRenderNode *node, GtkSnapshot *snapshot)