forked from enlightenment/efl
Make Eina_Rectangle_Pool more usable.
SVN revision: 37275
This commit is contained in:
parent
4592044c82
commit
e243e4408a
|
@ -53,6 +53,10 @@ static inline void eina_rectangle_rescale_in(Eina_Rectangle *out, Eina_Rectangle
|
||||||
static inline void eina_rectangle_rescale_out(Eina_Rectangle *out, Eina_Rectangle *in, Eina_Rectangle *res);
|
static inline void eina_rectangle_rescale_out(Eina_Rectangle *out, Eina_Rectangle *in, Eina_Rectangle *res);
|
||||||
|
|
||||||
EAPI Eina_Rectangle_Pool *eina_rectangle_pool_add(int w, int h);
|
EAPI Eina_Rectangle_Pool *eina_rectangle_pool_add(int w, int h);
|
||||||
|
EAPI Eina_Rectangle_Pool *eina_rectangle_pool_get(Eina_Rectangle *rect);
|
||||||
|
EAPI Eina_Bool eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h);
|
||||||
|
EAPI void *eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool);
|
||||||
|
EAPI void eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data);
|
||||||
EAPI void eina_rectangle_pool_delete(Eina_Rectangle_Pool *pool);
|
EAPI void eina_rectangle_pool_delete(Eina_Rectangle_Pool *pool);
|
||||||
EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool *pool);
|
EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool *pool);
|
||||||
EAPI Eina_Rectangle *eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h);
|
EAPI Eina_Rectangle *eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h);
|
||||||
|
|
|
@ -45,6 +45,7 @@ struct _Eina_Rectangle_Pool
|
||||||
EINA_MAGIC;
|
EINA_MAGIC;
|
||||||
|
|
||||||
Eina_Inlist *head;
|
Eina_Inlist *head;
|
||||||
|
void *data;
|
||||||
|
|
||||||
unsigned int references;
|
unsigned int references;
|
||||||
int w;
|
int w;
|
||||||
|
@ -287,4 +288,50 @@ eina_rectangle_pool_release(Eina_Rectangle *rect)
|
||||||
MAGIC_FREE(era);
|
MAGIC_FREE(era);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Rectangle_Pool *
|
||||||
|
eina_rectangle_pool_get(Eina_Rectangle *rect)
|
||||||
|
{
|
||||||
|
Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *) rect) - 1;
|
||||||
|
|
||||||
|
if (!rect) return NULL;
|
||||||
|
|
||||||
|
EINA_MAGIC_CHECK_RECTANGLE_ALLOC(era);
|
||||||
|
EINA_MAGIC_CHECK_RECTANGLE_POOL(era->pool);
|
||||||
|
|
||||||
|
return era->pool;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data)
|
||||||
|
{
|
||||||
|
if (!pool) return ;
|
||||||
|
|
||||||
|
EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
|
||||||
|
|
||||||
|
pool->data = (void*) data;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void *
|
||||||
|
eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool)
|
||||||
|
{
|
||||||
|
if (!pool) return NULL;
|
||||||
|
|
||||||
|
EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
|
||||||
|
|
||||||
|
return pool->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h)
|
||||||
|
{
|
||||||
|
if (!pool) return EINA_FALSE;
|
||||||
|
|
||||||
|
EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
|
||||||
|
|
||||||
|
if (w) *w = pool->w;
|
||||||
|
if (h) *h = pool->h;
|
||||||
|
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,15 @@ START_TEST(eina_rectangle_pool)
|
||||||
Eina_Rectangle *rct;
|
Eina_Rectangle *rct;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
int w;
|
||||||
|
int h;
|
||||||
|
|
||||||
pool = eina_rectangle_pool_add(256, 256);
|
pool = eina_rectangle_pool_add(256, 256);
|
||||||
fail_if(pool == NULL);
|
fail_if(pool == NULL);
|
||||||
|
|
||||||
|
eina_rectangle_pool_data_set(pool, rects);
|
||||||
|
fail_if(eina_rectangle_pool_data_get(pool) != rects);
|
||||||
|
|
||||||
fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
|
fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
|
||||||
|
|
||||||
for (x = 0; x < 8; x++)
|
for (x = 0; x < 8; x++)
|
||||||
|
@ -47,6 +52,11 @@ START_TEST(eina_rectangle_pool)
|
||||||
|
|
||||||
fail_if(eina_rectangle_pool_count(pool) != 64);
|
fail_if(eina_rectangle_pool_count(pool) != 64);
|
||||||
|
|
||||||
|
fail_if(eina_rectangle_pool_get(rects[0][0]) != pool);
|
||||||
|
|
||||||
|
fail_if(eina_rectangle_pool_geometry_get(pool, &w, &h) != EINA_TRUE);
|
||||||
|
fail_if(w != 256 || h != 256);
|
||||||
|
|
||||||
fail_if(eina_rectangle_pool_request(pool, 32, 32) != NULL);
|
fail_if(eina_rectangle_pool_request(pool, 32, 32) != NULL);
|
||||||
fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
|
fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue