evas: use eo_data_get less. Use clipees_has if you want to know the number of child now.

This commit is contained in:
Cedric Bail 2013-04-11 13:21:54 +09:00
parent bf07af3e7b
commit e0f2ddadde
6 changed files with 97 additions and 45 deletions

View File

@ -4764,6 +4764,15 @@ EAPI void evas_object_clip_unset(Evas_Object *obj);
*/
EAPI const Eina_List *evas_object_clipees_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
/**
* Test if any object is clipped by @p obj.
*
* @param obj The object to get a list of clippees from
* @return EINA_TRUE if @p obj clip any object.
* @since 1.8
*/
EAPI Eina_Bool evas_object_clipees_has(const Evas_Object *eo_obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
/**
* Sets or unsets a given object as the currently focused one on its
* canvas.
@ -17483,6 +17492,7 @@ enum
EVAS_OBJ_SUB_ID_CLIP_GET,
EVAS_OBJ_SUB_ID_CLIP_UNSET,
EVAS_OBJ_SUB_ID_CLIPEES_GET,
EVAS_OBJ_SUB_ID_CLIPEES_HAS,
EVAS_OBJ_SUB_ID_MAP_ENABLE_SET,
EVAS_OBJ_SUB_ID_MAP_ENABLE_GET,
EVAS_OBJ_SUB_ID_MAP_SET,
@ -18135,6 +18145,17 @@ enum
*/
#define evas_obj_clipees_get(clipees) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CLIPEES_GET), EO_TYPECHECK(const Eina_List **, clipees)
/**
* @def evas_obj_clipees_has
* @since 1.8
* Return a list of objects currently clipped by @p obj.
*
* @param[out] clipees out
*
* @see evas_object_clipees_has
*/
#define evas_obj_clipees_has(clipees_has) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CLIPEES_HAS), EO_TYPECHECK(const Eina_Bool *, clipees_has)
/**
* @def evas_obj_focus_set
* @since 1.8

View File

@ -1,8 +1,8 @@
#include "evas_common.h"
#include "evas_private.h"
static void evas_object_event_callback_clear(Evas_Object *eo_obj);
static void evas_event_callback_clear(Evas *eo_e);
static void evas_object_event_callback_clear(Evas_Object_Protected_Data *obj);
static void evas_event_callback_clear(Evas_Public_Data *e);
int _evas_event_counter = 0;
EVAS_MEMPOOL(_mp_fn);
@ -170,9 +170,8 @@ evas_event_callback_list_post_free(Eina_Inlist **list)
}
static void
evas_object_event_callback_clear(Evas_Object *eo_obj)
evas_object_event_callback_clear(Evas_Object_Protected_Data *obj)
{
Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS);
if (!obj) return;
if (!obj->callbacks) return;
if (!obj->callbacks->deletions_waiting) return;
@ -186,9 +185,8 @@ evas_object_event_callback_clear(Evas_Object *eo_obj)
}
static void
evas_event_callback_clear(Evas *eo_e)
evas_event_callback_clear(Evas_Public_Data *e)
{
Evas_Public_Data *e = eo_data_get(eo_e, EVAS_CLASS);
if (!e) return;
if (!e->callbacks) return;
if (!e->callbacks->deletions_waiting) return;
@ -277,7 +275,7 @@ evas_event_callback_call(Evas *eo_e, Evas_Callback_Type type, void *event_info)
e->callbacks->walking_list--;
if (!e->callbacks->walking_list)
{
evas_event_callback_clear(eo_e);
evas_event_callback_clear(e);
l_mod = NULL;
}
}
@ -361,7 +359,7 @@ evas_object_event_callback_call(Evas_Object *eo_obj, Evas_Object_Protected_Data
obj->callbacks->walking_list--;
if (!obj->callbacks->walking_list)
{
evas_object_event_callback_clear(eo_obj);
evas_object_event_callback_clear(obj);
l_mod = NULL;
}
@ -477,7 +475,7 @@ evas_object_event_callback_del(Evas_Object *eo_obj, Evas_Callback_Type type, Eva
fn->delete_me = 1;
obj->callbacks->deletions_waiting = 1;
if (!obj->callbacks->walking_list)
evas_object_event_callback_clear(eo_obj);
evas_object_event_callback_clear(obj);
return tmp;
}
}
@ -510,7 +508,7 @@ evas_object_event_callback_del_full(Evas_Object *eo_obj, Evas_Callback_Type type
fn->delete_me = 1;
obj->callbacks->deletions_waiting = 1;
if (!obj->callbacks->walking_list)
evas_object_event_callback_clear(eo_obj);
evas_object_event_callback_clear(obj);
return tmp;
}
}
@ -585,7 +583,7 @@ evas_event_callback_del(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb func)
fn->delete_me = 1;
e->callbacks->deletions_waiting = 1;
if (!e->callbacks->walking_list)
evas_event_callback_clear(eo_e);
evas_event_callback_clear(e);
return data;
}
}
@ -618,7 +616,7 @@ evas_event_callback_del_full(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb
fn->delete_me = 1;
e->callbacks->deletions_waiting = 1;
if (!e->callbacks->walking_list)
evas_event_callback_clear(eo_e);
evas_event_callback_clear(e);
return tmp;
}
}

View File

@ -4,9 +4,8 @@
void
evas_object_clip_dirty(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
{
Evas_Object_Protected_Data *clipee;
Eina_List *l;
Evas_Object *data;
Evas_Object_Protected_Data *clipee = NULL;
if (obj->cur->cache.clip.dirty) return;
@ -16,25 +15,23 @@ evas_object_clip_dirty(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Da
}
EINA_COW_STATE_WRITE_END(obj, state_write, cur);
EINA_LIST_FOREACH(obj->clip.clipees, l, data)
EINA_LIST_FOREACH(obj->clip.clipees, l, clipee)
{
clipee = eo_data_get(data, EVAS_OBJ_CLASS);
evas_object_clip_dirty(data, clipee);
evas_object_clip_dirty(clipee->object, clipee);
}
}
void
evas_object_recalc_clippees(Evas_Object_Protected_Data *obj)
{
Evas_Object_Protected_Data *clipee;
Eina_List *l;
Evas_Object *data;
if (obj->cur->cache.clip.dirty)
{
evas_object_clip_recalc(obj);
EINA_LIST_FOREACH(obj->clip.clipees, l, data)
EINA_LIST_FOREACH(obj->clip.clipees, l, clipee)
{
Evas_Object_Protected_Data *clipee = eo_data_get(data, EVAS_OBJ_CLASS);
evas_object_recalc_clippees(clipee);
}
}
@ -120,13 +117,12 @@ evas_object_child_map_across_mark(Evas_Object *eo_obj, Evas_Object_Protected_Dat
}
else if (obj->clip.clipees)
{
Evas_Object_Protected_Data *obj2;
Eina_List *l;
Evas_Object *eo_obj2;
EINA_LIST_FOREACH(obj->clip.clipees, l, eo_obj2)
EINA_LIST_FOREACH(obj->clip.clipees, l, obj2)
{
Evas_Object_Protected_Data *obj2 = eo_data_get(eo_obj2, EVAS_OBJ_CLASS);
evas_object_child_map_across_mark(eo_obj2, obj2, map_obj, force);
evas_object_child_map_across_mark(obj2->object, obj2, map_obj, force);
}
}
}
@ -147,8 +143,8 @@ void
evas_object_clip_across_clippees_check(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
{
#ifdef MAP_ACROSS
Evas_Object_Protected_Data *obj2;
Eina_List *l;
Evas_Object *eo_obj2;
if (!obj->clip.clipees) return;
// schloooooooooooow:
@ -157,10 +153,9 @@ evas_object_clip_across_clippees_check(Evas_Object *eo_obj, Evas_Object_Protecte
evas_object_child_map_across_mark(eo_obj, obj, obj->map->cur.map_parent, 0);
if (obj->cur->cache.clip.dirty)
{
EINA_LIST_FOREACH(obj->clip.clipees, l, eo_obj2)
EINA_LIST_FOREACH(obj->clip.clipees, l, obj2)
{
Evas_Object_Protected_Data *obj2 = eo_data_get(eo_obj2, EVAS_OBJ_CLASS);
evas_object_clip_across_clippees_check(eo_obj2, obj2);
evas_object_clip_across_clippees_check(obj2->object, obj2);
}
}
#endif
@ -265,7 +260,8 @@ _clip_set(Eo *eo_obj, void *_pd, va_list *list)
if (obj->cur->clipper)
{
/* unclip */
obj->cur->clipper->clip.clipees = eina_list_remove(obj->cur->clipper->clip.clipees, eo_obj);
obj->cur->clipper->clip.cache_clipees_answer = eina_list_free(obj->cur->clipper->clip.cache_clipees_answer);
obj->cur->clipper->clip.clipees = eina_list_remove(obj->cur->clipper->clip.clipees, obj);
if (!obj->cur->clipper->clip.clipees)
{
EINA_COW_STATE_WRITE_BEGIN(obj->cur->clipper, state_write, cur)
@ -306,7 +302,8 @@ _clip_set(Eo *eo_obj, void *_pd, va_list *list)
}
EINA_COW_STATE_WRITE_END(obj, state_write, cur);
clip->clip.clipees = eina_list_append(clip->clip.clipees, eo_obj);
clip->clip.cache_clipees_answer = eina_list_free(clip->clip.cache_clipees_answer);
clip->clip.clipees = eina_list_append(clip->clip.clipees, obj);
if (clip->clip.clipees)
{
EINA_COW_STATE_WRITE_BEGIN(clip, state_write, cur)
@ -383,6 +380,9 @@ _clip_unset(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)
Evas_Object_Protected_Data *obj = _pd;
if (!obj->cur->clipper) return;
obj->clip.cache_clipees_answer = eina_list_free(obj->clip.cache_clipees_answer);
/* unclip */
if (evas_object_intercept_call_clip_unset(eo_obj)) return;
if (obj->is_smart)
@ -391,7 +391,7 @@ _clip_unset(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)
}
if (obj->cur->clipper)
{
obj->cur->clipper->clip.clipees = eina_list_remove(obj->cur->clipper->clip.clipees, eo_obj);
obj->cur->clipper->clip.clipees = eina_list_remove(obj->cur->clipper->clip.clipees, obj);
if (!obj->cur->clipper->clip.clipees)
{
EINA_COW_STATE_WRITE_BEGIN(obj->cur->clipper, state_write, cur)
@ -448,7 +448,34 @@ void
_clipees_get(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
{
const Eina_List **clipees = va_arg(*list, const Eina_List **);
const Evas_Object_Protected_Data *obj = _pd;
*clipees = obj->clip.clipees;
Evas_Object_Protected_Data *obj = _pd;
const Evas_Object_Protected_Data *tmp;
Eina_List *l;
Eina_List *answer = NULL;
obj->clip.cache_clipees_answer = eina_list_free(obj->clip.cache_clipees_answer);
EINA_LIST_FOREACH(obj->clip.clipees, l, tmp)
answer = eina_list_append(answer, tmp);
*clipees = answer;
obj->clip.cache_clipees_answer = answer;
}
EAPI Eina_Bool
evas_object_clipees_has(const Evas_Object *eo_obj)
{
Eina_Bool r;
eo_do((Eo *)eo_obj, evas_obj_clipees_has(&r));
return r;
}
void
_clipees_has(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
{
Eina_Bool *r = va_arg(*list, Eina_Bool *);
Evas_Object_Protected_Data *obj = _pd;
*r = obj->clip.clipees ? EINA_TRUE : EINA_FALSE;
}

View File

@ -173,6 +173,7 @@ evas_object_free(Evas_Object *eo_obj, int clean_layer)
if (!was_smart_child) evas_object_release(eo_obj, obj, obj->clean_layer);
if (obj->clip.clipees)
eina_list_free(obj->clip.clipees);
obj->clip.cache_clipees_answer = eina_list_free(obj->clip.cache_clipees_answer);
evas_object_clip_changes_clean(eo_obj);
evas_object_event_callback_all_del(eo_obj);
evas_object_event_callback_cleanup(eo_obj);
@ -200,6 +201,7 @@ void
evas_object_change(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
{
Eina_List *l;
Evas_Object_Protected_Data *obj2;
Evas_Object *eo_obj2;
Eina_Bool movch = EINA_FALSE;
@ -219,17 +221,16 @@ evas_object_change(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
/* set changed flag on all objects this one clips too */
if (!((movch) && (obj->is_static_clip)))
{
EINA_LIST_FOREACH(obj->clip.clipees, l, eo_obj2)
EINA_LIST_FOREACH(obj->clip.clipees, l, obj2)
{
Evas_Object_Protected_Data *obj2 = eo_data_get(eo_obj2, MY_CLASS);
if (!obj2) continue;
evas_object_change(eo_obj2, obj2);
evas_object_change(obj2->object, obj2);
}
}
EINA_LIST_FOREACH(obj->proxy->proxies, l, eo_obj2)
{
Evas_Object_Protected_Data *obj2 = eo_data_get(eo_obj2, MY_CLASS);
if (!obj2) continue;
obj2 = eo_data_get(eo_obj2, MY_CLASS);
if (!obj2) continue;
evas_object_change(eo_obj2, obj2);
}
if (obj->smart.parent)
@ -605,6 +606,7 @@ _destructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)
return;
MAGIC_CHECK_END();
Evas_Object_Protected_Data *obj = _pd;
Evas_Object_Protected_Data *tmp;
evas_object_hide(eo_obj);
if (obj->focused)
@ -635,8 +637,8 @@ _destructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)
goto end;
}
evas_object_grabs_cleanup(eo_obj, obj);
while (obj->clip.clipees)
evas_object_clip_unset(obj->clip.clipees->data);
EINA_LIST_FREE(obj->clip.clipees, tmp)
evas_object_clip_unset(tmp->object);
while (obj->proxy->proxies)
evas_object_image_source_unset(obj->proxy->proxies->data);
if (obj->cur->clipper) evas_object_clip_unset(eo_obj);
@ -1904,9 +1906,9 @@ _dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
eo_do(eo_obj, evas_obj_propagate_events_get(&event));
EO_DBG_INFO_APPEND(group, "Propagate Events", EINA_VALUE_TYPE_CHAR, event);
const Eina_List *clipees;
eo_do(eo_obj, evas_obj_clipees_get(&clipees));
EO_DBG_INFO_APPEND(group, "Has clipees", EINA_VALUE_TYPE_CHAR, (Eina_Bool) (!!clipees));
const Eina_Bool clipees_has;
eo_do(eo_obj, evas_obj_clipees_has(&clipees_has));
EO_DBG_INFO_APPEND(group, "Has clipees", EINA_VALUE_TYPE_CHAR, clipees_has);
const Evas_Map *map = evas_object_map_get(eo_obj);
if (map)
@ -2461,6 +2463,7 @@ _class_constructor(Eo_Class *klass)
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CLIP_GET), _clip_get),
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CLIP_UNSET), _clip_unset),
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CLIPEES_GET), _clipees_get),
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CLIPEES_HAS), _clipees_has),
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_MAP_ENABLE_SET), _map_enable_set),
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_MAP_ENABLE_GET), _map_enable_get),
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_MAP_SET), _map_set),
@ -2543,6 +2546,7 @@ static const Eo_Op_Description op_desc[] = {
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_CLIP_GET, "Get the object clipping obj (if any)."),
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_CLIP_UNSET, "Disable/cease clipping on a clipped obj object."),
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_CLIPEES_GET, "Return a list of objects currently clipped by obj."),
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_CLIPEES_HAS, "Return EINA_TRUE if there is any object is clipped by obj."),
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_MAP_ENABLE_SET, "Enable or disable the map that is set."),
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_MAP_ENABLE_GET, "Get the map enabled state"),
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_MAP_SET, "Set current object transformation map."),

View File

@ -144,7 +144,7 @@ static void
evas_object_smart_clipped_smart_show(Evas_Object *eo_obj)
{
CSO_DATA_GET_OR_RETURN(eo_obj, cso);
if (evas_object_clipees_get(cso->clipper))
if (evas_object_clipees_has(cso->clipper))
evas_object_show(cso->clipper); /* just show if clipper being used */
}

View File

@ -584,6 +584,7 @@ struct _Evas_Object_Protected_Data
struct {
Eina_List *clipees;
Eina_List *cache_clipees_answer;
Eina_List *changes;
} clip;
@ -1107,6 +1108,7 @@ void _clip_set(Eo *obj, void *_pd, va_list *list);
void _clip_get(Eo *obj, void *_pd, va_list *list);
void _clip_unset(Eo *obj, void *_pd, va_list *list);
void _clipees_get(Eo *obj, void *_pd, va_list *list);
void _clipees_has(Eo *obj, void *_pd, va_list *list);
void _map_enable_set(Eo *obj, void *_pd, va_list *list);
void _map_enable_get(Eo *obj, void *_pd, va_list *list);
void _map_source_set(Eo *obj, void *_pd, va_list *list);