From 49a7a464f94c34ba006ce5f321125eb168c04173 Mon Sep 17 00:00:00 2001 From: cedric Date: Tue, 14 Apr 2009 09:27:27 +0000 Subject: [PATCH] * evas: Add a mempool. More speedup to come, depend on timing with "break" freeze. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@40037 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/canvas/evas_main.c | 16 ++++++++++ src/lib/canvas/evas_object_image.c | 53 ++++++++++------------------------ src/lib/canvas/evas_object_textblock.c | 20 ++----------- src/lib/canvas/evas_render.c | 24 +++++---------- src/lib/include/evas_private.h | 13 +++++---- 5 files changed, 50 insertions(+), 76 deletions(-) diff --git a/src/lib/canvas/evas_main.c b/src/lib/canvas/evas_main.c index 2958764..5534217 100644 --- a/src/lib/canvas/evas_main.c +++ b/src/lib/canvas/evas_main.c @@ -4,12 +4,28 @@ extern Eina_List *evas_modules; static int initcount = 0; +Eina_Mempool *_evas_rectangle_mp = NULL; + EAPI int evas_init(void) { if (initcount == 0) { + const char *choice; + eina_init(); + + if (!(choice = getenv("EINA_MEMPOOL"))) + choice = "chained_mempool"; + + _evas_rectangle_mp = eina_mempool_new(choice, "evas_rectangle", NULL, + sizeof (Evas_Rectangle), 42); + if (!_evas_rectangle_mp) + { + EINA_ERROR_PERR("ERROR: Mempool for rectangle cannot be allocated in list init.\n"); + abort(); + } + evas_module_init(); evas_async_events_init(); } diff --git a/src/lib/canvas/evas_object_image.c b/src/lib/canvas/evas_object_image.c index 8bec011..9ce1ce2 100644 --- a/src/lib/canvas/evas_object_image.c +++ b/src/lib/canvas/evas_object_image.c @@ -2070,6 +2070,7 @@ static void evas_object_image_free(Evas_Object *obj) { Evas_Object_Image *o; + Evas_Rectangle *r; /* frees private object data. very simple here */ o = (Evas_Object_Image *)(obj->object_data); @@ -2084,14 +2085,8 @@ evas_object_image_free(Evas_Object *obj) o->engine_data); o->engine_data = NULL; o->magic = 0; - while (o->pixel_updates) - { - Evas_Rectangle *r; - - r = (Evas_Rectangle *)o->pixel_updates->data; - o->pixel_updates = eina_list_remove(o->pixel_updates, r); - free(r); - } + EINA_LIST_FREE(o->pixel_updates, r) + eina_mempool_free(_evas_rectangle_mp, r); free(o); } @@ -2457,16 +2452,15 @@ evas_object_image_render_pre(Evas_Object *obj) (o->cur.border.t == 0) && (o->cur.border.b == 0)) { - while (o->pixel_updates) + Evas_Rectangle *rr; + + EINA_LIST_FREE(o->pixel_updates, rr) { - Evas_Rectangle *rr; Evas_Coord idw, idh, idx, idy; int x, y, w, h; - rr = o->pixel_updates->data; - o->pixel_updates = eina_list_remove(o->pixel_updates, rr); obj->layer->evas->engine.func->image_dirty_region(obj->layer->evas->engine.data.output, o->engine_data, rr->x, rr->y, rr->w, rr->h); - + idx = evas_object_image_figure_x_fill(obj, o->cur.fill.x, o->cur.fill.w, &idw); idy = evas_object_image_figure_y_fill(obj, o->cur.fill.y, o->cur.fill.h, &idh); @@ -2500,7 +2494,7 @@ evas_object_image_render_pre(Evas_Object *obj) idx += idw; idy = ydy; } - free(rr); + eina_mempool_free(_evas_rectangle_mp, rr); } goto done; } @@ -2508,14 +2502,10 @@ evas_object_image_render_pre(Evas_Object *obj) { if (o->pixel_updates) { - while (o->pixel_updates) - { - Evas_Rectangle *r; + Evas_Rectangle *r; - r = (Evas_Rectangle *)o->pixel_updates->data; - o->pixel_updates = eina_list_remove(o->pixel_updates, r); - free(r); - } + EINA_LIST_FREE(o->pixel_updates, r) + eina_mempool_free(_evas_rectangle_mp, r); obj->layer->evas->engine.func->image_dirty_region(obj->layer->evas->engine.data.output, o->engine_data, 0, 0, o->cur.image.w, o->cur.image.h); evas_object_render_pre_prev_cur_add(&rects, obj); goto done; @@ -2540,28 +2530,17 @@ static void evas_object_image_render_post(Evas_Object *obj) { Evas_Object_Image *o; + Evas_Rectangle *r; /* this moves the current data to the previous state parts of the object */ /* in whatever way is safest for the object. also if we don't need object */ /* data anymore we can free it if the object deems this is a good idea */ o = (Evas_Object_Image *)(obj->object_data); /* remove those pesky changes */ - while (obj->clip.changes) - { - Evas_Rectangle *r; - - r = (Evas_Rectangle *)obj->clip.changes->data; - obj->clip.changes = eina_list_remove(obj->clip.changes, r); - free(r); - } - while (o->pixel_updates) - { - Evas_Rectangle *r; - - r = (Evas_Rectangle *)o->pixel_updates->data; - o->pixel_updates = eina_list_remove(o->pixel_updates, r); - free(r); - } + EINA_LIST_FREE(obj->clip.changes, r) + eina_mempool_free(_evas_rectangle_mp, r); + EINA_LIST_FREE(o->pixel_updates, r) + eina_mempool_free(_evas_rectangle_mp, r); /* move cur to prev safely for object data */ obj->prev = obj->cur; o->prev = o->cur; diff --git a/src/lib/canvas/evas_object_textblock.c b/src/lib/canvas/evas_object_textblock.c index a1a8dd0..dd60dea 100644 --- a/src/lib/canvas/evas_object_textblock.c +++ b/src/lib/canvas/evas_object_textblock.c @@ -5511,15 +5511,6 @@ evas_object_textblock_render_pre(Evas_Object *obj) } if (o->changed) { -/* - Evas_Rectangle *r; - - r = malloc(sizeof(Evas_Rectangle)); - r->x = 0; r->y = 0; - r->w = obj->cur.geometry.w; - r->h = obj->cur.geometry.h; - updates = eina_list_append(updates, r); -*/ evas_object_render_pre_prev_cur_add(&rects, obj); o->changed = 0; } @@ -5531,20 +5522,15 @@ static void evas_object_textblock_render_post(Evas_Object *obj) { Evas_Object_Textblock *o; + Evas_Rectangle *r; /* this moves the current data to the previous state parts of the object */ /* in whatever way is safest for the object. also if we don't need object */ /* data anymore we can free it if the object deems this is a good idea */ o = (Evas_Object_Textblock *)(obj->object_data); /* remove those pesky changes */ - while (obj->clip.changes) - { - Evas_Rectangle *r; - - r = (Evas_Rectangle *)obj->clip.changes->data; - obj->clip.changes = eina_list_remove(obj->clip.changes, r); - free(r); - } + EINA_LIST_FREE(obj->clip.changes, r) + eina_mempool_free(_evas_rectangle_mp, r); /* move cur to prev safely for object data */ obj->prev = obj->cur; // o->prev = o->cur; diff --git a/src/lib/canvas/evas_render.c b/src/lib/canvas/evas_render.c index aac82b8..05f1bc1 100644 --- a/src/lib/canvas/evas_render.c +++ b/src/lib/canvas/evas_render.c @@ -18,9 +18,8 @@ evas_damage_rectangle_add(Evas *e, int x, int y, int w, int h) MAGIC_CHECK(e, Evas, MAGIC_EVAS); return; MAGIC_CHECK_END(); - r = malloc(sizeof(Evas_Rectangle)); + NEW_RECT(r, x, y, w, h); if (!r) return; - r->x = x; r->y = y; r->w = w; r->h = h; e->damages = eina_list_append(e->damages, r); e->changed = 1; } @@ -39,9 +38,8 @@ evas_obscured_rectangle_add(Evas *e, int x, int y, int w, int h) MAGIC_CHECK(e, Evas, MAGIC_EVAS); return; MAGIC_CHECK_END(); - r = malloc(sizeof(Evas_Rectangle)); + NEW_RECT(r, x, y, w, h); if (!r) return; - r->x = x; r->y = y; r->w = w; r->h = h; e->obscures = eina_list_append(e->obscures, r); } @@ -54,17 +52,13 @@ evas_obscured_rectangle_add(Evas *e, int x, int y, int w, int h) EAPI void evas_obscured_clear(Evas *e) { + Evas_Rectangle *r; + MAGIC_CHECK(e, Evas, MAGIC_EVAS); return; MAGIC_CHECK_END(); - while (e->obscures) - { - Evas_Rectangle *r; - - r = (Evas_Rectangle *)e->obscures->data; - e->obscures = eina_list_remove(e->obscures, r); - free(r); - } + EINA_LIST_FREE(e->obscures, r) + eina_mempool_free(_evas_rectangle_mp, r); } static void @@ -363,13 +357,11 @@ evas_render_updates_internal(Evas *e, unsigned char make_updates, unsigned char } eina_array_clean(&e->restack_objects); /* phase 3. add exposes */ - while (e->damages) + EINA_LIST_FREE(e->damages, r) { - r = e->damages->data; - e->damages = eina_list_remove(e->damages, r); e->engine.func->output_redraws_rect_add(e->engine.data.output, r->x, r->y, r->w, r->h); - free(r); + eina_mempool_free(_evas_rectangle_mp, r); } /* phase 4. output & viewport changes */ if (e->viewport.changed) diff --git a/src/lib/include/evas_private.h b/src/lib/include/evas_private.h index 0246fbc..13ea78f 100644 --- a/src/lib/include/evas_private.h +++ b/src/lib/include/evas_private.h @@ -85,12 +85,12 @@ MAGIC_CHECK_FAILED(o, t, m) #endif #define NEW_RECT(_r, _x, _y, _w, _h) \ -{(_r) = malloc(sizeof(Evas_Rectangle)); \ -if (_r) \ -{ \ - (_r)->x = (_x); (_r)->y = (_y); \ - (_r)->w = (_w); (_r)->h = (_h); \ -}} +{(_r) = eina_mempool_alloc(_evas_rectangle_mp, sizeof(Evas_Rectangle)); \ + if (_r) \ + { \ + (_r)->x = (_x); (_r)->y = (_y); \ + (_r)->w = (_w); (_r)->h = (_h); \ + }} #define MERR_NONE() _evas_alloc_error = EVAS_ALLOC_ERROR_NONE #define MERR_FATAL() _evas_alloc_error = EVAS_ALLOC_ERROR_FATAL @@ -783,6 +783,7 @@ void _evas_object_text_rehint(Evas_Object *obj); void _evas_object_textblock_rehint(Evas_Object *obj); extern int _evas_alloc_error; +extern Eina_Mempool *_evas_rectangle_mp; struct _Evas_Imaging_Image { -- 2.7.4