diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c index f38b177e53..768467f4c1 100644 --- a/gsk/gskglrenderer.c +++ b/gsk/gskglrenderer.c @@ -813,7 +813,7 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self, case GSK_CAIRO_NODE: { - cairo_surface_t *surface = gsk_cairo_node_get_surface (node); + const cairo_surface_t *surface = gsk_cairo_node_peek_surface (node); int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST; if (surface == NULL) @@ -828,7 +828,7 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self, gsk_gl_driver_bind_source_texture (self->gl_driver, item.render_data.texture_id); gsk_gl_driver_init_texture_with_surface (self->gl_driver, item.render_data.texture_id, - surface, + (cairo_surface_t *)surface, gl_min_filter, gl_mag_filter); item.mode = MODE_TEXTURE; diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h index 1b0fba6a72..bc8126884f 100644 --- a/gsk/gskrendernode.h +++ b/gsk/gskrendernode.h @@ -183,13 +183,10 @@ float gsk_outset_shadow_node_get_blur_radius (GskRenderNode GDK_AVAILABLE_IN_3_90 GskRenderNode * gsk_cairo_node_new (const graphene_rect_t *bounds); GDK_AVAILABLE_IN_3_90 -GskRenderNode * gsk_cairo_node_new_for_surface (const graphene_rect_t *bounds, - cairo_surface_t *surface); -GDK_AVAILABLE_IN_3_90 cairo_t * gsk_cairo_node_get_draw_context (GskRenderNode *node, GskRenderer *renderer); GDK_AVAILABLE_IN_3_94 -cairo_surface_t * gsk_cairo_node_get_surface (GskRenderNode *node); +const cairo_surface_t * gsk_cairo_node_peek_surface (GskRenderNode *node); GDK_AVAILABLE_IN_3_90 GskRenderNode * gsk_container_node_new (GskRenderNode **children, diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index b3a6e2455f..1072dfcb18 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -1829,16 +1829,8 @@ static const GskRenderNodeClass GSK_CAIRO_NODE_CLASS = { gsk_cairo_node_deserialize }; -/*< private > - * gsk_cairo_node_get_surface: - * @node: a #GskRenderNode - * - * Retrieves the surface set using gsk_render_node_set_surface(). - * - * Returns: (transfer none) (nullable): a Cairo surface - */ -cairo_surface_t * -gsk_cairo_node_get_surface (GskRenderNode *node) +const cairo_surface_t * +gsk_cairo_node_peek_surface (GskRenderNode *node) { GskCairoNode *self = (GskCairoNode *) node; diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h index 8fafdb37f3..e337c53656 100644 --- a/gsk/gskrendernodeprivate.h +++ b/gsk/gskrendernodeprivate.h @@ -48,6 +48,9 @@ GskRenderNode * gsk_render_node_deserialize_node (GskRenderNodeType typ GVariant *variant, GError **error); +GskRenderNode * gsk_cairo_node_new_for_surface (const graphene_rect_t *bounds, + cairo_surface_t *surface); + G_END_DECLS #endif /* __GSK_RENDER_NODE_PRIVATE_H__ */ diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c index 3a1a23cdeb..83d9e2edd2 100644 --- a/gsk/gskvulkanrenderpass.c +++ b/gsk/gskvulkanrenderpass.c @@ -353,7 +353,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, return; case GSK_CAIRO_NODE: - if (gsk_cairo_node_get_surface (node) == NULL) + if (gsk_cairo_node_peek_surface (node) == NULL) return; if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds)) pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE; @@ -691,7 +691,7 @@ gsk_vulkan_render_pass_get_node_as_texture (GskVulkanRenderPass *self, case GSK_CAIRO_NODE: if (graphene_rect_equal (bounds, &node->bounds)) { - surface = cairo_surface_reference (gsk_cairo_node_get_surface (node)); + surface = cairo_surface_reference ((cairo_surface_t *)gsk_cairo_node_peek_surface (node)); goto got_surface; } break; @@ -910,7 +910,7 @@ gsk_vulkan_render_pass_upload (GskVulkanRenderPass *self, { cairo_surface_t *surface; - surface = gsk_cairo_node_get_surface (op->render.node); + surface = gsk_cairo_node_peek_surface (op->render.node); op->render.source = gsk_vulkan_image_new_from_data (uploader, cairo_image_surface_get_data (surface), cairo_image_surface_get_width (surface), diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c index eac8fafe28..1aeee3b23d 100644 --- a/gtk/inspector/recorder.c +++ b/gtk/inspector/recorder.c @@ -322,7 +322,7 @@ populate_render_node_properties (GtkListStore *store, else { text = "Surface"; - surface = gsk_cairo_node_get_surface (node); + surface = (cairo_surface_t *)gsk_cairo_node_peek_surface (node); } show_inline = cairo_image_surface_get_height (surface) <= 40 && diff --git a/tests/rendernode-create-tests.c b/tests/rendernode-create-tests.c index 2621c264f5..013188ea65 100644 --- a/tests/rendernode-create-tests.c +++ b/tests/rendernode-create-tests.c @@ -430,10 +430,7 @@ cairo_node (guint n) { GskRenderNode **nodes = g_newa (GskRenderNode *, n); GskRenderNode *container; - cairo_surface_t *surface; graphene_rect_t bounds; - gint offset = 0, height, width, stride; - guchar *buf; guint i; for (i = 0; i < n; i++) @@ -442,25 +439,7 @@ cairo_node (guint n) bounds.origin.x = g_random_int_range (0, 1000 - bounds.size.width); bounds.size.height = g_random_int_range (20, 100); bounds.origin.y = g_random_int_range (0, 1000 - bounds.size.height); - - height = g_random_int_range (1, 100); - width = g_random_int_range (1, 100); - stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width + offset); - - buf = g_malloc (stride * height); - - if (i % 3 == 0) - surface = NULL; - else - surface = cairo_image_surface_create_for_data (buf, CAIRO_FORMAT_ARGB32, width, height, stride); - - nodes[i] = gsk_cairo_node_new_for_surface (&bounds, surface); - - /* Offset in stride helps to test when image is not 'tightly packed' condition */ - offset = offset ? 0 : 3; - - cairo_surface_destroy (surface); - g_free (buf); + nodes [i] = gsk_cairo_node_new (&bounds); } container = gsk_container_node_new (nodes, n); diff --git a/testsuite/gsk/test-render-nodes.c b/testsuite/gsk/test-render-nodes.c index 29119aec96..befbf9ee4f 100644 --- a/testsuite/gsk/test-render-nodes.c +++ b/testsuite/gsk/test-render-nodes.c @@ -255,17 +255,18 @@ static GskRenderNode * ducky (void) { GdkPixbuf *pixbuf; - cairo_surface_t *surface; GskRenderNode *node; + cairo_t *cr; pixbuf = gdk_pixbuf_new_from_file_at_size ("ducky.png", 100, 100, NULL); - surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL); - node = gsk_cairo_node_new_for_surface (&GRAPHENE_RECT_INIT (0, 0, - cairo_image_surface_get_width (surface), - cairo_image_surface_get_height (surface)), - surface); + node = gsk_cairo_node_new (&GRAPHENE_RECT_INIT (0, 0, + gdk_pixbuf_get_width (pixbuf), + gdk_pixbuf_get_height (pixbuf))); + cr = gsk_cairo_node_get_draw_context (node, NULL); + gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); + cairo_paint (cr); + cairo_destroy (cr); g_object_unref (pixbuf); - cairo_surface_destroy (surface); return node; }