diff --git a/docs/reference/gsk/gsk4-sections.txt b/docs/reference/gsk/gsk4-sections.txt index 7d590b4c50..0282fd2087 100644 --- a/docs/reference/gsk/gsk4-sections.txt +++ b/docs/reference/gsk/gsk4-sections.txt @@ -63,18 +63,3 @@ GskRenderNodeClass gsk_render_node_get_type GSK_TYPE_BLEND_MODE - -
-GskRenderNodeIter -gsk_render_node_iter_new -gsk_render_node_iter_free -gsk_render_node_iter_init -gsk_render_node_iter_is_valid -gsk_render_node_iter_prev -gsk_render_node_iter_next -gsk_render_node_iter_remove - -GSK_TYPE_RENDER_NODE_ITER -GskRenderNodeIter -gsk_render_node_iter_get_type -
diff --git a/gsk/Makefile.am b/gsk/Makefile.am index 32f37d3261..9091c2424a 100644 --- a/gsk/Makefile.am +++ b/gsk/Makefile.am @@ -47,7 +47,6 @@ gsk_public_source_h = \ gskenums.h \ gskrenderer.h \ gskrendernode.h \ - gskrendernodeiter.h \ gsktexture.h \ gsktypes.h gsk_private_source_h = \ @@ -66,7 +65,6 @@ gsk_private_source_h = \ gsk_public_source_c = \ gskrenderer.c \ gskrendernode.c \ - gskrendernodeiter.c \ gsktexture.c gsk_private_source_c = \ $(gsk_private_vulkan_source_c) \ diff --git a/gsk/gsk.h b/gsk/gsk.h index 394895c1aa..92ce028784 100644 --- a/gsk/gsk.h +++ b/gsk/gsk.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/gsk/gskcairorenderer.c b/gsk/gskcairorenderer.c index 9b333c5867..7e96052f20 100644 --- a/gsk/gskcairorenderer.c +++ b/gsk/gskcairorenderer.c @@ -4,7 +4,6 @@ #include "gskdebugprivate.h" #include "gskrendererprivate.h" -#include "gskrendernodeiter.h" #include "gskrendernodeprivate.h" #include "gsktextureprivate.h" @@ -52,7 +51,6 @@ gsk_cairo_renderer_render_node (GskCairoRenderer *self, GskRenderNode *node, cairo_t *cr) { - GskRenderNodeIter iter; GskRenderNode *child; gboolean pop_group = FALSE; graphene_matrix_t mvp; @@ -136,9 +134,12 @@ out: GSK_NOTE (CAIRO, g_print ("Drawing %d children of node [%p]\n", gsk_render_node_get_n_children (node), node)); - gsk_render_node_iter_init (&iter, node); - while (gsk_render_node_iter_next (&iter, &child)) - gsk_cairo_renderer_render_node (self, child, cr); + for (child = gsk_render_node_get_first_child (node); + child != NULL; + child = gsk_render_node_get_next_sibling (child)) + { + gsk_cairo_renderer_render_node (self, child, cr); + } } if (pop_group) diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c index ad03664de5..f8524ee951 100644 --- a/gsk/gskglrenderer.c +++ b/gsk/gskglrenderer.c @@ -9,7 +9,6 @@ #include "gskprofilerprivate.h" #include "gskrendererprivate.h" #include "gskrendernodeprivate.h" -#include "gskrendernodeiter.h" #include "gskshaderbuilderprivate.h" #include "gsktextureprivate.h" @@ -627,7 +626,6 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self, RenderItem *parent) { graphene_rect_t viewport; - GskRenderNodeIter iter; graphene_matrix_t mv; graphene_rect_t bounds; GskRenderNode *child; @@ -789,9 +787,12 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self, render_items = item.children; out: - gsk_render_node_iter_init (&iter, node); - while (gsk_render_node_iter_next (&iter, &child)) - gsk_gl_renderer_add_render_item (self, projection, render_items, child, ritem); + for (child = gsk_render_node_get_first_child (node); + child != NULL; + child = gsk_render_node_get_next_sibling (child)) + { + gsk_gl_renderer_add_render_item (self, projection, render_items, child, ritem); + } } static gboolean diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c index 54ea5a5271..13869e1382 100644 --- a/gsk/gskrendernode.c +++ b/gsk/gskrendernode.c @@ -44,7 +44,6 @@ #include "gskrendernodeprivate.h" #include "gskdebugprivate.h" -#include "gskrendernodeiter.h" #include "gskrendererprivate.h" #include "gsktexture.h" @@ -69,17 +68,14 @@ G_DEFINE_BOXED_TYPE (GskRenderNode, gsk_render_node, static void gsk_render_node_finalize (GskRenderNode *self) { - GskRenderNodeIter iter; - self->is_mutable = TRUE; g_clear_pointer (&self->surface, cairo_surface_destroy); g_clear_pointer (&self->texture, gsk_texture_unref); g_clear_pointer (&self->name, g_free); - gsk_render_node_iter_init (&iter, self); - while (gsk_render_node_iter_next (&iter, NULL)) - gsk_render_node_iter_remove (&iter); + while (self->first_child) + gsk_render_node_remove_child (self, self->first_child); g_slice_free (GskRenderNode, self); } @@ -697,17 +693,14 @@ gsk_render_node_remove_child (GskRenderNode *node, GskRenderNode * gsk_render_node_remove_all_children (GskRenderNode *node) { - GskRenderNodeIter iter; - g_return_val_if_fail (GSK_IS_RENDER_NODE (node), NULL); g_return_val_if_fail (node->is_mutable, node); if (node->n_children == 0) return node; - gsk_render_node_iter_init (&iter, node); - while (gsk_render_node_iter_next (&iter, NULL)) - gsk_render_node_iter_remove (&iter); + while (node->first_child != NULL) + gsk_render_node_remove_child (node, node->first_child); g_assert (node->n_children == 0); g_assert (node->first_child == NULL); @@ -967,7 +960,6 @@ void gsk_render_node_update_world_matrix (GskRenderNode *node, gboolean force) { - GskRenderNodeIter iter; GskRenderNode *child; if (force || node->needs_world_matrix_update) @@ -1000,9 +992,12 @@ gsk_render_node_update_world_matrix (GskRenderNode *node, node->needs_world_matrix_update = FALSE; } - gsk_render_node_iter_init (&iter, node); - while (gsk_render_node_iter_next (&iter, &child)) - gsk_render_node_update_world_matrix (child, TRUE); + for (child = gsk_render_node_get_first_child (node); + child != NULL; + child = gsk_render_node_get_next_sibling (child)) + { + gsk_render_node_update_world_matrix (child, TRUE); + } } gboolean @@ -1289,7 +1284,6 @@ gsk_render_node_get_draw_context (GskRenderNode *node, void gsk_render_node_make_immutable (GskRenderNode *node) { - GskRenderNodeIter iter; GskRenderNode *child; if (!node->is_mutable) @@ -1297,9 +1291,12 @@ gsk_render_node_make_immutable (GskRenderNode *node) node->is_mutable = FALSE; - gsk_render_node_iter_init (&iter, node); - while (gsk_render_node_iter_next (&iter, &child)) - gsk_render_node_make_immutable (child); + for (child = gsk_render_node_get_first_child (node); + child != NULL; + child = gsk_render_node_get_next_sibling (child)) + { + gsk_render_node_make_immutable (child); + } } /*< private > @@ -1313,16 +1310,18 @@ gsk_render_node_make_immutable (GskRenderNode *node) int gsk_render_node_get_size (GskRenderNode *root) { - GskRenderNodeIter iter; GskRenderNode *child; int res; g_return_val_if_fail (GSK_IS_RENDER_NODE (root), 0); res = 1; - gsk_render_node_iter_init (&iter, root); - while (gsk_render_node_iter_next (&iter, &child)) - res += gsk_render_node_get_size (child); + for (child = gsk_render_node_get_first_child (root); + child != NULL; + child = gsk_render_node_get_next_sibling (child)) + { + res += gsk_render_node_get_size (child); + } return res; } diff --git a/gsk/gskrendernodeiter.c b/gsk/gskrendernodeiter.c deleted file mode 100644 index 74b52e3d30..0000000000 --- a/gsk/gskrendernodeiter.c +++ /dev/null @@ -1,254 +0,0 @@ -/* GSK - The GTK Scene Kit - * - * Copyright 2016 Endless - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/** - * SECTION:GskRenderNodeIter - * @Title: GskRenderNodeIter - * @Short_description: Iterator helper for render nodes - * - * TODO - */ - -#include "config.h" - -#include "gskrendernodeiter.h" -#include "gskrendernodeprivate.h" - -typedef struct { - GskRenderNode *root; - GskRenderNode *current; - gint64 age; - gpointer reserved1; - gpointer reserved2; -} RealIter; - -#define REAL_ITER(iter) ((RealIter *) (iter)) - -/** - * gsk_render_node_iter_new: (constructor) - * - * Allocates a new #GskRenderNodeIter. - * - * Returns: (transfer full): the newly allocated #GskRenderNodeIter - * - * Since: 3.90 - */ -GskRenderNodeIter * -gsk_render_node_iter_new (void) -{ - return g_slice_new (GskRenderNodeIter); -} - -/*< private > - * gsk_render_node_iter_copy: - * @src: a #GskRenderNodeIter - * - * Copies a #GskRenderNodeIter. - * - * Returns: (transfer full): a #GskRenderNodeIter - */ -static GskRenderNodeIter * -gsk_render_node_iter_copy (GskRenderNodeIter *src) -{ - return g_slice_dup (GskRenderNodeIter, src); -} - -/** - * gsk_render_node_iter_free: - * @iter: a #GskRenderNodeIter - * - * Frees the resources allocated by gsk_render_node_iter_new(). - * - * Since: 3.90 - */ -void -gsk_render_node_iter_free (GskRenderNodeIter *iter) -{ - g_slice_free (GskRenderNodeIter, iter); -} - -G_DEFINE_BOXED_TYPE (GskRenderNodeIter, gsk_render_node_iter, - gsk_render_node_iter_copy, - gsk_render_node_iter_free) - -/** - * gsk_render_node_iter_init: - * @iter: a #GskRenderNodeIter - * @node: a #GskRenderNode - * - * Initializes a #GskRenderNodeIter for iterating over the - * children of @node. - * - * It's safe to call this function multiple times on the same - * #GskRenderNodeIter instance. - * - * Since: 3.90 - */ -void -gsk_render_node_iter_init (GskRenderNodeIter *iter, - GskRenderNode *node) -{ - RealIter *riter = REAL_ITER (iter); - - g_return_if_fail (iter != NULL); - g_return_if_fail (GSK_IS_RENDER_NODE (node)); - - riter->root = node; - riter->age = node->age; - riter->current = NULL; -} - -/** - * gsk_render_node_iter_is_valid: - * @iter: a #GskRenderNodeIter - * - * Checks whether a #GskRenderNodeIter is associated to a #GskRenderNode, - * or whether the associated node was modified while iterating. - * - * Returns: %TRUE if the iterator is still valid. - * - * Since: 3.90 - */ -gboolean -gsk_render_node_iter_is_valid (GskRenderNodeIter *iter) -{ - RealIter *riter = REAL_ITER (iter); - - g_return_val_if_fail (iter != NULL, FALSE); - - if (riter->root == NULL) - return FALSE; - - return riter->root->age == riter->age; -} - -/** - * gsk_render_node_iter_next: - * @iter: a #GskRenderNodeIter - * @child: (out) (transfer none): return location for a #GskRenderNode - * - * Advances the @iter and retrieves the next child of the root #GskRenderNode - * used to initialize the #GskRenderNodeIter. - * - * If the iterator could advance, this function returns %TRUE and sets the - * @child argument with the child #GskRenderNode. - * - * If the iterator could not advance, this function returns %FALSE and the - * contents of the @child argument are undefined. - * - * Returns: %TRUE if the iterator could advance, and %FALSE otherwise - * - * Since: 3.90 - */ -gboolean -gsk_render_node_iter_next (GskRenderNodeIter *iter, - GskRenderNode **child) -{ - RealIter *riter = REAL_ITER (iter); - - g_return_val_if_fail (riter != NULL, FALSE); - g_return_val_if_fail (riter->root != NULL, FALSE); - g_return_val_if_fail (riter->root->age == riter->age, FALSE); - - if (riter->current == NULL) - riter->current = riter->root->first_child; - else - riter->current = riter->current->next_sibling; - - if (child != NULL) - *child = riter->current; - - return riter->current != NULL; -} - -/** - * gsk_render_node_iter_prev: - * @iter: a #GskRenderNodeIter - * @child: (out) (transfer none): return location for a #GskRenderNode - * - * Advances the @iter and retrieves the previous child of the root - * #GskRenderNode used to initialize the #GskRenderNodeIter. - * - * If the iterator could advance, this function returns %TRUE and sets the - * @child argument with the child #GskRenderNode. - * - * If the iterator could not advance, this function returns %FALSE and the - * contents of the @child argument are undefined. - * - * Returns: %TRUE if the iterator could advance, and %FALSE otherwise - * - * Since: 3.90 - */ -gboolean -gsk_render_node_iter_prev (GskRenderNodeIter *iter, - GskRenderNode **child) -{ - RealIter *riter = REAL_ITER (iter); - - g_return_val_if_fail (riter != NULL, FALSE); - g_return_val_if_fail (riter->root != NULL, FALSE); - g_return_val_if_fail (riter->root->age == riter->age, FALSE); - - if (riter->current == NULL) - riter->current = riter->root->last_child; - else - riter->current = riter->current->prev_sibling; - - if (child != NULL) - *child = riter->current; - - return riter->current != NULL; -} - -/** - * gsk_render_node_iter_remove: - * @iter: a #GskRenderNodeIter - * - * Removes the child #GskRenderNode currently being visited by - * the iterator. - * - * Calling this function on an invalid #GskRenderNodeIter results - * in undefined behavior. - * - * Since: 3.90 - */ -void -gsk_render_node_iter_remove (GskRenderNodeIter *iter) -{ - RealIter *riter = REAL_ITER (iter); - GskRenderNode *tmp; - - g_return_if_fail (riter != NULL); - g_return_if_fail (riter->root != NULL); - g_return_if_fail (riter->root->age == riter->age); - g_return_if_fail (riter->current != NULL); - - tmp = riter->current; - - if (tmp != NULL) - { - riter->current = tmp->prev_sibling; - - gsk_render_node_remove_child (riter->root, tmp); - - riter->age += 1; - - /* Safety net */ - g_assert (riter->age == riter->root->age); - } -} diff --git a/gsk/gskrendernodeiter.h b/gsk/gskrendernodeiter.h deleted file mode 100644 index 1342c1e4ec..0000000000 --- a/gsk/gskrendernodeiter.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __GSK_RENDER_NODE_ITER_H__ -#define __GSK_RENDER_NODE_ITER_H__ - -#include - -G_BEGIN_DECLS - -#define GSK_TYPE_RENDER_NODE_ITER (gsk_render_node_iter_get_type()) - -typedef struct _GskRenderNodeIter GskRenderNodeIter; - -struct _GskRenderNodeIter -{ - /*< private >*/ - gpointer dummy1; - gpointer dummy2; - gint64 dummy3; - gpointer dummy4; - gpointer dummy5; -}; - -GDK_AVAILABLE_IN_3_90 -GType gsk_render_node_iter_get_type (void) G_GNUC_CONST; -GDK_AVAILABLE_IN_3_90 -GskRenderNodeIter * gsk_render_node_iter_new (void); -GDK_AVAILABLE_IN_3_90 -void gsk_render_node_iter_free (GskRenderNodeIter *iter); -GDK_AVAILABLE_IN_3_90 -void gsk_render_node_iter_init (GskRenderNodeIter *iter, - GskRenderNode *node); - -GDK_AVAILABLE_IN_3_90 -gboolean gsk_render_node_iter_is_valid (GskRenderNodeIter *iter); -GDK_AVAILABLE_IN_3_90 -gboolean gsk_render_node_iter_prev (GskRenderNodeIter *iter, - GskRenderNode **child); -GDK_AVAILABLE_IN_3_90 -gboolean gsk_render_node_iter_next (GskRenderNodeIter *iter, - GskRenderNode **child); -GDK_AVAILABLE_IN_3_90 -void gsk_render_node_iter_remove (GskRenderNodeIter *iter); - -G_END_DECLS - -#endif /* GSK_RENDER_NODE_ITER_H */ diff --git a/gsk/gskvulkanrenderer.c b/gsk/gskvulkanrenderer.c index 0e6a04bbbb..08e94fc1c7 100644 --- a/gsk/gskvulkanrenderer.c +++ b/gsk/gskvulkanrenderer.c @@ -5,7 +5,6 @@ #include "gskdebugprivate.h" #include "gskprivate.h" #include "gskrendererprivate.h" -#include "gskrendernodeiter.h" #include "gskrendernodeprivate.h" #include "gsktextureprivate.h" #include "gskvulkanbufferprivate.h"