forked from enlightenment/efl
efl/eina: Eina_Tiler take tile size into account.
SVN revision: 83708
This commit is contained in:
parent
5d3e2e48d2
commit
e684f5a823
|
@ -1,3 +1,7 @@
|
||||||
|
2013-02-07 Cedric Bail
|
||||||
|
|
||||||
|
* eina: Eina_Tiler now take tile size into account.
|
||||||
|
|
||||||
2013-02-07 WooHyun Jung
|
2013-02-07 WooHyun Jung
|
||||||
|
|
||||||
* edje: Checking walking_callbacks for not removing patterns which are still used.
|
* edje: Checking walking_callbacks for not removing patterns which are still used.
|
||||||
|
|
1
NEWS
1
NEWS
|
@ -100,6 +100,7 @@ Improvements:
|
||||||
* Translations updates:
|
* Translations updates:
|
||||||
- french.
|
- french.
|
||||||
* edje entry : Support &, < and > in preedit string
|
* edje entry : Support &, < and > in preedit string
|
||||||
|
* eina: Eina_Tiler now take tile size into account.
|
||||||
|
|
||||||
Fixes:
|
Fixes:
|
||||||
* Fix a memory leak in ecore_con_dns when using ecore_con_server_connect
|
* Fix a memory leak in ecore_con_dns when using ecore_con_server_connect
|
||||||
|
|
|
@ -109,6 +109,8 @@ struct _Eina_Tiler
|
||||||
Eina_Rectangle area;
|
Eina_Rectangle area;
|
||||||
EINA_MAGIC
|
EINA_MAGIC
|
||||||
splitter_t splitter;
|
splitter_t splitter;
|
||||||
|
|
||||||
|
Eina_Bool rounding : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EINA_MAGIC_CHECK_TILER(d, ...) \
|
#define EINA_MAGIC_CHECK_TILER(d, ...) \
|
||||||
|
@ -1009,23 +1011,25 @@ static inline Eina_Bool _splitter_rect_add(Eina_Tiler *t, Eina_Rectangle *rect)
|
||||||
rect_node_t *rn;
|
rect_node_t *rn;
|
||||||
|
|
||||||
//printf("ACCOUNTING[1]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
|
//printf("ACCOUNTING[1]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
|
||||||
|
if (t->rounding)
|
||||||
|
{
|
||||||
rect->x >>= 1;
|
rect->x >>= 1;
|
||||||
rect->y >>= 1;
|
rect->y >>= 1;
|
||||||
rect->w += 2;
|
rect->w += 2;
|
||||||
rect->w >>= 1;
|
rect->w >>= 1;
|
||||||
rect->h += 2;
|
rect->h += 2;
|
||||||
rect->h >>= 1;
|
rect->h >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
rn = (rect_node_t *)rect_list_node_pool_get();
|
rn = (rect_node_t *)rect_list_node_pool_get();
|
||||||
rn->_lst = list_node_zeroed;
|
rn->_lst = list_node_zeroed;
|
||||||
rect_init(&rn->rect, rect->x, rect->y, rect->w, rect->h);
|
rect_init(&rn->rect, rect->x, rect->y, rect->w, rect->h);
|
||||||
//printf("ACCOUNTING[2]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
|
//printf("ACCOUNTING[2]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
|
||||||
//testing on my core2 duo desktop - fuzz of 32 or 48 is best.
|
//testing on my core2 duo desktop - fuzz of 32 or 48 is best.
|
||||||
#define FUZZ 32
|
|
||||||
rect_list_add_split_fuzzy_and_merge(&t->splitter.rects,
|
rect_list_add_split_fuzzy_and_merge(&t->splitter.rects,
|
||||||
(list_node_t *)rn,
|
(list_node_t *)rn,
|
||||||
FUZZ * FUZZ,
|
t->tile.w * t->tile.h,
|
||||||
FUZZ * FUZZ);
|
t->tile.w * t->tile.h);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1036,6 +1040,8 @@ static inline void _splitter_rect_del(Eina_Tiler *t, Eina_Rectangle *rect)
|
||||||
if (!t->splitter.rects.head)
|
if (!t->splitter.rects.head)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (t->rounding)
|
||||||
|
{
|
||||||
rect->x += 1;
|
rect->x += 1;
|
||||||
rect->y += 1;
|
rect->y += 1;
|
||||||
rect->x >>= 1;
|
rect->x >>= 1;
|
||||||
|
@ -1044,6 +1050,7 @@ static inline void _splitter_rect_del(Eina_Tiler *t, Eina_Rectangle *rect)
|
||||||
rect->w >>= 1;
|
rect->w >>= 1;
|
||||||
rect->h -= 1;
|
rect->h -= 1;
|
||||||
rect->h >>= 1;
|
rect->h >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((rect->w <= 0) || (rect->h <= 0))
|
if ((rect->w <= 0) || (rect->h <= 0))
|
||||||
return;
|
return;
|
||||||
|
@ -1073,10 +1080,20 @@ static Eina_Bool _iterator_next(Eina_Iterator_Tiler *it, void **data)
|
||||||
|
|
||||||
cur = ((rect_node_t *)n)->rect;
|
cur = ((rect_node_t *)n)->rect;
|
||||||
|
|
||||||
|
if (it->tiler->rounding)
|
||||||
|
{
|
||||||
it->r.x = cur.left << 1;
|
it->r.x = cur.left << 1;
|
||||||
it->r.y = cur.top << 1;
|
it->r.y = cur.top << 1;
|
||||||
it->r.w = cur.width << 1;
|
it->r.w = cur.width << 1;
|
||||||
it->r.h = cur.height << 1;
|
it->r.h = cur.height << 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
it->r.x = cur.left;
|
||||||
|
it->r.y = cur.top;
|
||||||
|
it->r.w = cur.width;
|
||||||
|
it->r.h = cur.height;
|
||||||
|
}
|
||||||
|
|
||||||
if (eina_rectangle_intersection(&it->r, &it->tiler->area) == EINA_FALSE)
|
if (eina_rectangle_intersection(&it->r, &it->tiler->area) == EINA_FALSE)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1121,8 +1138,9 @@ EAPI Eina_Tiler *eina_tiler_new(int w, int h)
|
||||||
t = calloc(1, sizeof(Eina_Tiler));
|
t = calloc(1, sizeof(Eina_Tiler));
|
||||||
t->area.w = w;
|
t->area.w = w;
|
||||||
t->area.h = h;
|
t->area.h = h;
|
||||||
t->tile.w = w;
|
t->tile.w = 32;
|
||||||
t->tile.h = h;
|
t->tile.h = 32;
|
||||||
|
t->rounding = EINA_TRUE;
|
||||||
EINA_MAGIC_SET(t, EINA_MAGIC_TILER);
|
EINA_MAGIC_SET(t, EINA_MAGIC_TILER);
|
||||||
_splitter_new(t);
|
_splitter_new(t);
|
||||||
return t;
|
return t;
|
||||||
|
@ -1144,6 +1162,7 @@ EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h)
|
||||||
if ((w <= 0) || (h <= 0))
|
if ((w <= 0) || (h <= 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (w == 1 || h == 1) t->rounding = EINA_FALSE;
|
||||||
t->tile.w = w;
|
t->tile.w = w;
|
||||||
t->tile.h = h;
|
t->tile.h = h;
|
||||||
_splitter_tile_size_set(t, w, h);
|
_splitter_tile_size_set(t, w, h);
|
||||||
|
@ -1216,7 +1235,7 @@ EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t)
|
||||||
sp = (splitter_t *)&(t->splitter);
|
sp = (splitter_t *)&(t->splitter);
|
||||||
to_merge = t->splitter.rects;
|
to_merge = t->splitter.rects;
|
||||||
sp->rects = list_zeroed;
|
sp->rects = list_zeroed;
|
||||||
rect_list_merge_rects(&sp->rects, &to_merge, FUZZ * FUZZ);
|
rect_list_merge_rects(&sp->rects, &to_merge, t->tile.w * t->tile.h);
|
||||||
sp->need_merge = 0;
|
sp->need_merge = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,9 +176,54 @@ START_TEST(eina_test_tiler_all)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(eina_test_tiler_stable)
|
||||||
|
{
|
||||||
|
Eina_Tiler *tl;
|
||||||
|
Eina_Rectangle *rp;
|
||||||
|
Eina_Iterator *it;
|
||||||
|
Eina_Rectangle r;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
eina_init();
|
||||||
|
|
||||||
|
tl = eina_tiler_new(640, 480);
|
||||||
|
fail_if(!tl);
|
||||||
|
|
||||||
|
eina_tiler_tile_size_set(tl, 1, 1);
|
||||||
|
|
||||||
|
EINA_RECTANGLE_SET(&r, 50, 50, 20, 20);
|
||||||
|
fail_if(!eina_tiler_rect_add(tl, &r));
|
||||||
|
|
||||||
|
EINA_RECTANGLE_SET(&r, 40, 40, 20, 20);
|
||||||
|
eina_tiler_rect_del(tl, &r);
|
||||||
|
|
||||||
|
it = eina_tiler_iterator_new(tl);
|
||||||
|
fail_if(!it);
|
||||||
|
|
||||||
|
EINA_ITERATOR_FOREACH(it, rp)
|
||||||
|
{
|
||||||
|
EINA_RECTANGLE_SET(&r, 40, 40, 20, 20);
|
||||||
|
fail_if(eina_rectangle_intersection(&r, rp));
|
||||||
|
|
||||||
|
EINA_RECTANGLE_SET(&r, 50, 50, 20, 20);
|
||||||
|
fail_if(!eina_rectangles_intersect(&r, rp));
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
fail_if(i != 2);
|
||||||
|
|
||||||
|
eina_iterator_free(it);
|
||||||
|
|
||||||
|
eina_tiler_free(tl);
|
||||||
|
|
||||||
|
eina_shutdown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
void
|
void
|
||||||
eina_test_tiler(TCase *tc)
|
eina_test_tiler(TCase *tc)
|
||||||
{
|
{
|
||||||
tcase_add_test(tc, eina_test_tile_grid_slicer_iterator);
|
tcase_add_test(tc, eina_test_tile_grid_slicer_iterator);
|
||||||
tcase_add_test(tc, eina_test_tiler_all);
|
tcase_add_test(tc, eina_test_tiler_all);
|
||||||
|
tcase_add_test(tc, eina_test_tiler_stable);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue