rendernode: Remove gsk_render_node_set_name()

And of course, gsk_render_node_get_name() is gone, too.
The replacement is of course debug nodes.

As a side effect, GskRenderNode is now *really* immutable.
This commit is contained in:
Benjamin Otte 2018-04-24 03:46:44 +02:00
parent 73b4a62f51
commit b49dccb86d
6 changed files with 70 additions and 75 deletions

View File

@ -29,8 +29,6 @@ gsk_render_node_serialize
gsk_render_node_deserialize
gsk_render_node_write_to_file
GskScalingFilter
gsk_render_node_set_name
gsk_render_node_get_name
gsk_render_node_get_bounds
<SUBSECTION Nodes>

View File

@ -66,8 +66,6 @@ gsk_render_node_finalize (GskRenderNode *self)
{
self->node_class->finalize (self);
g_clear_pointer (&self->name, g_free);
g_free (self);
}
@ -164,43 +162,6 @@ gsk_render_node_get_bounds (GskRenderNode *node,
graphene_rect_init_from_rect (bounds, &node->bounds);
}
/**
* gsk_render_node_set_name:
* @node: a #GskRenderNode
* @name: (nullable): a name for the node
*
* Sets the name of the node.
*
* A name is generally useful for debugging purposes.
*/
void
gsk_render_node_set_name (GskRenderNode *node,
const char *name)
{
g_return_if_fail (GSK_IS_RENDER_NODE (node));
g_free (node->name);
node->name = g_strdup (name);
}
/**
* gsk_render_node_get_name:
* @node: a #GskRenderNode
*
* Retrieves the name previously set via gsk_render_node_set_name().
* If no name has been set, %NULL is returned.
*
* Returns: (nullable): The name previously set via
* gsk_render_node_set_name() or %NULL
**/
const char *
gsk_render_node_get_name (GskRenderNode *node)
{
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), NULL);
return node->name;
}
/**
* gsk_render_node_draw:
* @node: a #GskRenderNode
@ -238,8 +199,7 @@ gsk_render_node_draw (GskRenderNode *node,
#endif
GSK_NOTE (CAIRO, g_message ("Rendering node %s[%p]",
node->name ? node->name : node->node_class->type_name,
node));
node->node_class->type_name, node));
node->node_class->draw (node, cr);
@ -259,9 +219,8 @@ gsk_render_node_draw (GskRenderNode *node,
if (cairo_status (cr))
{
g_warning ("drawing failure for render node %s '%s': %s",
g_warning ("drawing failure for render node %s: %s",
node->node_class->type_name,
gsk_render_node_get_name (node),
cairo_status_to_string (cairo_status (cr)));
}
}

View File

@ -66,11 +66,6 @@ void gsk_render_node_unref (GskRenderNode *
GDK_AVAILABLE_IN_ALL
GskRenderNodeType gsk_render_node_get_node_type (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
void gsk_render_node_set_name (GskRenderNode *node,
const char *name);
GDK_AVAILABLE_IN_ALL
const char * gsk_render_node_get_name (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
void gsk_render_node_get_bounds (GskRenderNode *node,
graphene_rect_t *bounds);

View File

@ -16,9 +16,6 @@ struct _GskRenderNode
volatile int ref_count;
/* Use for debugging */
char *name;
graphene_rect_t bounds;
};

View File

@ -839,7 +839,7 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderPass *self,
g_message ("Upload op=%s, node %s[%p], bounds %gx%g",
op->type == GSK_VULKAN_OP_FALLBACK_CLIP ? "fallback-clip" :
(op->type == GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP ? "fallback-rounded-clip" : "fallback"),
node->name ? node->name : node->node_class->type_name, node,
node->node_class->type_name, node,
ceil (node->bounds.size.width),
ceil (node->bounds.size.height)));
#ifdef G_ENABLE_DEBUG

View File

@ -122,24 +122,6 @@ recordings_list_row_selected (GtkListBox *box,
g_object_unref (recording);
}
static void
render_node_list_get_value (GtkTreeModelRenderNode *model,
GskRenderNode *node,
int column,
GValue *value)
{
switch (column)
{
case COLUMN_NODE_NAME:
g_value_set_string (value, gsk_render_node_get_name (node));
break;
default:
g_assert_not_reached ();
break;
}
}
static const char *
node_type_name (GskRenderNodeType type)
{
@ -196,6 +178,69 @@ node_type_name (GskRenderNodeType type)
}
}
static char *
node_name (GskRenderNode *node)
{
switch (gsk_render_node_get_node_type (node))
{
case GSK_NOT_A_RENDER_NODE:
default:
g_assert_not_reached ();
case GSK_CONTAINER_NODE:
case GSK_CAIRO_NODE:
case GSK_LINEAR_GRADIENT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
case GSK_BORDER_NODE:
case GSK_INSET_SHADOW_NODE:
case GSK_OUTSET_SHADOW_NODE:
case GSK_TRANSFORM_NODE:
case GSK_OPACITY_NODE:
case GSK_COLOR_MATRIX_NODE:
case GSK_REPEAT_NODE:
case GSK_CLIP_NODE:
case GSK_ROUNDED_CLIP_NODE:
case GSK_SHADOW_NODE:
case GSK_BLEND_NODE:
case GSK_CROSS_FADE_NODE:
case GSK_TEXT_NODE:
case GSK_BLUR_NODE:
return g_strdup (node_type_name (gsk_render_node_get_node_type (node)));
case GSK_OFFSET_NODE:
return g_strdup_printf ("Offset %g, %g", gsk_offset_node_get_x_offset (node), gsk_offset_node_get_y_offset (node));
case GSK_DEBUG_NODE:
return g_strdup (gsk_debug_node_get_message (node));
case GSK_COLOR_NODE:
return gdk_rgba_to_string (gsk_color_node_peek_color (node));
case GSK_TEXTURE_NODE:
{
GdkTexture *texture = gsk_texture_node_get_texture (node);
return g_strdup_printf ("%dx%d Texture", gdk_texture_get_width (texture), gdk_texture_get_height (texture));
}
}
}
static void
render_node_list_get_value (GtkTreeModelRenderNode *model,
GskRenderNode *node,
int column,
GValue *value)
{
switch (column)
{
case COLUMN_NODE_NAME:
g_value_take_string (value, node_name (node));
break;
default:
g_assert_not_reached ();
break;
}
}
static GdkTexture *
get_color_texture (const GdkRGBA *color)
{
@ -742,7 +787,7 @@ render_node_save (GtkButton *button,
GskRenderNode *node;
GtkTreeIter iter;
GtkWidget *dialog;
char *filename;
char *filename, *nodename;
if (!gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->render_node_tree)), NULL, &iter))
return;
@ -755,8 +800,9 @@ render_node_save (GtkButton *button,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Save"), GTK_RESPONSE_ACCEPT,
NULL);
filename = g_strdup_printf ("%s.node", gsk_render_node_get_name (node) ? gsk_render_node_get_name (node)
: node_type_name (gsk_render_node_get_node_type (node)));
nodename = node_name (node);
filename = g_strdup_printf ("%s.node", nodename);
g_free (nodename);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename);
g_free (filename);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);