[gtk+] gsk: Add gsk_cairo_node_new()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gsk: Add gsk_cairo_node_new()
- Date: Tue, 20 Dec 2016 17:08:35 +0000 (UTC)
commit 52d2faef8821a8cff31cd66301018c707a7ef04e
Author: Benjamin Otte <otte redhat com>
Date: Sun Dec 11 01:23:02 2016 +0100
gsk: Add gsk_cairo_node_new()
Split off Cairo drawn content nodes and require you to allocate them
using this new function.
docs/reference/gsk/gsk4-sections.txt | 3 +-
gsk/gskcairorenderer.c | 5 +--
gsk/gskglrenderer.c | 2 +-
gsk/gskrendernode.c | 40 ++++++++++++++++++++++++++++-----
gsk/gskrendernode.h | 9 +++++--
gsk/gskrendernodeprivate.h | 2 +-
gsk/gskvulkanrenderpass.c | 2 +-
gtk/gtksnapshot.c | 5 +--
8 files changed, 49 insertions(+), 19 deletions(-)
---
diff --git a/docs/reference/gsk/gsk4-sections.txt b/docs/reference/gsk/gsk4-sections.txt
index 642a52d..7003776 100644
--- a/docs/reference/gsk/gsk4-sections.txt
+++ b/docs/reference/gsk/gsk4-sections.txt
@@ -49,13 +49,14 @@ gsk_render_node_set_transform
gsk_render_node_set_opacity
gsk_render_node_set_opaque
gsk_render_node_is_opaque
-gsk_render_node_get_draw_context
GskBlendMode
gsk_render_node_set_blend_mode
GskScalingFilter
gsk_render_node_set_scaling_filters
gsk_render_node_set_name
gsk_texture_node_new
+gsk_cairo_node_new
+gsk_cairo_node_get_draw_context
<SUBSECTION Standard>
GSK_IS_RENDER_NODE
GSK_RENDER_NODE
diff --git a/gsk/gskcairorenderer.c b/gsk/gskcairorenderer.c
index 5a31814..0d3c66e 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 b533cbd..5eb3d8a 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 c9568c4..31a6f27 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 c724ad2..e912fbe 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 c70ef62..d581af6 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 e5c64cc..d4c1862 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),
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index b6025a8..3a57d44 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -409,8 +409,7 @@ gtk_snapshot_append_cairo_node (GtkSnapshot *snapshot,
g_return_val_if_fail (snapshot != NULL, NULL);
g_return_val_if_fail (bounds != NULL, NULL);
- node = gsk_renderer_create_render_node (snapshot->renderer);
- gsk_render_node_set_bounds (node, bounds);
+ node = gsk_cairo_node_new (bounds);
if (name)
{
@@ -429,7 +428,7 @@ gtk_snapshot_append_cairo_node (GtkSnapshot *snapshot,
gtk_snapshot_append_node (snapshot, node);
gsk_render_node_unref (node);
- return gsk_render_node_get_draw_context (node, snapshot->renderer);
+ return gsk_cairo_node_get_draw_context (node, snapshot->renderer);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]