[gtk+] snapshot: Redo pop() API



commit b58de2d16cbb1b4e8fbdb6aac9d73deb887650e9
Author: Benjamin Otte <otte redhat com>
Date:   Fri Jan 13 00:39:59 2017 +0100

    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().

 docs/reference/gtk/gtk4-sections.txt |    1 -
 gtk/gtkcellrenderer.c                |    2 +-
 gtk/gtkcellrendererprogress.c        |    6 ++--
 gtk/gtkcellrenderertext.c            |    2 +-
 gtk/gtkcellrenderertoggle.c          |    2 +-
 gtk/gtkcolorswatch.c                 |    2 +-
 gtk/gtkcssfiltervalue.c              |    2 +-
 gtk/gtkcssimagecrossfade.c           |    4 +-
 gtk/gtkiconview.c                    |    2 +-
 gtk/gtkmenu.c                        |    2 +-
 gtk/gtkpaned.c                       |    4 +-
 gtk/gtkrenderbackground.c            |   10 +++---
 gtk/gtkrendericon.c                  |    8 ++--
 gtk/gtkrevealer.c                    |    2 +-
 gtk/gtksnapshot.c                    |   53 +++++++++++++---------------------
 gtk/gtksnapshot.h                    |    4 +--
 gtk/gtkstack.c                       |   14 ++++----
 gtk/gtktreeview.c                    |    4 +-
 gtk/gtkviewport.c                    |    2 +-
 gtk/gtkwidget.c                      |    4 +-
 20 files changed, 57 insertions(+), 73 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 76fb079..d74a2a9 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -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
diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c
index 7c0f776..334ddca 100644
--- a/gtk/gtkcellrenderer.c
+++ b/gtk/gtkcellrenderer.c
@@ -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);
 }
 
 /**
diff --git a/gtk/gtkcellrendererprogress.c b/gtk/gtkcellrendererprogress.c
index 290fd14..56ca8e4 100644
--- a/gtk/gtkcellrendererprogress.c
+++ b/gtk/gtkcellrendererprogress.c
@@ -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);
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index a5f2255..a969a36 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -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);
 }
diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c
index 7f8dc74..5022474 100644
--- a/gtk/gtkcellrenderertoggle.c
+++ b/gtk/gtkcellrenderertoggle.c
@@ -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
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index aa11f34..a7af9a7 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -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);
diff --git a/gtk/gtkcssfiltervalue.c b/gtk/gtkcssfiltervalue.c
index 7ad0bd4..cb33e42 100644
--- a/gtk/gtkcssfiltervalue.c
+++ b/gtk/gtkcssfiltervalue.c
@@ -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);
 }
diff --git a/gtk/gtkcssimagecrossfade.c b/gtk/gtkcssimagecrossfade.c
index 7f80248..08cd137 100644
--- a/gtk/gtkcssimagecrossfade.c
+++ b/gtk/gtkcssimagecrossfade.c
@@ -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
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 2cbc680..580208f 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -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);
 }
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index e1b3ec1..c70b3ea 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -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
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index 4953ca9..2762074 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -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;
diff --git a/gtk/gtkrenderbackground.c b/gtk/gtkrenderbackground.c
index 6d2f2fd..bca7dc1 100644
--- a/gtk/gtkrenderbackground.c
+++ b/gtk/gtkrenderbackground.c
@@ -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);
         }
     }
 
diff --git a/gtk/gtkrendericon.c b/gtk/gtkrendericon.c
index 9cf0b6e..f8c50fa 100644
--- a/gtk/gtkrendericon.c
+++ b/gtk/gtkrendericon.c
@@ -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);
     }
   
diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c
index 4c30ac7..9e9a6c8 100644
--- a/gtk/gtkrevealer.c
+++ b/gtk/gtkrevealer.c
@@ -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);
     }
 }
 
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 3e0b9f4..7c9a75a 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -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);
diff --git a/gtk/gtksnapshot.h b/gtk/gtksnapshot.h
index b59f32c..d44ad4d 100644
--- a/gtk/gtksnapshot.h
+++ b/gtk/gtksnapshot.h
@@ -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,
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index 0e4e463..083c199 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -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,
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index e289d0b..7e7f3d5 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -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
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index d439c45..ff8933c 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -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;
 }
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 2f93d63..e84179d 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]