snapshot: Redo pop() API

gtk_snapshot_pop() => removed
gtk_snapshot_pop_and_append() => gtk_snapshot_pop()

So now there is no way to get a rendernode out of the snapshotting API
until you gtk_snapshot_finish().
This commit is contained in:
Benjamin Otte 2017-01-13 00:39:59 +01:00
parent bc3ba68641
commit b58de2d16c
20 changed files with 57 additions and 73 deletions

View File

@ -4461,7 +4461,6 @@ gtk_snapshot_push_rounded_clip
gtk_snapshot_push_cross_fade
gtk_snapshot_push_blend
gtk_snapshot_pop
gtk_snapshot_pop_and_append
gtk_snapshot_set_transform
gtk_snapshot_transform
gtk_snapshot_translate_2d

View File

@ -787,7 +787,7 @@ gtk_cell_renderer_snapshot (GtkCellRenderer *cell,
cell_area,
flags);
gtk_style_context_restore (context);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
/**

View File

@ -671,7 +671,7 @@ gtk_cell_renderer_progress_snapshot (GtkCellRenderer *cell,
layout);
gtk_style_context_restore (context);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TROUGH);
@ -700,7 +700,7 @@ gtk_cell_renderer_progress_snapshot (GtkCellRenderer *cell,
x_pos, y_pos,
layout);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
if (bar_position + bar_size < start + full_size)
@ -727,7 +727,7 @@ gtk_cell_renderer_progress_snapshot (GtkCellRenderer *cell,
x_pos, y_pos,
layout);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
gtk_style_context_restore (context);

View File

@ -1767,7 +1767,7 @@ gtk_cell_renderer_text_snapshot (GtkCellRenderer *cell,
cell_area->y + y_offset + ypad,
layout);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
g_object_unref (layout);
}

View File

@ -465,7 +465,7 @@ gtk_cell_renderer_toggle_snapshot (GtkCellRenderer *cell,
image_type);
gtk_style_context_restore (context);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
static gint

View File

@ -176,7 +176,7 @@ gtk_color_swatch_render (GtkCssGadget *gadget,
"ColorSwatch Opaque Color");
}
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
gtk_css_gadget_snapshot (swatch->priv->overlay_gadget, snapshot);

View File

@ -859,5 +859,5 @@ gtk_css_filter_value_pop_snapshot (const GtkCssValue *filter,
if (gtk_css_filter_value_is_none (filter))
return;
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}

View File

@ -110,11 +110,11 @@ gtk_css_image_cross_fade_snapshot (GtkCssImage *image,
if (cross_fade->start)
gtk_css_image_snapshot (cross_fade->start, snapshot, width, height);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
if (cross_fade->end)
gtk_css_image_snapshot (cross_fade->end, snapshot, width, height);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
static gboolean

View File

@ -1846,7 +1846,7 @@ gtk_icon_view_snapshot (GtkWidget *widget,
if (icon_view->priv->doing_rubberband)
gtk_icon_view_snapshot_rubberband (icon_view, snapshot);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->snapshot (widget, snapshot);
}

View File

@ -2970,7 +2970,7 @@ gtk_menu_snapshot (GtkWidget *widget,
GTK_WIDGET_CLASS (gtk_menu_parent_class)->snapshot (widget, snapshot);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
static void

View File

@ -1679,7 +1679,7 @@ gtk_paned_render (GtkCssGadget *gadget,
),
"GtkPanedChild1");
gtk_widget_snapshot_child (widget, priv->child1, snapshot);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
if (priv->child2 && gtk_widget_get_visible (priv->child2))
@ -1694,7 +1694,7 @@ gtk_paned_render (GtkCssGadget *gadget,
),
"GtkPanedChild2");
gtk_widget_snapshot_child (widget, priv->child2, snapshot);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
return FALSE;

View File

@ -105,7 +105,7 @@ gtk_theming_background_snapshot_color (GtkThemingBackground *bg,
bg_color,
&bg->boxes[clip].bounds,
"BackgroundColor");
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
}
@ -506,12 +506,12 @@ gtk_theming_background_snapshot_layer (GtkThemingBackground *bg,
position_y + 0.5 * (repeat_height - image_height));
gtk_css_image_snapshot (image, snapshot, image_width, image_height);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
gtk_snapshot_translate_2d (snapshot, - origin->bounds.origin.x, - origin->bounds.origin.y);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
static void
@ -664,9 +664,9 @@ gtk_css_style_snapshot_background (GtkCssStyle *style,
}
else
{
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
gtk_theming_background_snapshot_layer (&bg, idx, snapshot);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
}

View File

@ -140,12 +140,12 @@ gtk_css_style_snapshot_icon (GtkCssStyle *style,
gtk_css_image_builtin_snapshot (image, snapshot, width, height, builtin_type);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
if (shadows)
{
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
g_free (shadows);
}
@ -322,12 +322,12 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
graphene_rect_init (&bounds, 0, 0, gsk_texture_get_width (texture), gsk_texture_get_height (texture));
gtk_snapshot_append_texture_node (snapshot, texture, &bounds, "Icon");
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
if (shadows)
{
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
g_free (shadows);
}

View File

@ -851,7 +851,7 @@ gtk_revealer_snapshot (GtkWidget *widget,
),
"RevealerClip");
gtk_widget_snapshot_child (widget, child, snapshot);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
}

View File

@ -156,21 +156,6 @@ gtk_snapshot_init (GtkSnapshot *snapshot,
gtk_snapshot_collect_default);
}
GskRenderNode *
gtk_snapshot_finish (GtkSnapshot *snapshot)
{
GskRenderNode *result;
result = gtk_snapshot_pop (snapshot);
if (snapshot->state != NULL)
{
g_warning ("Too many gtk_snapshot_push() calls.");
}
return result;
}
/**
* gtk_snapshot_push:
* @snapshot: a #GtkSnapshot
@ -887,21 +872,8 @@ gtk_snapshot_push_cross_fade (GtkSnapshot *snapshot,
snapshot->state = state;
}
/**
* gtk_snapshot_pop:
* @snapshot: a #GtkSnapshot
*
* Removes the top element from the stack of render nodes,
* making the node underneath the current node again.
*
* Returns: (transfer full) (nullable): A #GskRenderNode for
* the contents that were rendered to @snapshot since
* the corresponding gtk_snapshot_push() call
*
* Since: 3.90
*/
GskRenderNode *
gtk_snapshot_pop (GtkSnapshot *snapshot)
static GskRenderNode *
gtk_snapshot_pop_internal (GtkSnapshot *snapshot)
{
GtkSnapshotState *state;
GskRenderNode *node;
@ -931,8 +903,23 @@ gtk_snapshot_pop (GtkSnapshot *snapshot)
return node;
}
GskRenderNode *
gtk_snapshot_finish (GtkSnapshot *snapshot)
{
GskRenderNode *result;
result = gtk_snapshot_pop_internal (snapshot);
if (snapshot->state != NULL)
{
g_warning ("Too many gtk_snapshot_push() calls.");
}
return result;
}
/**
* gtk_snapshot_pop_and_append:
* gtk_snapshot_pop:
* @snapshot: a #GtkSnapshot
*
* Removes the top element from the stack of render nodes,
@ -941,11 +928,11 @@ gtk_snapshot_pop (GtkSnapshot *snapshot)
* Since: 3.90
*/
void
gtk_snapshot_pop_and_append (GtkSnapshot *snapshot)
gtk_snapshot_pop (GtkSnapshot *snapshot)
{
GskRenderNode *node;
node = gtk_snapshot_pop (snapshot);
node = gtk_snapshot_pop_internal (snapshot);
if (node)
{
gtk_snapshot_append_node (snapshot, node);

View File

@ -90,9 +90,7 @@ void gtk_snapshot_push_cross_fade (GtkSnapshot
const char *name,
...) G_GNUC_PRINTF (3, 4);
GDK_AVAILABLE_IN_3_90
GskRenderNode * gtk_snapshot_pop (GtkSnapshot *snapshot) G_GNUC_WARN_UNUSED_RESULT;
GDK_AVAILABLE_IN_3_90
void gtk_snapshot_pop_and_append (GtkSnapshot *snapshot);
void gtk_snapshot_pop (GtkSnapshot *snapshot);
GDK_AVAILABLE_IN_3_90
void gtk_snapshot_translate_2d (GtkSnapshot *snapshot,

View File

@ -1925,14 +1925,14 @@ gtk_stack_snapshot_crossfade (GtkWidget *widget,
gtk_snapshot_push_transform (snapshot, &identity, "CrossFadeStart");
gtk_snapshot_append_node (snapshot, priv->last_visible_node);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
gtk_widget_snapshot_child (widget,
priv->visible_child->widget,
snapshot);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
static void
@ -1984,7 +1984,7 @@ gtk_stack_snapshot_under (GtkWidget *widget,
priv->visible_child->widget,
snapshot);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
if (priv->last_visible_node)
{
@ -1994,7 +1994,7 @@ gtk_stack_snapshot_under (GtkWidget *widget,
gtk_snapshot_push_transform (snapshot, &matrix, "StackUnder");
gtk_snapshot_append_node (snapshot, priv->last_visible_node);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
}
@ -2055,7 +2055,7 @@ gtk_stack_snapshot_slide (GtkWidget *widget,
graphene_matrix_init_translate (&matrix, &GRAPHENE_POINT3D_INIT (x, y, 0));
gtk_snapshot_push_transform (snapshot, &matrix, "StackSlide");
gtk_snapshot_append_node (snapshot, priv->last_visible_node);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
gtk_widget_snapshot_child (widget,
@ -2139,7 +2139,7 @@ gtk_stack_render (GtkCssGadget *gadget,
g_assert_not_reached ();
}
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
else
gtk_widget_snapshot_child (widget,

View File

@ -5412,7 +5412,7 @@ gtk_tree_view_snapshot (GtkWidget *widget,
gtk_widget_snapshot_child (widget, child->widget, snapshot);
}
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
#if 0
Thyis clearly does not work. priv->drag_highlight_window is potentially a toplevel...
@ -5478,7 +5478,7 @@ gtk_tree_view_snapshot (GtkWidget *widget,
gtk_style_context_restore (context);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
enum

View File

@ -298,7 +298,7 @@ gtk_viewport_render (GtkCssGadget *gadget,
GTK_WIDGET_CLASS (gtk_viewport_parent_class)->snapshot (widget, snapshot);
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
return FALSE;
}

View File

@ -15661,13 +15661,13 @@ gtk_widget_snapshot (GtkWidget *widget,
}
if (opacity < 1.0)
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
gtk_css_filter_value_pop_snapshot (filter_value, snapshot);
if (GTK_DEBUG_CHECK (SNAPSHOT))
gtk_snapshot_pop_and_append (snapshot);
gtk_snapshot_pop (snapshot);
}
void