tasn pushed a commit to branch master. http://git.enlightenment.org/tools/clouseau.git/commit/?id=e764f9552f08e272d0be443d784e747bbafe90ea
commit e764f9552f08e272d0be443d784e747bbafe90ea Author: Tom Hacohen <t...@stosb.com> Date: Tue Dec 31 15:13:46 2013 +0000 Canvas Sanity Checker: Implemented first version. This is as requested by Mike T660. I think the logic doesn't make sense, but I implemented it as requested. This fixes T660. --- src/modules/client/canvas_checker.c | 130 ++++++++++++++++++++++++++++++++++-- 1 file changed, 126 insertions(+), 4 deletions(-) diff --git a/src/modules/client/canvas_checker.c b/src/modules/client/canvas_checker.c index 8143039..ff82bb1 100644 --- a/src/modules/client/canvas_checker.c +++ b/src/modules/client/canvas_checker.c @@ -11,7 +11,7 @@ EAPI const char *clouseau_module_name = "Canvas Sanity Checker"; static Eina_Bool _init(void) { - return EINA_FALSE; + return EINA_TRUE; } static void @@ -19,15 +19,137 @@ _shutdown(void) { } -EAPI void clouseau_client_module_run(Eina_List *tree) +typedef struct { + Clouseau_Tree_Item *ptr; + Clouseau_Tree_Item *parent; +} Clipper_Info; + +typedef struct { + Clouseau_Tree_Item *ptr; + Clouseau_Tree_Item *parent; + uint64_t clipper; +} Clippee_Info; + +typedef struct { + Eina_Hash *clippers; + Eina_List *clippees; +} Context; + +static void +_hash_clipper_free_cb(void *data) +{ + free(data); +} + +static uint64_t +_treeit_clipee_is(Clouseau_Tree_Item *treeit) +{ + Eina_List *l; + Eo_Dbg_Info *eo_root, *eo; + Eina_Value_List eo_list; + clouseau_tree_item_from_legacy_convert(treeit); + eo_root = treeit->new_eo_info; + + eina_value_pget(&(eo_root->value), &eo_list); + + EINA_LIST_FOREACH(eo_list.list, l, eo) + { + if (!strcmp(eo->name, "Evas_Object")) + { + Eina_Value_List eo_list2; + Eina_List *l2; + eina_value_pget(&(eo->value), &eo_list2); + EINA_LIST_FOREACH(eo_list2.list, l2, eo) + { + if (!strcmp(eo->name, "Clipper")) + { + uint64_t ptr = 0; + eina_value_get(&(eo->value), &ptr); + + return ptr; + } + } + + return 0; + } + } + + return 0; +} + + +static void +_treeit_clipper_clipee_recursively_add(Context *ctx, Clouseau_Tree_Item *parent) { Clouseau_Tree_Item *treeit; Eina_List *l; + + EINA_LIST_FOREACH(parent->children, l, treeit) + { + uint64_t ptr; + if (treeit->is_clipper) + { + Clipper_Info *info = calloc(1, sizeof(*info)); + info->ptr = treeit; + info->parent = parent; + + eina_hash_add(ctx->clippers, &info->ptr->ptr, info); + } + else if ((ptr = _treeit_clipee_is(treeit))) + { + Clippee_Info *info = calloc(1, sizeof(*info)); + info->ptr = treeit; + info->parent = parent; + info->clipper = ptr; + + ctx->clippees = eina_list_append(ctx->clippees, info); + } + + _treeit_clipper_clipee_recursively_add(ctx, treeit); + } +} + +EAPI void +clouseau_client_module_run(Eina_List *tree) +{ + Context ctx; + ctx.clippers = eina_hash_int64_new(_hash_clipper_free_cb); + ctx.clippees = NULL; + + /* Gather the information from the tree. */ + Clouseau_Tree_Item *treeit; + Eina_List *l; EINA_LIST_FOREACH(tree, l, treeit) { - if (treeit) - return; + _treeit_clipper_clipee_recursively_add(&ctx, treeit); } + + /* Analyze the information. */ + Clippee_Info *info; + EINA_LIST_FOREACH(ctx.clippees, l, info) + { + Clipper_Info *clipper = eina_hash_find(ctx.clippers, &info->clipper); + + if (!clipper) + { + printf("Error! Object: %llx. Can't find clipper '%llx'\n", (unsigned long long) info->ptr->ptr, (unsigned long long) info->clipper); + } + else if (clipper->parent != info->parent) + { + printf("Error! Object's (%llx) parent (%llx) != Clipper's (%llx) parent (%llx)\n", info->ptr->ptr, info->parent->ptr, clipper->ptr->ptr, clipper->parent->ptr); + } + } + + printf("Finished running '%s'\n", clouseau_module_name); + + /* Clear the data. */ + { + void *data; + + eina_hash_free(ctx.clippers); + EINA_LIST_FREE(ctx.clippees, data) + free(data); + } } EINA_MODULE_INIT(_init); --