summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2018-03-10 21:14:09 -0500
committerMatthias Clasen <mclasen@redhat.com>2018-03-11 00:31:44 -0500
commit694f1d8ecdf39317cabe68f595950f67b35f4af6 (patch)
tree3329107a31e14682555db878f7cd4f245736de6a
parente23f641e491fd85371a613dde7f90fee8924657d (diff)
downloadgtk+-694f1d8ecdf39317cabe68f595950f67b35f4af6.tar.gz
Stop using stack-allocated snapshots
Use the new/free api instead of init/finish for GtkSnapshot.
-rw-r--r--gtk/gtkcssimage.c8
-rw-r--r--gtk/gtkiconview.c16
-rw-r--r--gtk/gtkmagnifier.c15
-rw-r--r--gtk/gtkoverlay.c21
-rw-r--r--gtk/gtkstack.c15
-rw-r--r--gtk/gtktreeview.c12
-rw-r--r--gtk/gtkwidget.c23
7 files changed, 53 insertions, 57 deletions
diff --git a/gtk/gtkcssimage.c b/gtk/gtkcssimage.c
index 665ef93c47..6d0f449803 100644
--- a/gtk/gtkcssimage.c
+++ b/gtk/gtkcssimage.c
@@ -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)
{
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 6ffbd1d523..e03640344a 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -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;
diff --git a/gtk/gtkmagnifier.c b/gtk/gtkmagnifier.c
index 7d09b10a98..cc4e85081d 100644
--- a/gtk/gtkmagnifier.c
+++ b/gtk/gtkmagnifier.c
@@ -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)
{
diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c
index 3dc65aca77..90a930799b 100644
--- a/gtk/gtkoverlay.c
+++ b/gtk/gtkoverlay.c
@@ -673,17 +673,16 @@ gtk_overlay_snapshot (GtkWidget *widget,
if (main_widget_node == NULL)
{
- 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);
+ GtkSnapshot *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));
}
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index b501b77edb..172801e194 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -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,
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 1670f1a0c8..e3657c9d92 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -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);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 65bcf6adf5..e78f66272d 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -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,