Stop using stack-allocated snapshots

Use the new/free api instead of init/finish
for GtkSnapshot.
This commit is contained in:
Matthias Clasen 2018-03-10 21:14:09 -05:00
parent e23f641e49
commit 694f1d8ecd
7 changed files with 52 additions and 56 deletions

View File

@ -219,7 +219,7 @@ _gtk_css_image_draw (GtkCssImage *image,
double width,
double height)
{
GtkSnapshot snapshot;
GtkSnapshot *snapshot;
GskRenderNode *node;
cairo_region_t *clip;
@ -231,9 +231,9 @@ _gtk_css_image_draw (GtkCssImage *image,
cairo_save (cr);
clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) { 0, 0, width, height });
gtk_snapshot_init (&snapshot, NULL, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (image));
gtk_css_image_snapshot (image, &snapshot, width, height);
node = gtk_snapshot_finish (&snapshot);
snapshot = gtk_snapshot_new (NULL, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (image));
gtk_css_image_snapshot (image, snapshot, width, height);
node = gtk_snapshot_free_to_node (snapshot);
if (node != NULL)
{

View File

@ -6689,7 +6689,7 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
GtkTreePath *path)
{
GtkWidget *widget;
GtkSnapshot snapshot;
GtkSnapshot *snapshot;
GskRenderNode *node;
cairo_t *cr;
cairo_surface_t *surface;
@ -6724,15 +6724,15 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
rect.width,
rect.height);
gtk_snapshot_init (&snapshot, NULL, FALSE, NULL, "IconView DragIcon");
gtk_icon_view_snapshot_item (icon_view, &snapshot, item,
icon_view->priv->item_padding,
icon_view->priv->item_padding,
FALSE);
node = gtk_snapshot_finish (&snapshot);
snapshot = gtk_snapshot_new (NULL, FALSE, NULL, "IconView DragIcon");
gtk_icon_view_snapshot_item (icon_view, snapshot, item,
icon_view->priv->item_padding,
icon_view->priv->item_padding,
FALSE);
node = gtk_snapshot_free_to_node (snapshot);
cr = cairo_create (surface);
gsk_render_node_draw (node, cr);
gsk_render_node_draw (node, cr);
cairo_destroy (cr);
return surface;

View File

