snapshot: Remove renderer

Now that there's no longer a need to keep the renderer around for Cairo
rendering, don't do that then.
This commit is contained in:
Benjamin Otte 2018-03-24 21:41:53 +01:00
parent e84c6acc4f
commit 1cfa88ed91
10 changed files with 11 additions and 38 deletions

View File

@ -253,7 +253,7 @@ _gtk_css_image_draw (GtkCssImage *image,
cairo_save (cr); cairo_save (cr);
clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) { 0, 0, width, height }); clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) { 0, 0, width, height });
snapshot = gtk_snapshot_new (NULL, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (image)); snapshot = gtk_snapshot_new (FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (image));
gtk_css_image_snapshot (image, snapshot, width, height); gtk_css_image_snapshot (image, snapshot, width, height);
node = gtk_snapshot_free_to_node (snapshot); node = gtk_snapshot_free_to_node (snapshot);

View File

@ -6724,7 +6724,7 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
rect.width, rect.width,
rect.height); rect.height);
snapshot = gtk_snapshot_new (NULL, FALSE, NULL, "IconView DragIcon"); snapshot = gtk_snapshot_new (FALSE, NULL, "IconView DragIcon");
gtk_icon_view_snapshot_item (icon_view, snapshot, item, gtk_icon_view_snapshot_item (icon_view, snapshot, item,
icon_view->priv->item_padding, icon_view->priv->item_padding,
icon_view->priv->item_padding, icon_view->priv->item_padding,

View File

@ -115,8 +115,7 @@ gtk_magnifier_snapshot (GtkWidget *widget,
g_signal_handler_block (priv->inspected, priv->draw_handler); g_signal_handler_block (priv->inspected, priv->draw_handler);
inspected_snapshot = gtk_snapshot_new (gtk_snapshot_get_renderer (snapshot), inspected_snapshot = gtk_snapshot_new (gtk_snapshot_get_record_names (snapshot),
gtk_snapshot_get_record_names (snapshot),
NULL, NULL,
"MagnifierSnapshot"); "MagnifierSnapshot");

View File

@ -675,8 +675,7 @@ gtk_overlay_snapshot (GtkWidget *widget,
{ {
GtkSnapshot *child_snapshot; GtkSnapshot *child_snapshot;
child_snapshot = gtk_snapshot_new (gtk_snapshot_get_renderer (snapshot), child_snapshot = gtk_snapshot_new (gtk_snapshot_get_record_names (snapshot),
gtk_snapshot_get_record_names (snapshot),
NULL, NULL,
"OverlayCaptureMainChild"); "OverlayCaptureMainChild");
gtk_snapshot_offset (child_snapshot, main_alloc.x, main_alloc.y); gtk_snapshot_offset (child_snapshot, main_alloc.x, main_alloc.y);

View File

@ -157,7 +157,6 @@ gtk_snapshot_state_clear (GtkSnapshotState *state)
/** /**
* gtk_snapshot_new: * gtk_snapshot_new:
* @renderer: the #GskRenderer to create nodes for
* @record_names: whether to keep node names (for debugging purposes) * @record_names: whether to keep node names (for debugging purposes)
* @clip: (nullable): the clip region to use, or %NULL * @clip: (nullable): the clip region to use, or %NULL
* @name: a printf-style format string to create the node name * @name: a printf-style format string to create the node name
@ -168,8 +167,7 @@ gtk_snapshot_state_clear (GtkSnapshotState *state)
* Returns: a newly-allocated #GtkSnapshot * Returns: a newly-allocated #GtkSnapshot
*/ */
GtkSnapshot * GtkSnapshot *
gtk_snapshot_new (GskRenderer *renderer, gtk_snapshot_new (gboolean record_names,
gboolean record_names,
const cairo_region_t *clip, const cairo_region_t *clip,
const char *name, const char *name,
...) ...)
@ -191,7 +189,6 @@ gtk_snapshot_new (GskRenderer *renderer,
snapshot = g_object_new (GTK_TYPE_SNAPSHOT, NULL); snapshot = g_object_new (GTK_TYPE_SNAPSHOT, NULL);
snapshot->record_names = record_names; snapshot->record_names = record_names;
snapshot->renderer = renderer;
snapshot->state_stack = g_array_new (FALSE, TRUE, sizeof (GtkSnapshotState)); snapshot->state_stack = g_array_new (FALSE, TRUE, sizeof (GtkSnapshotState));
g_array_set_clear_func (snapshot->state_stack, (GDestroyNotify)gtk_snapshot_state_clear); g_array_set_clear_func (snapshot->state_stack, (GDestroyNotify)gtk_snapshot_state_clear);
snapshot->nodes = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_render_node_unref); snapshot->nodes = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_render_node_unref);
@ -1199,21 +1196,6 @@ gtk_snapshot_pop (GtkSnapshot *snapshot)
} }
} }
/**
* gtk_snapshot_get_renderer:
* @snapshot: a #GtkSnapshot
*
* Obtains the #GskRenderer that this snapshot will be
* rendered with.
*
* Returns: (transfer none): the #GskRenderer
*/
GskRenderer *
gtk_snapshot_get_renderer (GtkSnapshot *snapshot)
{
return snapshot->renderer;
}
/** /**
* gtk_snapshot_get_record_names: * gtk_snapshot_get_record_names:
* @snapshot: a #GtkSnapshot * @snapshot: a #GtkSnapshot

View File

@ -52,19 +52,16 @@ GDK_AVAILABLE_IN_ALL
GType gtk_snapshot_get_type (void) G_GNUC_CONST; GType gtk_snapshot_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GtkSnapshot * gtk_snapshot_new (GskRenderer *renderer, GtkSnapshot * gtk_snapshot_new (gboolean record_names,
gboolean record_names,
const cairo_region_t *clip, const cairo_region_t *clip,
const char *name, const char *name,
...) G_GNUC_PRINTF (4, 5); ...) G_GNUC_PRINTF (3, 4);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gtk_snapshot_free_to_node (GtkSnapshot *snapshot); GskRenderNode * gtk_snapshot_free_to_node (GtkSnapshot *snapshot);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gtk_snapshot_to_node (GtkSnapshot *snapshot); GskRenderNode * gtk_snapshot_to_node (GtkSnapshot *snapshot);
GDK_AVAILABLE_IN_ALL
GskRenderer * gtk_snapshot_get_renderer (GtkSnapshot *snapshot);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
gboolean gtk_snapshot_get_record_names (GtkSnapshot *snapshot); gboolean gtk_snapshot_get_record_names (GtkSnapshot *snapshot);

View File

@ -89,7 +89,6 @@ struct _GdkSnapshot {
GObject parent_instance; /* it's really GdkSnapshot, but don't tell anyone! */ GObject parent_instance; /* it's really GdkSnapshot, but don't tell anyone! */
gboolean record_names; gboolean record_names;
GskRenderer *renderer;
GArray *state_stack; GArray *state_stack;
GPtrArray *nodes; GPtrArray *nodes;
}; };

