summaryrefslogtreecommitdiff
path: root/gsk
diff options
context:
space:
mode:
Diffstat (limited to 'gsk')
-rw-r--r--gsk/gskcairorenderer.c5
-rw-r--r--gsk/gskglrenderer.c2
-rw-r--r--gsk/gskrendernode.c40
-rw-r--r--gsk/gskrendernode.h9
-rw-r--r--gsk/gskrendernodeprivate.h2
-rw-r--r--gsk/gskvulkanrenderpass.c2
6 files changed, 45 insertions, 15 deletions
diff --git a/gsk/gskcairorenderer.c b/gsk/gskcairorenderer.c
index 5a31814eec..0d3c66e64d 100644
--- a/gsk/gskcairorenderer.c
+++ b/gsk/gskcairorenderer.c
@@ -94,8 +94,7 @@ gsk_cairo_renderer_render_node (GskCairoRenderer *self,
pop_group = TRUE;
}
- GSK_NOTE (CAIRO, g_print ("Rendering surface %p for node %s[%p] at %g, %g\n",
- gsk_render_node_get_surface (node),
+ GSK_NOTE (CAIRO, g_print ("Rendering node %s[%p] at %g, %g\n",
node->name,
node,
frame.origin.x, frame.origin.y));
@@ -110,7 +109,7 @@ gsk_cairo_renderer_render_node (GskCairoRenderer *self,
}
else
{
- cairo_set_source_surface (cr, gsk_render_node_get_surface (node), frame.origin.x, frame.origin.y);
+ cairo_set_source_surface (cr, gsk_cairo_node_get_surface (node), frame.origin.x, frame.origin.y);
cairo_paint (cr);
}
diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c
index b533cbd00e..5eb3d8afe1 100644
--- a/gsk/gskglrenderer.c
+++ b/gsk/gskglrenderer.c
@@ -733,7 +733,7 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
}
else if (gsk_render_node_has_surface (node))
{
- cairo_surface_t *surface = gsk_render_node_get_surface (node);
+ cairo_surface_t *surface = gsk_cairo_node_get_surface (node);
int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST;
get_gl_scaling_filters (node, &gl_min_filter, &gl_mag_filter);
diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c
index c9568c43b9..31a6f27eb5 100644
--- a/gsk/gskrendernode.c
+++ b/gsk/gskrendernode.c
@@ -1080,7 +1080,7 @@ gsk_texture_node_new (GskTexture *texture,
}
/*< private >
- * gsk_render_node_get_surface:
+ * gsk_cairo_node_get_surface:
* @node: a #GskRenderNode
*
* Retrieves the surface set using gsk_render_node_set_surface().
@@ -1088,9 +1088,10 @@ gsk_texture_node_new (GskTexture *texture,
* Returns: (transfer none) (nullable): a Cairo surface
*/
cairo_surface_t *
-gsk_render_node_get_surface (GskRenderNode *node)
+gsk_cairo_node_get_surface (GskRenderNode *node)
{
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), NULL);
+ g_return_val_if_fail (node->type == GSK_CAIRO_NODE, NULL);
return node->surface;
}
@@ -1218,8 +1219,34 @@ gsk_render_node_get_blend_mode (GskRenderNode *node)
}
/**
- * gsk_render_node_get_draw_context:
- * @node: a #GskRenderNode
+ * gsk_cairo_node_new:
+ * @bounds: the rectangle to render the to
+ *
+ * Creates a #GskRenderNode that will render a cairo surface
+ * into the area given by @bounds. You can draw to the cairo
+ * surface using gsk_cairo_node_get_draw_context()
+ *
+ * Returns: A new #GskRenderNode
+ *
+ * Since: 3.90
+ */
+GskRenderNode *
+gsk_cairo_node_new (const graphene_rect_t *bounds)
+{
+ GskRenderNode *node;
+
+ g_return_val_if_fail (bounds != NULL, NULL);
+
+ node = gsk_render_node_new (GSK_CAIRO_NODE);
+
+ graphene_rect_init_from_rect (&node->bounds, bounds);
+
+ return node;
+}
+
+/**
+ * gsk_cairo_node_get_draw_context:
+ * @node: a cairo #GskRenderNode
* @renderer: (nullable): Renderer to optimize for or %NULL for any
*
* Creates a Cairo context for drawing using the surface associated
@@ -1233,13 +1260,14 @@ gsk_render_node_get_blend_mode (GskRenderNode *node)
* Since: 3.90
*/
cairo_t *
-gsk_render_node_get_draw_context (GskRenderNode *node,
- GskRenderer *renderer)
+gsk_cairo_node_get_draw_context (GskRenderNode *node,
+ GskRenderer *renderer)
{
int width, height;
cairo_t *res;
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), NULL);
+ g_return_val_if_fail (node->type == GSK_CAIRO_NODE, NULL);
g_return_val_if_fail (node->is_mutable, NULL);
g_return_val_if_fail (renderer == NULL || GSK_IS_RENDERER (renderer), NULL);
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index c724ad298c..e912fbed98 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -49,6 +49,12 @@ GskRenderNode * gsk_texture_node_new (GskTexture
const graphene_rect_t *bounds);
GDK_AVAILABLE_IN_3_90
+GskRenderNode * gsk_cairo_node_new (const graphene_rect_t *bounds);
+GDK_AVAILABLE_IN_3_90
+cairo_t * gsk_cairo_node_get_draw_context (GskRenderNode *node,
+ GskRenderer *renderer);
+
+GDK_AVAILABLE_IN_3_90
GskRenderNode * gsk_render_node_get_parent (GskRenderNode *node);
GDK_AVAILABLE_IN_3_90
GskRenderNode * gsk_render_node_get_first_child (GskRenderNode *node);
@@ -107,9 +113,6 @@ void gsk_render_node_set_opaque (GskRenderNode *
gboolean opaque);
GDK_AVAILABLE_IN_3_90
gboolean gsk_render_node_is_opaque (GskRenderNode *node);
-GDK_AVAILABLE_IN_3_90
-cairo_t * gsk_render_node_get_draw_context (GskRenderNode *node,
- GskRenderer *renderer);
GDK_AVAILABLE_IN_3_90
void gsk_render_node_set_blend_mode (GskRenderNode *node,
diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h
index c70ef62476..d581af6188 100644
--- a/gsk/gskrendernodeprivate.h
+++ b/gsk/gskrendernodeprivate.h
@@ -69,7 +69,7 @@ void gsk_render_node_get_transform (GskRenderNode *node,
graphene_matrix_t *mv);
double gsk_render_node_get_opacity (GskRenderNode *node);
-cairo_surface_t *gsk_render_node_get_surface (GskRenderNode *node);
+cairo_surface_t *gsk_cairo_node_get_surface (GskRenderNode *node);
GskTexture *gsk_texture_node_get_texture (GskRenderNode *node);
diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c
index e5c64ccc95..d4c1862c07 100644
--- a/gsk/gskvulkanrenderpass.c
+++ b/gsk/gskvulkanrenderpass.c
@@ -154,7 +154,7 @@ gsk_vulkan_render_pass_upload (GskVulkanRenderPass *self,
case GSK_VULKAN_OP_SURFACE:
{
- cairo_surface_t *surface = gsk_render_node_get_surface (op->node);
+ cairo_surface_t *surface = gsk_cairo_node_get_surface (op->node);
op->source = gsk_vulkan_image_new_from_data (self->vulkan,
command_buffer,
cairo_image_surface_get_data (surface),