From 03235773be11073efba0a98cffca635f8b6678a6 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Tue, 14 Nov 2023 16:52:37 +0100 Subject: [PATCH] clutter/cleanup: Drop PaintNodes serialization Currently, nothing uses the dumped json of the paint nodes tree. So let us drop them in a separate commit so it can easily be reverted if someone ends up wanting to build a tool to consume and inspect the JSON. Part-of: --- clutter/clutter/clutter-actor.c | 8 - clutter/clutter/clutter-paint-node-private.h | 11 - clutter/clutter/clutter-paint-node.c | 152 ----------- clutter/clutter/clutter-paint-nodes.c | 253 ------------------- clutter/meson.build | 6 - meson.build | 2 - 6 files changed, 432 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index ca126e863..fab0d4fd3 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -3509,14 +3509,6 @@ clutter_actor_paint_node (ClutterActor *actor, if (clutter_paint_node_get_n_children (root) == 0) return FALSE; -#ifdef CLUTTER_ENABLE_DEBUG - if (CLUTTER_HAS_DEBUG (PAINT)) - { - /* dump the tree only if we have one */ - _clutter_paint_node_dump_tree (root); - } -#endif /* CLUTTER_ENABLE_DEBUG */ - clutter_paint_node_paint (root, paint_context); return TRUE; diff --git a/clutter/clutter/clutter-paint-node-private.h b/clutter/clutter/clutter-paint-node-private.h index c185b5efa..7a1332f4b 100644 --- a/clutter/clutter/clutter-paint-node-private.h +++ b/clutter/clutter/clutter-paint-node-private.h @@ -26,10 +26,6 @@ #include -#ifdef CLUTTER_ENABLE_DEBUG -#include -#endif - #include "clutter/clutter-backend.h" #include "clutter/clutter-paint-context.h" #include "clutter/clutter-paint-node.h" @@ -74,11 +70,6 @@ struct _ClutterPaintNodeClass ClutterPaintContext *paint_context); void (* post_draw) (ClutterPaintNode *node, ClutterPaintContext *paint_context); - -#ifdef CLUTTER_ENABLE_DEBUG - JsonNode*(* serialize) (ClutterPaintNode *node); -#endif - CoglFramebuffer *(* get_framebuffer) (ClutterPaintNode *node); }; @@ -122,8 +113,6 @@ ClutterPaintNode * _clutter_transform_node_new (const g ClutterPaintNode * _clutter_dummy_node_new (ClutterActor *actor, CoglFramebuffer *framebuffer); -void _clutter_paint_node_dump_tree (ClutterPaintNode *root); - G_GNUC_INTERNAL void clutter_paint_node_remove_child (ClutterPaintNode *node, ClutterPaintNode *child); diff --git a/clutter/clutter/clutter-paint-node.c b/clutter/clutter/clutter-paint-node.c index 08e497b39..354f82f07 100644 --- a/clutter/clutter/clutter-paint-node.c +++ b/clutter/clutter/clutter-paint-node.c @@ -52,10 +52,6 @@ #include #include -#ifdef CLUTTER_ENABLE_DEBUG -#include -#endif - #include "cogl/cogl.h" #include "clutter/clutter-paint-node-private.h" #include "clutter/clutter-debug.h" @@ -1044,154 +1040,6 @@ clutter_paint_node_paint (ClutterPaintNode *node, } } -#ifdef CLUTTER_ENABLE_DEBUG -static JsonNode * -clutter_paint_node_serialize (ClutterPaintNode *node) -{ - ClutterPaintNodeClass *klass = CLUTTER_PAINT_NODE_GET_CLASS (node); - - if (klass->serialize != NULL) - return klass->serialize (node); - - return json_node_new (JSON_NODE_NULL); -} - -static JsonNode * -clutter_paint_node_to_json (ClutterPaintNode *node) -{ - JsonBuilder *builder; - JsonNode *res; - - builder = json_builder_new (); - - json_builder_begin_object (builder); - - json_builder_set_member_name (builder, "type"); - json_builder_add_string_value (builder, g_type_name (G_TYPE_FROM_INSTANCE (node))); - - json_builder_set_member_name (builder, "name"); - json_builder_add_string_value (builder, node->name); - - json_builder_set_member_name (builder, "node-data"); - json_builder_add_value (builder, clutter_paint_node_serialize (node)); - - json_builder_set_member_name (builder, "operations"); - json_builder_begin_array (builder); - - if (node->operations != NULL) - { - guint i, j; - - for (i = 0; i < node->operations->len; i++) - { - const ClutterPaintOperation *op; - - op = &g_array_index (node->operations, ClutterPaintOperation, i); - json_builder_begin_object (builder); - - switch (op->opcode) - { - case PAINT_OP_TEX_RECT: - json_builder_set_member_name (builder, "texrect"); - json_builder_begin_array (builder); - json_builder_add_double_value (builder, op->op.texrect[0]); - json_builder_add_double_value (builder, op->op.texrect[1]); - json_builder_add_double_value (builder, op->op.texrect[2]); - json_builder_add_double_value (builder, op->op.texrect[3]); - json_builder_add_double_value (builder, op->op.texrect[4]); - json_builder_add_double_value (builder, op->op.texrect[5]); - json_builder_add_double_value (builder, op->op.texrect[6]); - json_builder_add_double_value (builder, op->op.texrect[7]); - json_builder_end_array (builder); - break; - - case PAINT_OP_TEX_RECTS: - json_builder_set_member_name (builder, "texrects"); - json_builder_begin_array (builder); - - for (j = 0; i < op->coords->len; j++) - { - float coord = g_array_index (op->coords, float, j); - json_builder_add_double_value (builder, coord); - } - - json_builder_end_array (builder); - break; - - case PAINT_OP_MULTITEX_RECT: - json_builder_set_member_name (builder, "texrect"); - json_builder_begin_array (builder); - - for (j = 0; i < op->coords->len; j++) - { - float coord = g_array_index (op->coords, float, j); - json_builder_add_double_value (builder, coord); - } - - json_builder_end_array (builder); - break; - - case PAINT_OP_PRIMITIVE: - json_builder_set_member_name (builder, "primitive"); - json_builder_add_int_value (builder, (intptr_t) op->op.primitive); - break; - - case PAINT_OP_INVALID: - break; - } - - json_builder_end_object (builder); - } - } - - json_builder_end_array (builder); - - json_builder_set_member_name (builder, "children"); - json_builder_begin_array (builder); - - if (node->first_child != NULL) - { - ClutterPaintNode *child; - - for (child = node->first_child; - child != NULL; - child = child->next_sibling) - { - JsonNode *n = clutter_paint_node_to_json (child); - - json_builder_add_value (builder, n); - } - } - - json_builder_end_array (builder); - - json_builder_end_object (builder); - - res = json_builder_get_root (builder); - - g_object_unref (builder); - - return res; -} -#endif /* CLUTTER_ENABLE_DEBUG */ - -void -_clutter_paint_node_dump_tree (ClutterPaintNode *node) -{ -#ifdef CLUTTER_ENABLE_DEBUG - JsonGenerator *gen = json_generator_new (); - char *str; - gsize len; - - json_generator_set_root (gen, clutter_paint_node_to_json (node)); - str = json_generator_to_data (gen, &len); - - g_print ("Render tree starting from %p:\n%s\n", node, str); - - g_free (str); -#endif /* CLUTTER_ENABLE_DEBUG */ -} - /*< private > * _clutter_paint_node_create: * @gtype: a #ClutterPaintNode type diff --git a/clutter/clutter/clutter-paint-nodes.c b/clutter/clutter/clutter-paint-nodes.c index 25ef795bc..3430f4a46 100644 --- a/clutter/clutter/clutter-paint-nodes.c +++ b/clutter/clutter/clutter-paint-nodes.c @@ -280,32 +280,6 @@ clutter_dummy_node_pre_draw (ClutterPaintNode *node, return TRUE; } -#ifdef CLUTTER_ENABLE_DEBUG -static JsonNode * -clutter_dummy_node_serialize (ClutterPaintNode *node) -{ - ClutterDummyNode *dnode = (ClutterDummyNode *) node; - JsonBuilder *builder; - JsonNode *res; - - if (dnode->actor == NULL) - return json_node_new (JSON_NODE_NULL); - - builder = json_builder_new (); - json_builder_begin_object (builder); - - json_builder_set_member_name (builder, "actor"); - json_builder_add_string_value (builder, _clutter_actor_get_debug_name (dnode->actor)); - - json_builder_end_object (builder); - - res = json_builder_get_root (builder); - g_object_unref (builder); - - return res; -} -#endif - static CoglFramebuffer * clutter_dummy_node_get_framebuffer (ClutterPaintNode *node) { @@ -330,9 +304,6 @@ clutter_dummy_node_class_init (ClutterDummyNodeClass *klass) ClutterPaintNodeClass *node_class = CLUTTER_PAINT_NODE_CLASS (klass); node_class->pre_draw = clutter_dummy_node_pre_draw; -#ifdef CLUTTER_ENABLE_DEBUG - node_class->serialize = clutter_dummy_node_serialize; -#endif node_class->get_framebuffer = clutter_dummy_node_get_framebuffer; node_class->finalize = clutter_dummy_node_finalize; } @@ -492,48 +463,6 @@ clutter_pipeline_node_post_draw (ClutterPaintNode *node, { } -#ifdef CLUTTER_ENABLE_DEBUG -static JsonNode * -clutter_pipeline_node_serialize (ClutterPaintNode *node) -{ - ClutterPipelineNode *pnode = CLUTTER_PIPELINE_NODE (node); - JsonBuilder *builder; - CoglColor color; - JsonNode *res; - - if (pnode->pipeline == NULL) - return json_node_new (JSON_NODE_NULL); - - builder = json_builder_new (); - json_builder_begin_object (builder); - - cogl_pipeline_get_color (pnode->pipeline, &color); - json_builder_set_member_name (builder, "color"); - json_builder_begin_array (builder); - json_builder_add_double_value (builder, cogl_color_get_red (&color)); - json_builder_add_double_value (builder, cogl_color_get_green (&color)); - json_builder_add_double_value (builder, cogl_color_get_blue (&color)); - json_builder_add_double_value (builder, cogl_color_get_alpha (&color)); - json_builder_end_array (builder); - -#if 0 - json_builder_set_member_name (builder, "layers"); - json_builder_begin_array (builder); - cogl_pipeline_foreach_layer (pnode->pipeline, - clutter_pipeline_node_serialize_layer, - builder); - json_builder_end_array (builder); -#endif - - json_builder_end_object (builder); - - res = json_builder_get_root (builder); - g_object_unref (builder); - - return res; -} -#endif - static void clutter_pipeline_node_class_init (ClutterPipelineNodeClass *klass) { @@ -544,9 +473,6 @@ clutter_pipeline_node_class_init (ClutterPipelineNodeClass *klass) node_class->draw = clutter_pipeline_node_draw; node_class->post_draw = clutter_pipeline_node_post_draw; node_class->finalize = clutter_pipeline_node_finalize; -#ifdef CLUTTER_ENABLE_DEBUG - node_class->serialize = clutter_pipeline_node_serialize; -#endif } static void @@ -873,49 +799,6 @@ clutter_text_node_draw (ClutterPaintNode *node, } } -#ifdef CLUTTER_ENABLE_DEBUG -static JsonNode * -clutter_text_node_serialize (ClutterPaintNode *node) -{ - ClutterTextNode *tnode = CLUTTER_TEXT_NODE (node); - JsonBuilder *builder; - JsonNode *res; - - builder = json_builder_new (); - - json_builder_begin_object (builder); - - json_builder_set_member_name (builder, "layout"); - - if (pango_layout_get_character_count (tnode->layout) > 12) - { - const char *text = pango_layout_get_text (tnode->layout); - char *str; - - str = g_strndup (text, 12); - json_builder_add_string_value (builder, str); - g_free (str); - } - else - json_builder_add_string_value (builder, pango_layout_get_text (tnode->layout)); - - json_builder_set_member_name (builder, "color"); - json_builder_begin_array (builder); - json_builder_add_double_value (builder, cogl_color_get_red (&tnode->color)); - json_builder_add_double_value (builder, cogl_color_get_green (&tnode->color)); - json_builder_add_double_value (builder, cogl_color_get_blue (&tnode->color)); - json_builder_add_double_value (builder, cogl_color_get_alpha (&tnode->color)); - json_builder_end_array (builder); - - json_builder_end_object (builder); - - res = json_builder_get_root (builder); - g_object_unref (builder); - - return res; -} -#endif - static void clutter_text_node_class_init (ClutterTextNodeClass *klass) { @@ -924,9 +807,6 @@ clutter_text_node_class_init (ClutterTextNodeClass *klass) node_class->pre_draw = clutter_text_node_pre_draw; node_class->draw = clutter_text_node_draw; node_class->finalize = clutter_text_node_finalize; -#ifdef CLUTTER_ENABLE_DEBUG - node_class->serialize = clutter_text_node_serialize; -#endif } static void @@ -1163,27 +1043,6 @@ clutter_actor_node_post_draw (ClutterPaintNode *node, } } -#ifdef CLUTTER_ENABLE_DEBUG -static JsonNode * -clutter_actor_node_serialize (ClutterPaintNode *node) -{ - ClutterActorNode *actor_node = CLUTTER_ACTOR_NODE (node); - g_autoptr (JsonBuilder) builder = NULL; - const char *debug_name; - - debug_name = _clutter_actor_get_debug_name (actor_node->actor); - - builder = json_builder_new (); - - json_builder_begin_object (builder); - json_builder_set_member_name (builder, "actor"); - json_builder_add_string_value (builder, debug_name); - json_builder_end_object (builder); - - return json_builder_get_root (builder); -} -#endif - static void clutter_actor_node_class_init (ClutterActorNodeClass *klass) { @@ -1193,9 +1052,6 @@ clutter_actor_node_class_init (ClutterActorNodeClass *klass) node_class->pre_draw = clutter_actor_node_pre_draw; node_class->draw = clutter_actor_node_draw; node_class->post_draw = clutter_actor_node_post_draw; -#ifdef CLUTTER_ENABLE_DEBUG - node_class->serialize = clutter_actor_node_serialize; -#endif } static void @@ -1251,48 +1107,9 @@ struct _ClutterEffectNodeClass G_DEFINE_TYPE (ClutterEffectNode, clutter_effect_node, CLUTTER_TYPE_PAINT_NODE) -#ifdef CLUTTER_ENABLE_DEBUG -static JsonNode * -clutter_effect_node_serialize (ClutterPaintNode *node) -{ - ClutterEffectNode *effect_node = CLUTTER_EFFECT_NODE (node); - ClutterActorMeta *effect_meta = CLUTTER_ACTOR_META (effect_node->effect); - g_autoptr (JsonBuilder) builder = NULL; - g_autoptr (GString) string = NULL; - const char *meta_name; - - meta_name = clutter_actor_meta_get_name (effect_meta); - - string = g_string_new (NULL); - g_string_append (string, G_OBJECT_TYPE_NAME (effect_node->effect)); - g_string_append (string, " ("); - if (meta_name) - g_string_append_printf (string, "\"%s\"", meta_name); - else - g_string_append (string, "unnamed"); - g_string_append (string, ")"); - - builder = json_builder_new (); - - json_builder_begin_object (builder); - json_builder_set_member_name (builder, "effect"); - json_builder_add_string_value (builder, string->str); - json_builder_end_object (builder); - - return json_builder_get_root (builder); -} -#endif - static void clutter_effect_node_class_init (ClutterEffectNodeClass *klass) { -#ifdef CLUTTER_ENABLE_DEBUG - - ClutterPaintNodeClass *node_class; - - node_class = CLUTTER_PAINT_NODE_CLASS (klass); - node_class->serialize = clutter_effect_node_serialize; -#endif } static void @@ -1455,27 +1272,6 @@ clutter_layer_node_finalize (ClutterPaintNode *node) CLUTTER_PAINT_NODE_CLASS (clutter_layer_node_parent_class)->finalize (node); } -#ifdef CLUTTER_ENABLE_DEBUG -static JsonNode * -clutter_layer_node_serialize (ClutterPaintNode *node) -{ - ClutterLayerNode *layer_node = CLUTTER_LAYER_NODE (node); - g_autoptr (JsonBuilder) builder = NULL; - g_autofree char *framebuffer_ptr = NULL; - - builder = json_builder_new (); - - framebuffer_ptr = g_strdup_printf ("%p", layer_node->offscreen); - - json_builder_begin_object (builder); - json_builder_set_member_name (builder, "framebuffer"); - json_builder_add_string_value (builder, framebuffer_ptr); - json_builder_end_object (builder); - - return json_builder_get_root (builder); -} -#endif - static void clutter_layer_node_class_init (ClutterLayerNodeClass *klass) { @@ -1485,9 +1281,6 @@ clutter_layer_node_class_init (ClutterLayerNodeClass *klass) node_class->pre_draw = clutter_layer_node_pre_draw; node_class->post_draw = clutter_layer_node_post_draw; node_class->finalize = clutter_layer_node_finalize; -#ifdef CLUTTER_ENABLE_DEBUG - node_class->serialize = clutter_layer_node_serialize; -#endif } static void @@ -1616,26 +1409,6 @@ clutter_blit_node_finalize (ClutterPaintNode *node) CLUTTER_PAINT_NODE_CLASS (clutter_blit_node_parent_class)->finalize (node); } -#ifdef CLUTTER_ENABLE_DEBUG -static JsonNode * -clutter_blit_node_serialize (ClutterPaintNode *node) -{ - ClutterBlitNode *blit_node = CLUTTER_BLIT_NODE (node); - g_autoptr (JsonBuilder) builder = NULL; - g_autofree char *src_ptr = NULL; - - src_ptr = g_strdup_printf ("%p", blit_node->src); - - builder = json_builder_new (); - json_builder_begin_object (builder); - json_builder_set_member_name (builder, "source"); - json_builder_add_string_value (builder, src_ptr); - json_builder_end_object (builder); - - return json_builder_get_root (builder); -} -#endif - static void clutter_blit_node_class_init (ClutterBlitNodeClass *klass) { @@ -1645,9 +1418,6 @@ clutter_blit_node_class_init (ClutterBlitNodeClass *klass) node_class->pre_draw = clutter_blit_node_pre_draw; node_class->draw = clutter_blit_node_draw; node_class->finalize = clutter_blit_node_finalize; -#ifdef CLUTTER_ENABLE_DEBUG - node_class->serialize = clutter_blit_node_serialize; -#endif } static void @@ -1754,26 +1524,6 @@ clutter_blur_node_finalize (ClutterPaintNode *node) CLUTTER_PAINT_NODE_CLASS (clutter_blur_node_parent_class)->finalize (node); } -#ifdef CLUTTER_ENABLE_DEBUG -static JsonNode * -clutter_blur_node_serialize (ClutterPaintNode *node) -{ - ClutterBlurNode *blur_node = CLUTTER_BLUR_NODE (node); - g_autoptr (JsonBuilder) builder = NULL; - g_autofree char *src_ptr = NULL; - - src_ptr = g_strdup_printf ("%d", blur_node->sigma); - - builder = json_builder_new (); - json_builder_begin_object (builder); - json_builder_set_member_name (builder, "sigma"); - json_builder_add_string_value (builder, src_ptr); - json_builder_end_object (builder); - - return json_builder_get_root (builder); -} -#endif - static void clutter_blur_node_class_init (ClutterBlurNodeClass *klass) { @@ -1782,9 +1532,6 @@ clutter_blur_node_class_init (ClutterBlurNodeClass *klass) node_class = CLUTTER_PAINT_NODE_CLASS (klass); node_class->post_draw = clutter_blur_node_post_draw; node_class->finalize = clutter_blur_node_finalize; -#ifdef CLUTTER_ENABLE_DEBUG - node_class->serialize = clutter_blur_node_serialize; -#endif } static void diff --git a/clutter/meson.build b/clutter/meson.build index cdb4bb4d2..97487eb72 100644 --- a/clutter/meson.build +++ b/clutter/meson.build @@ -44,12 +44,6 @@ clutter_pkg_private_deps = [ pangocairo_dep, ] -if get_option('debug') - clutter_pkg_private_deps += [ - json_glib_dep, - ] -endif - if have_pango_ft2 clutter_pkg_private_deps += [ pangoft2_dep, diff --git a/meson.build b/meson.build index d6be91e8b..ef45dd176 100644 --- a/meson.build +++ b/meson.build @@ -28,7 +28,6 @@ cairo_req = '>= 1.10.0' pangocairo_req = '>= 1.20' pixman_req = '>= 0.42' gsettings_desktop_schemas_req = '>= 40.alpha' -json_glib_req = '>= 0.12.0' x11_req = '>= 1.7.0' xcomposite_req = '>= 0.4' xkbcommon_req = '>= 0.4.3' @@ -123,7 +122,6 @@ gobject_dep = dependency('gobject-2.0', version: glib_req) gthread_dep = dependency('gobject-2.0', version: glib_req) gmodule_no_export_dep = dependency('gmodule-no-export-2.0', version: glib_req) gnome_settings_daemon_dep = dependency('gnome-settings-daemon', required: false) -json_glib_dep = dependency('json-glib-1.0', version: json_glib_req, required: get_option('debug')) xkbcommon_dep = dependency('xkbcommon', version: xkbcommon_req) ice_dep = dependency('ice') atk_dep = dependency('atk', version: atk_req)