View File

@ -1956,8 +1956,7 @@ gtk_stack_snapshot (GtkWidget *widget,
gtk_widget_get_allocation (priv->last_visible_child->widget, gtk_widget_get_allocation (priv->last_visible_child->widget,
&priv->last_visible_surface_allocation); &priv->last_visible_surface_allocation);
last_visible_snapshot = gtk_snapshot_new (gtk_snapshot_get_renderer (snapshot), last_visible_snapshot = gtk_snapshot_new (gtk_snapshot_get_record_names (snapshot),
gtk_snapshot_get_record_names (snapshot),
NULL, NULL,
"StackCaptureLastVisibleChild"); "StackCaptureLastVisibleChild");
gtk_widget_snapshot (priv->last_visible_child->widget, last_visible_snapshot); gtk_widget_snapshot (priv->last_visible_child->widget, last_visible_snapshot);

View File

@ -13860,7 +13860,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
bin_window_width + 2, bin_window_width + 2,
background_area.height + 2); background_area.height + 2);
snapshot = gtk_snapshot_new (NULL, FALSE, NULL, "TreeView DragIcon"); snapshot = gtk_snapshot_new (FALSE, NULL, "TreeView DragIcon");
gtk_snapshot_render_background (snapshot, context, gtk_snapshot_render_background (snapshot, context,
0, 0, 0, 0,

View File

@ -5444,7 +5444,6 @@ gtk_widget_draw_internal (GtkWidget *widget,
if (mode == RENDER_SNAPSHOT) if (mode == RENDER_SNAPSHOT)
{ {
GskRenderer *renderer = gtk_widget_get_renderer (widget);
GtkSnapshot *snapshot; GtkSnapshot *snapshot;
cairo_region_t *clip; cairo_region_t *clip;
GskRenderNode *node; GskRenderNode *node;
@ -5454,7 +5453,7 @@ gtk_widget_draw_internal (GtkWidget *widget,
widget->priv->clip.y - widget->priv->allocation.y, widget->priv->clip.y - widget->priv->allocation.y,
widget->priv->clip.width, widget->priv->clip.width,
widget->priv->clip.height}); widget->priv->clip.height});
snapshot = gtk_snapshot_new (renderer, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (widget)); snapshot = gtk_snapshot_new (FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (widget));
gtk_widget_snapshot (widget, snapshot); gtk_widget_snapshot (widget, snapshot);
node = gtk_snapshot_free_to_node (snapshot); node = gtk_snapshot_free_to_node (snapshot);
if (node != NULL) if (node != NULL)
@ -13982,8 +13981,7 @@ gtk_widget_render (GtkWidget *widget,
context = gsk_renderer_begin_draw_frame (renderer, region); context = gsk_renderer_begin_draw_frame (renderer, region);
clip = gdk_drawing_context_get_clip (context); clip = gdk_drawing_context_get_clip (context);
snapshot = gtk_snapshot_new (renderer, snapshot = gtk_snapshot_new (should_record_names (widget, renderer),
should_record_names (widget, renderer),
clip, clip,
"Render<%s>", G_OBJECT_TYPE_NAME (widget)); "Render<%s>", G_OBJECT_TYPE_NAME (widget));
cairo_region_destroy (clip); cairo_region_destroy (clip);