mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
gsk: Add GskDebugNode
This commit is contained in:
parent
29d77be03f
commit
49f9d2108d
@ -108,6 +108,9 @@ gsk_text_node_get_y
|
||||
gsk_blur_node_new
|
||||
gsk_blur_node_get_child
|
||||
gsk_blur_node_get_radius
|
||||
gsk_debug_node_new
|
||||
gsk_debug_node_get_child
|
||||
gsk_debug_node_get_message
|
||||
<SUBSECTION Standard>
|
||||
GSK_IS_RENDER_NODE
|
||||
GSK_RENDER_NODE
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -89,6 +89,14 @@ GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_render_node_deserialize (GBytes *bytes,
|
||||
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);
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
{
|
||||
|
@ -600,6 +600,10 @@ append_node (GtkTreeModelRenderNode *nodemodel,
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_DEBUG_NODE:
|
||||
append_node (nodemodel, gsk_debug_node_get_child (node), priv->nodes->len - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,6 +151,8 @@ node_type_name (GskRenderNodeType type)
|
||||
return "Unknown";
|
||||
case GSK_CONTAINER_NODE:
|
||||
return "Container";
|
||||
case GSK_DEBUG_NODE:
|
||||
return "Debug";
|
||||
case GSK_CAIRO_NODE:
|
||||
return "Cairo";
|
||||
case GSK_COLOR_NODE:
|
||||
@ -626,6 +628,10 @@ populate_render_node_properties (GtkListStore *store,
|
||||
g_free (tmp);
|
||||
break;
|
||||
|
||||
case GSK_DEBUG_NODE:
|
||||
add_text_row (store, "Message", gsk_debug_node_get_message (node));
|
||||
break;
|
||||
|
||||
case GSK_SHADOW_NODE:
|
||||
{
|
||||
int i;
|
||||
|
Loading…
Reference in New Issue
Block a user