summaryrefslogtreecommitdiff
path: root/gsk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-04-24 00:41:48 +0200
committerBenjamin Otte <otte@redhat.com>2018-04-24 04:06:58 +0200
commit49f9d2108dbde96d2d5555f737db0183e4002a8a (patch)
tree948debaa20cee02ec4433a6cc2db37fcbc918e0a /gsk
parent29d77be03f79f17e97b0db1575eba87ecaf0d222 (diff)
downloadgtk+-49f9d2108dbde96d2d5555f737db0183e4002a8a.tar.gz
gsk: Add GskDebugNode
Diffstat (limited to 'gsk')
-rw-r--r--gsk/gl/gskglrenderer.c6
-rw-r--r--gsk/gskbroadwayrenderer.c5
-rw-r--r--gsk/gskenums.h3
-rw-r--r--gsk/gskrendernode.h8
-rw-r--r--gsk/gskrendernodeimpl.c171
-rw-r--r--gsk/vulkan/gskvulkanrenderpass.c4
6 files changed, 196 insertions, 1 deletions
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index c7b8a7910f..177ac4b611 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -2077,6 +2077,12 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
}
break;
+ case GSK_DEBUG_NODE:
+ gsk_gl_renderer_add_render_ops (self,
+ gsk_debug_node_get_child (node),
+ builder);
+ break;
+
case GSK_COLOR_NODE:
render_color_node (self, node, builder, vertex_data);
break;
diff --git a/gsk/gskbroadwayrenderer.c b/gsk/gskbroadwayrenderer.c
index ec8b1bdd47..1a0268a096 100644
--- a/gsk/gskbroadwayrenderer.c
+++ b/gsk/gskbroadwayrenderer.c
@@ -619,6 +619,11 @@ gsk_broadway_renderer_add_node (GskRenderer *self,
}
return;
+ case GSK_DEBUG_NODE:
+ gsk_broadway_renderer_add_node (self, nodes, node_textures,
+ gsk_debug_node_get_child (node), offset_x, offset_y);
+ return;
+
case GSK_COLOR_MATRIX_NODE:
case GSK_TEXT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
diff --git a/gsk/gskenums.h b/gsk/gskenums.h
index 11def6bd8e..b605509047 100644
--- a/gsk/gskenums.h
+++ b/gsk/gskenums.h
@@ -73,7 +73,8 @@ typedef enum {
GSK_CROSS_FADE_NODE,
GSK_TEXT_NODE,
GSK_BLUR_NODE,
- GSK_OFFSET_NODE
+ GSK_OFFSET_NODE,
+ GSK_DEBUG_NODE
} GskRenderNodeType;
/**
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index 24e49b6385..b79381c251 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -90,6 +90,14 @@ GskRenderNode * gsk_render_node_deserialize (GBytes *
GError **error);
GDK_AVAILABLE_IN_ALL
+GskRenderNode * gsk_debug_node_new (GskRenderNode *child,
+ char *message);
+GDK_AVAILABLE_IN_ALL
+GskRenderNode * gsk_debug_node_get_child (GskRenderNode *node);
+GDK_AVAILABLE_IN_ALL
+const char * gsk_debug_node_get_message (GskRenderNode *node);
+
+GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_color_node_new (const GdkRGBA *rgba,
const graphene_rect_t *bounds);
GDK_AVAILABLE_IN_ALL
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index 36c99376ba..190eb5beba 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -2752,6 +2752,177 @@ gsk_offset_node_get_y_offset (GskRenderNode *node)
return self->y_offset;
}
+/*** GSK_DEBUG_NODE ***/
+
+typedef struct _GskDebugNode GskDebugNode;
+
+struct _GskDebugNode
+{
+ GskRenderNode render_node;
+
+ GskRenderNode *child;
+ char *message;
+};
+
+static void
+gsk_debug_node_finalize (GskRenderNode *node)
+{
+ GskDebugNode *self = (GskDebugNode *) node;
+
+ gsk_render_node_unref (self->child);
+ g_free (self->message);
+}
+
+static void
+gsk_debug_node_draw (GskRenderNode *node,
+ cairo_t *cr)
+{
+ GskDebugNode *self = (GskDebugNode *) node;
+
+ gsk_render_node_draw (self->child, cr);
+}
+
+static gboolean
+gsk_debug_node_can_diff (GskRenderNode *node1,
+ GskRenderNode *node2)
+{
+ GskDebugNode *self1 = (GskDebugNode *) node1;
+ GskDebugNode *self2 = (GskDebugNode *) node2;
+
+ return gsk_render_node_can_diff (self1->child, self2->child);
+}
+
+static void
+gsk_debug_node_diff (GskRenderNode *node1,
+ GskRenderNode *node2,
+ cairo_region_t *region)
+{
+ GskDebugNode *self1 = (GskDebugNode *) node1;
+ GskDebugNode *self2 = (GskDebugNode *) node2;
+
+ gsk_render_node_diff (self1->child, self2->child, region);
+}
+
+#define GSK_DEBUG_NODE_VARIANT_TYPE "(uvs)"
+
+static GVariant *
+gsk_debug_node_serialize (GskRenderNode *node)
+{
+ GskDebugNode *self = (GskDebugNode *) node;
+
+ return g_variant_new (GSK_DEBUG_NODE_VARIANT_TYPE,
+ (guint32) gsk_render_node_get_node_type (self->child),
+ gsk_render_node_serialize_node (self->child),
+ self->message);
+}
+
+static GskRenderNode *
+gsk_debug_node_deserialize (GVariant *variant,
+ GError **error)
+{
+ guint32 child_type;
+ GVariant *child_variant;
+ char *message;
+ GskRenderNode *result, *child;
+
+ if (!check_variant_type (variant, GSK_DEBUG_NODE_VARIANT_TYPE, error))
+ return NULL;
+
+ g_variant_get (variant, GSK_DEBUG_NODE_VARIANT_TYPE,
+ &child_type, &child_variant,
+ &message);
+
+ child = gsk_render_node_deserialize_node (child_type, child_variant, error);
+ g_variant_unref (child_variant);
+
+ if (child == NULL)
+ return NULL;
+
+ result = gsk_debug_node_new (child, message);
+
+ gsk_render_node_unref (child);
+
+ return result;
+}
+
+static const GskRenderNodeClass GSK_DEBUG_NODE_CLASS = {
+ GSK_DEBUG_NODE,
+ sizeof (GskDebugNode),
+ "GskDebugNode",
+ gsk_debug_node_finalize,
+ gsk_debug_node_draw,
+ gsk_debug_node_can_diff,
+ gsk_debug_node_diff,
+ gsk_debug_node_serialize,
+ gsk_debug_node_deserialize
+};
+
+/**
+ * gsk_debug_node_new:
+ * @child: The child to add debug info for
+ * @message: (transfer full): The debug message
+ *
+ * Creates a #GskRenderNode that will add debug information about
+ * the given @child.
+ *
+ * Adding this node has no visual effect.
+ *
+ * Returns: A new #GskRenderNode
+ */
+GskRenderNode *
+gsk_debug_node_new (GskRenderNode *child,
+ char *message)
+{
+ GskDebugNode *self;
+
+ g_return_val_if_fail (GSK_IS_RENDER_NODE (child), NULL);
+
+ self = (GskDebugNode *) gsk_render_node_new (&GSK_DEBUG_NODE_CLASS, 0);
+
+ self->child = gsk_render_node_ref (child);
+ self->message = message;
+
+ graphene_rect_init_from_rect (&self->render_node.bounds, &child->bounds);
+
+ return &self->render_node;
+}
+
+/**
+ * gsk_debug_node_get_child:
+ * @node: a debug @GskRenderNode
+ *
+ * Gets the child node that is getting debug by the given @node.
+ *
+ * Returns: (transfer none): The child that is getting debug
+ **/
+GskRenderNode *
+gsk_debug_node_get_child (GskRenderNode *node)
+{
+ GskDebugNode *self = (GskDebugNode *) node;
+
+ g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_DEBUG_NODE), NULL);
+
+ return self->child;
+}
+
+/**
+ * gsk_debug_node_get_message:
+ * @node: a debug #GskRenderNode
+ *
+ * Gets the debug message that was set on this node
+ *
+ * Returns: (transfer none): The debug message
+ **/
+const char *
+gsk_debug_node_get_message (GskRenderNode *node)
+{
+ GskDebugNode *self = (GskDebugNode *) node;
+
+ g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_DEBUG_NODE), "You run broken code!");
+
+ return self->message;
+}
+
/*** GSK_OPACITY_NODE ***/
typedef struct _GskOpacityNode GskOpacityNode;
diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c
index 9bc38f3006..48e3b2c959 100644
--- a/gsk/vulkan/gskvulkanrenderpass.c
+++ b/gsk/vulkan/gskvulkanrenderpass.c
@@ -545,6 +545,10 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
}
return;
+ case GSK_DEBUG_NODE:
+ gsk_vulkan_render_pass_add_node (self, render, constants, gsk_debug_node_get_child (node));
+ return;
+
case GSK_OFFSET_NODE:
case GSK_TRANSFORM_NODE:
{