@ -103,7 +103,7 @@ gtk_magnifier_snapshot (GtkWidget *widget,
{
GtkMagnifier *magnifier = GTK_MAGNIFIER (widget);
GtkMagnifierPrivate *priv = _gtk_magnifier_get_instance_private (magnifier);
GtkSnapshot inspected_snapshot;
GtkSnapshot *inspected_snapshot;
GskRenderNode *inspected_node;
graphene_matrix_t transform;
@ -115,14 +115,13 @@ gtk_magnifier_snapshot (GtkWidget *widget,
g_signal_handler_block (priv->inspected, priv->draw_handler);
gtk_snapshot_init (&inspected_snapshot,
gtk_snapshot_get_renderer (snapshot),
snapshot->record_names,
NULL,
"MagnifierSnapshot");
inspected_snapshot = gtk_snapshot_new (gtk_snapshot_get_renderer (snapshot),
snapshot->record_names,
NULL,
"MagnifierSnapshot");
gtk_widget_snapshot (priv->inspected, &inspected_snapshot);
inspected_node = gtk_snapshot_finish (&inspected_snapshot);
gtk_widget_snapshot (priv->inspected, inspected_snapshot);
inspected_node = gtk_snapshot_free_to_node (inspected_snapshot);
if (inspected_node != NULL)
{

View File

@ -673,17 +673,16 @@ gtk_overlay_snapshot (GtkWidget *widget,
if (main_widget_node == NULL)
{
GtkSnapshot child_snapshot;
GtkSnapshot *child_snapshot;
gtk_snapshot_init (&child_snapshot,
gtk_snapshot_get_renderer (snapshot),
snapshot->record_names,
NULL,
"OverlayCaptureMainChild");
gtk_snapshot_offset (&child_snapshot, main_alloc.x, main_alloc.y);
gtk_widget_snapshot (main_widget, &child_snapshot);
gtk_snapshot_offset (&child_snapshot, -main_alloc.x, -main_alloc.y);
main_widget_node = gtk_snapshot_finish (&child_snapshot);
child_snapshot = gtk_snapshot_new (gtk_snapshot_get_renderer (snapshot),
snapshot->record_names,
NULL,
"OverlayCaptureMainChild");
gtk_snapshot_offset (child_snapshot, main_alloc.x, main_alloc.y);
gtk_widget_snapshot (main_widget, child_snapshot);
gtk_snapshot_offset (child_snapshot, -main_alloc.x, -main_alloc.y);
main_widget_node = gtk_snapshot_free_to_node (child_snapshot);
graphene_matrix_init_translate (&translate, &GRAPHENE_POINT3D_INIT (main_alloc.x,main_alloc.y, 0));
}

View File

@ -1952,17 +1952,16 @@ gtk_stack_snapshot (GtkWidget *widget,
if (priv->last_visible_node == NULL &&
priv->last_visible_child != NULL)
{
GtkSnapshot last_visible_snapshot;
GtkSnapshot *last_visible_snapshot;
gtk_widget_get_allocation (priv->last_visible_child->widget,
&priv->last_visible_surface_allocation);
gtk_snapshot_init (&last_visible_snapshot,
gtk_snapshot_get_renderer (snapshot),
snapshot->record_names,
NULL,
"StackCaptureLastVisibleChild");
gtk_widget_snapshot (priv->last_visible_child->widget, &last_visible_snapshot);
priv->last_visible_node = gtk_snapshot_finish (&last_visible_snapshot);
last_visible_snapshot = gtk_snapshot_new (gtk_snapshot_get_renderer (snapshot),
snapshot->record_names,
NULL,
"StackCaptureLastVisibleChild");
gtk_widget_snapshot (priv->last_visible_child->widget, last_visible_snapshot);
priv->last_visible_node = gtk_snapshot_free_to_node (last_visible_snapshot);
}
gtk_snapshot_push_clip (snapshot,

View File

@ -13821,7 +13821,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
GList *list;
GdkRectangle background_area;
GtkWidget *widget;
GtkSnapshot snapshot;
GtkSnapshot *snapshot;
GskRenderNode *rendernode;
gint depth;
/* start drawing inside the black outline */
@ -13871,9 +13871,9 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
bin_window_width + 2,
background_area.height + 2);
gtk_snapshot_init (&snapshot, NULL, FALSE, NULL, "TreeView DragIcon");
snapshot = gtk_snapshot_new (NULL, FALSE, NULL, "TreeView DragIcon");
gtk_snapshot_render_background (&snapshot, context,
gtk_snapshot_render_background (snapshot, context,
0, 0,
bin_window_width + 2,
background_area.height + 2);
@ -13924,7 +13924,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SEPARATOR);
gtk_style_context_get_color (context, &color);
gtk_snapshot_append_color (&snapshot,
gtk_snapshot_append_color (snapshot,
&color,
&GRAPHENE_RECT_INIT(
cell_area.x,
@ -13939,7 +13939,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
else
{
gtk_tree_view_column_cell_snapshot (column,
&snapshot,
snapshot,
&background_area,
&cell_area,
0, FALSE);
@ -13948,7 +13948,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
cell_offset += gtk_tree_view_column_get_width (column);
}
rendernode = gtk_snapshot_finish (&snapshot);
rendernode = gtk_snapshot_free_to_node (snapshot);
cr = cairo_create (surface);

View File

@ -5459,7 +5459,7 @@ gtk_widget_draw_internal (GtkWidget *widget,
if (mode == RENDER_SNAPSHOT)
{
GskRenderer *renderer = gtk_widget_get_renderer (widget);
GtkSnapshot snapshot;
GtkSnapshot *snapshot;
cairo_region_t *clip;
GskRenderNode *node;
@ -5468,9 +5468,9 @@ gtk_widget_draw_internal (GtkWidget *widget,
widget->priv->clip.y - widget->priv->allocation.y,
widget->priv->clip.width,
widget->priv->clip.height});
gtk_snapshot_init (&snapshot, renderer, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (widget));
gtk_widget_snapshot (widget, &snapshot);
node = gtk_snapshot_finish (&snapshot);
snapshot = gtk_snapshot_new (renderer, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (widget));
gtk_widget_snapshot (widget, snapshot);
node = gtk_snapshot_free_to_node (snapshot);
if (node != NULL)
{
gsk_render_node_draw (node, cr);
@ -13981,7 +13981,7 @@ gtk_widget_render (GtkWidget *widget,
const cairo_region_t *region)
{
GdkDrawingContext *context;
GtkSnapshot snapshot;
GtkSnapshot *snapshot;
GskRenderer *renderer;
GskRenderNode *root;
cairo_region_t *clip;
@ -13997,14 +13997,13 @@ gtk_widget_render (GtkWidget *widget,
context = gsk_renderer_begin_draw_frame (renderer, region);
clip = gdk_drawing_context_get_clip (context);
gtk_snapshot_init (&snapshot,
renderer,
should_record_names (widget, renderer),
clip,
"Render<%s>", G_OBJECT_TYPE_NAME (widget));
snapshot = gtk_snapshot_new (renderer,
should_record_names (widget, renderer),
clip,
"Render<%s>", G_OBJECT_TYPE_NAME (widget));
cairo_region_destroy (clip);
gtk_widget_snapshot (widget, &snapshot);
root = gtk_snapshot_finish (&snapshot);
gtk_widget_snapshot (widget, snapshot);
root = gtk_snapshot_free_to_node (snapshot);
if (root != NULL)
{
gtk_inspector_record_render (widget,