From 5ac7b84136b2e13b975aa65483d9ba42db7ab399 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Wed, 4 Apr 2007 09:55:40 +0000 Subject: [PATCH] pager urgent popup patch - good evas clipouts less allocs patch - definite spedusp for when it's used heavily! SVN revision: 29331 --- .../src/lib/engines/common/evas_draw_main.c | 381 +++++++++--------- .../evas/src/lib/engines/common/evas_pipe.c | 19 +- .../lib/engines/common/evas_rectangle_main.c | 13 +- .../lib/engines/common/evas_scale_sample.c | 13 +- .../lib/engines/common/evas_scale_smooth.c | 13 +- legacy/evas/src/lib/include/evas_common.h | 30 +- .../engines/directfb/evas_engine_dfb.c | 11 +- .../engines/xrender_x11/evas_engine_xrender.c | 18 +- .../engines/xrender_xcb/evas_engine_xrender.c | 14 +- 9 files changed, 249 insertions(+), 263 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_draw_main.c b/legacy/evas/src/lib/engines/common/evas_draw_main.c index e67ddd02b0..9a6e9141bd 100644 --- a/legacy/evas/src/lib/engines/common/evas_draw_main.c +++ b/legacy/evas/src/lib/engines/common/evas_draw_main.c @@ -1,5 +1,57 @@ #include "evas_common.h" +EAPI Cutout_Rects* +evas_common_draw_context_cutouts_new() +{ + Cutout_Rects *rects; + + rects = malloc(sizeof(Cutout_Rects)); + rects->rects = NULL; + rects->active = 0; + rects->max = 0; + + return rects; +} + +EAPI void +evas_common_draw_context_cutouts_free(Cutout_Rects* rects) +{ + rects->active = 0; +} + +EAPI Cutout_Rect* +evas_common_draw_context_cutouts_add(Cutout_Rects* rects, + int x, int y, int w, int h) +{ + Cutout_Rect* rect; + + if (rects->max < rects->active + 1) { + rects->max += 8; + rects->rects = realloc(rects->rects, sizeof(Cutout_Rect) * rects->max); + } + + rect = rects->rects + rects->active++; + rect->x = x; + rect->y = y; + rect->w = w; + rect->h = h; + + return rect; +} + +EAPI void +evas_common_draw_context_cutouts_del(Cutout_Rects* rects, + int index) +{ + if (index >= 0 && index < rects->active) + { + Cutout_Rect* rect = rects->rects + index; + + memmove(rect, rect + 1, sizeof (Cutout_Rect) * (rects->active - index - 1)); + rects->active--; + } +} + void evas_common_init(void) { @@ -43,9 +95,16 @@ evas_common_draw_context_new(void) EAPI void evas_common_draw_context_free(RGBA_Draw_Context *dc) { + evas_common_draw_context_apply_clean_cutouts(&dc->cutout); free(dc); } +EAPI void +evas_common_draw_context_clear_cutouts(RGBA_Draw_Context *dc) +{ + evas_common_draw_context_apply_clean_cutouts(&dc->cutout); +} + EAPI void evas_common_draw_context_font_ext_set(RGBA_Draw_Context *dc, void *data, @@ -115,113 +174,34 @@ evas_common_draw_context_unset_multiplier(RGBA_Draw_Context *dc) EAPI void evas_common_draw_context_add_cutout(RGBA_Draw_Context *dc, int x, int y, int w, int h) { - Cutout_Rect *r; - - r = calloc(1, sizeof(Cutout_Rect)); - r->x = x; - r->y = y; - r->w = w; - r->h = h; - dc->cutout.rects = evas_object_list_append(dc->cutout.rects, r); + evas_common_draw_context_cutouts_add(&dc->cutout, x, y, w, h); } -EAPI void -evas_common_draw_context_clear_cutouts(RGBA_Draw_Context *dc) -{ - evas_common_draw_context_apply_free_cutouts(dc->cutout.rects); - dc->cutout.rects = NULL; -} - -EAPI Cutout_Rect * -evas_common_draw_context_apply_cutouts(RGBA_Draw_Context *dc) -{ - Cutout_Rect *r, *rects; - Evas_Object_List *l; - - if (!dc->clip.use) return NULL; - if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) return NULL; - r = calloc(1, sizeof(Cutout_Rect)); - r->x = dc->clip.x; - r->y = dc->clip.y; - r->w = dc->clip.w; - r->h = dc->clip.h; - rects = r; - for (l = (Evas_Object_List *)dc->cutout.rects; l; l = l->next) - { - r = (Cutout_Rect *)l; - rects = evas_common_draw_context_cutouts_split(rects, r); - } - return rects; -} - -EAPI void -evas_common_draw_context_apply_free_cutouts(Cutout_Rect *rects) -{ - while (rects) - { - Cutout_Rect *r; - - r = rects; - rects = evas_object_list_remove(rects, rects); - free(r); - } -} - -EAPI Cutout_Rect * -evas_common_draw_context_cutouts_split(Cutout_Rect *in, Cutout_Rect *split) -{ - /* multiple rect in, multiple out */ - Cutout_Rect *out; - Evas_Object_List *l; - - out = NULL; - for (l = (Evas_Object_List *)in; l; l = l->next) - { - Cutout_Rect *r; - - r = (Cutout_Rect *)l; - r = evas_common_draw_context_cutout_split(r, split); - while (r) - { - Cutout_Rect *r2; - - r2 = r; - r = evas_object_list_remove(r, r); - out = evas_object_list_append(out, r2); - } - } - evas_common_draw_context_apply_free_cutouts(in); - return out; -} - -EAPI Cutout_Rect * -evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) +int +evas_common_draw_context_cutout_split(Cutout_Rects* res, int index, Cutout_Rect *split) { /* 1 input rect, multiple out */ - Cutout_Rect *out; - Cutout_Rect *r; + Cutout_Rect in = res->rects[index]; /* this is to save me a LOT of typing */ -#define INX1 (in->x) -#define INX2 (in->x + in->w) +#define INX1 (in.x) +#define INX2 (in.x + in.w) #define SPX1 (split->x) #define SPX2 (split->x + split->w) -#define INY1 (in->y) -#define INY2 (in->y + in->h) +#define INY1 (in.y) +#define INY2 (in.y + in.h) #define SPY1 (split->y) #define SPY2 (split->y + split->h) -#define X1_IN (in->x < split->x) -#define X2_IN ((in->x + in->w) > (split->x + split->w)) -#define Y1_IN (in->y < split->y) -#define Y2_IN ((in->y + in->h) > (split->y + split->h)) -#define R_NEW(_r, _x, _y, _w, _h) {(_r) = calloc(1, sizeof(Cutout_Rect)); (_r)->x = (_x); (_r)->y = (_y); (_r)->w = (_w); (_r)->h = (_h);} - out = NULL; - if (!RECTS_INTERSECT(in->x, in->y, in->w, in->h, +#define X1_IN (in.x < split->x) +#define X2_IN ((in.x + in.w) > (split->x + split->w)) +#define Y1_IN (in.y < split->y) +#define Y2_IN ((in.y + in.h) > (split->y + split->h)) +#define R_NEW(_r, _x, _y, _w, _h) { evas_common_draw_context_cutouts_add(_r, _x, _y, _w, _h); } + if (!RECTS_INTERSECT(in.x, in.y, in.w, in.h, split->x, split->y, split->w, split->h)) { - R_NEW(r, in->x, in->y, in->w, in->h); - out = evas_object_list_append(out, r); - return out; + /* No colision => no clipping, don't touch it. */ + return 1; } /* S = split (ie cut out rect) */ @@ -237,15 +217,13 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (X1_IN && X2_IN && Y1_IN && Y2_IN) { - R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); - out = evas_object_list_append(out, r); - R_NEW(r, in->x, SPY1, SPX1 - in->x, SPY2 - SPY1); - out = evas_object_list_append(out, r); - R_NEW(r, SPX2, SPY1, INX2 - SPX2, SPY2 - SPY1); - out = evas_object_list_append(out, r); - R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); - out = evas_object_list_append(out, r); - return out; + R_NEW(res, in.x, in.y, in.w, SPY1 - in.y); + R_NEW(res, in.x, SPY1, SPX1 - in.x, SPY2 - SPY1); + R_NEW(res, SPX2, SPY1, INX2 - SPX2, SPY2 - SPY1); + /* out => (in.x, SPY2, in.w, INY2 - SPY2) */ + res->rects[index].h = INY2 - SPY2; + res->rects[index].y = SPY2; + return 1; } /* SSSSSSS * S+---+S @@ -257,7 +235,8 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (!X1_IN && !X2_IN && !Y1_IN && !Y2_IN) { - return NULL; + evas_common_draw_context_cutouts_del(res, index); + return 0; } /* SSS * S+---+ @@ -269,9 +248,10 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (!X1_IN && X2_IN && !Y1_IN && !Y2_IN) { - R_NEW(r, SPX2, in->y, INX2 - SPX2, in->h); - out = evas_object_list_append(out, r); - return out; + /* in => (SPX2, in.y, INX2 - SPX2, in.h) */ + res->rects[index].w = INX2 - SPX2; + res->rects[index].x = SPX2; + return 1; } /* S * +---+ @@ -283,11 +263,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (X1_IN && X2_IN && !Y1_IN && !Y2_IN) { - R_NEW(r, in->x, in->y, SPX1 - in->x, in->h); - out = evas_object_list_append(out, r); - R_NEW(r, SPX2, in->y, INX2 - SPX2, in->h); - out = evas_object_list_append(out, r); - return out; + R_NEW(res, in.x, in.y, SPX1 - in.x, in.h); + /* in => (SPX2, in.y, INX2 - SPX2, in.h) */ + res->rects[index].w = INX2 - SPX2; + res->rects[index].x = SPX2; + return 1; } /* SSS * +---+S @@ -299,9 +279,9 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (X1_IN && !X2_IN && !Y1_IN && !Y2_IN) { - R_NEW(r, in->x, in->y, SPX1 - in->x, in->h); - out = evas_object_list_append(out, r); - return out; + /* in => (in.x, in.y, SPX1 - in.x, in.h) */ + res->rects[index].w = SPX1 - in.x; + return 1; } /* SSSSSSS * S+---+S @@ -313,9 +293,10 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (!X1_IN && !X2_IN && !Y1_IN && Y2_IN) { - R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); - out = evas_object_list_append(out, r); - return out; + /* in => (in.x, SPY2, in.w, INY2 - SPY2) */ + res->rects[index].h = INY2 - SPY2; + res->rects[index].y = SPY2; + return 1; } /* * +---+ @@ -327,11 +308,10 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (!X1_IN && !X2_IN && Y1_IN && Y2_IN) { - R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); - out = evas_object_list_append(out, r); - R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); - out = evas_object_list_append(out, r); - return out; + R_NEW(res, in.x, SPY2, in.w, INY2 - SPY2); + /* in => (in.x, in.y, in.w, SPY1 - in.y) */ + res->rects[index].h = SPY1 - in.y; + return 1; } /* * +---+ @@ -343,9 +323,9 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (!X1_IN && !X2_IN && Y1_IN && !Y2_IN) { - R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); - out = evas_object_list_append(out, r); - return out; + /* in => (in.x, in.y, in.w, SPY1 - in.y) */ + res->rects[index].h = SPY1 - in.y; + return 1; } /* SSS * S+---+ @@ -357,11 +337,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (!X1_IN && X2_IN && !Y1_IN && Y2_IN) { - R_NEW(r, SPX2, in->y, INX2 - SPX2, SPY2 - in->y); - out = evas_object_list_append(out, r); - R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); - out = evas_object_list_append(out, r); - return out; + R_NEW(res, SPX2, in.y, INX2 - SPX2, SPY2 - in.y); + /* in => (in.x, SPY2, in.w, INY2 - SPY2) */ + res->rects[index].h = INY2 - SPY2; + res->rects[index].y = SPY2; + return 1; } /* S * +---+ @@ -373,13 +353,12 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (X1_IN && X2_IN && !Y1_IN && Y2_IN) { - R_NEW(r, in->x, in->y, SPX1 - in->x, SPY2 - in->y); - out = evas_object_list_append(out, r); - R_NEW(r, SPX2, in->y, INX2 - SPX2, SPY2 - in->y); - out = evas_object_list_append(out, r); - R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); - out = evas_object_list_append(out, r); - return out; + R_NEW(res, in.x, in.y, SPX1 - in.x, SPY2 - in.y); + R_NEW(res, SPX2, in.y, INX2 - SPX2, SPY2 - in.y); + /* in => (in.x, SPY2, in.w, INY2 - SPY2) */ + res->rects[index].h = INY2 - SPY2; + res->rects[index].y = SPY2; + return 1; } /* SSS * +---+S @@ -391,11 +370,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (X1_IN && !X2_IN && !Y1_IN && Y2_IN) { - R_NEW(r, in->x, in->y, SPX1 - in->x, SPY2 - in->y); - out = evas_object_list_append(out, r); - R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); - out = evas_object_list_append(out, r); - return out; + R_NEW(res, in.x, in.y, SPX1 - in.x, SPY2 - in.y); + /* in => (in.x, SPY2, in.w, INY2 - SPY2) */ + res->rects[index].h = INY2 - SPY2; + res->rects[index].y = SPY2; + return 1; } /* * +---+ @@ -407,13 +386,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (!X1_IN && X2_IN && Y1_IN && Y2_IN) { - R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); - out = evas_object_list_append(out, r); - R_NEW(r, SPX2, SPY1, INX2 - SPX2, SPY2 - SPY1); - out = evas_object_list_append(out, r); - R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); - out = evas_object_list_append(out, r); - return out; + R_NEW(res, in.x, SPY2, in.w, INY2 - SPY2); + R_NEW(res, SPX2, SPY1, INX2 - SPX2, SPY2 - SPY1); + /* in => (in.x, SPY2, in.w, INY2 - SPY2) */ + res->rects[index].h = SPY1 - in.y; + return 1; } /* * +---+ @@ -425,13 +402,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (X1_IN && !X2_IN && Y1_IN && Y2_IN) { - R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); - out = evas_object_list_append(out, r); - R_NEW(r, in->x, SPY1, SPX1 - in->x, SPY2 - SPY1); - out = evas_object_list_append(out, r); - R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); - out = evas_object_list_append(out, r); - return out; + R_NEW(res, in.x, SPY2, in.w, INY2 - SPY2); + R_NEW(res, in.x, SPY1, SPX1 - in.x, SPY2 - SPY1); + /* in => (in.x, in.y, in.w, SPY1 - in.y) */ + res->rects[index].h = SPY1 - in.y; + return 1; } /* * +---+ @@ -443,11 +418,10 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (!X1_IN && X2_IN && Y1_IN && !Y2_IN) { - R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); - out = evas_object_list_append(out, r); - R_NEW(r, SPX2, SPY1, INX2 - SPX2, INY2 - SPY1); - out = evas_object_list_append(out, r); - return out; + R_NEW(res, SPX2, SPY1, INX2 - SPX2, INY2 - SPY1); + /* in => (in.x, in.y, in.w, SPY1 - in.y) */ + res->rects[index].h = SPY1 - in.y; + return 1; } /* * +---+ @@ -459,13 +433,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (X1_IN && X2_IN && Y1_IN && !Y2_IN) { - R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); - out = evas_object_list_append(out, r); - R_NEW(r, in->x, SPY1, SPX1 - in->x, INY2 - SPY1); - out = evas_object_list_append(out, r); - R_NEW(r, SPX2, SPY1, INX2 - SPX2, INY2 - SPY1); - out = evas_object_list_append(out, r); - return out; + R_NEW(res, in.x, SPY1, SPX1 - in.x, INY2 - SPY1); + R_NEW(res, SPX2, SPY1, INX2 - SPX2, INY2 - SPY1); + /* in => (in.x, in.y, in.w, SPY1 - in.y) */ + res->rects[index].h = SPY1 - in.y; + return 1; } /* * +---+ @@ -477,13 +449,13 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) */ if (X1_IN && !X2_IN && Y1_IN && !Y2_IN) { - R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); - out = evas_object_list_append(out, r); - R_NEW(r, in->x, SPY1, SPX1 - in->x, INY2 - SPY1); - out = evas_object_list_append(out, r); - return out; + R_NEW(res, in.x, SPY1, SPX1 - in.x, INY2 - SPY1); + /* in => (in.x, in.y, in.w, SPY1 - in.y) */ + res->rects[index].h = SPY1 - in.y; + return 1; } - return NULL; + evas_common_draw_context_cutouts_del(res, index); + return 0; #undef INX1 #undef INX2 #undef SPX1 @@ -499,32 +471,49 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) #undef R_NEW } -EAPI Cutout_Rect * -evas_common_draw_context_cutout_merge(Cutout_Rect *in, Cutout_Rect *merge) +EAPI Cutout_Rects* +evas_common_draw_context_apply_cutouts(RGBA_Draw_Context *dc) { - /* 1 input rect, multiple out */ - Cutout_Rect *out; - Cutout_Rect *r; - Evas_Object_List *l; + Cutout_Rects* res; + int i; + int j; - for (l = (Evas_Object_List *)in; l; l = l->next) + if (!dc->clip.use) return NULL; + if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) return NULL; + + res = evas_common_draw_context_cutouts_new(); + evas_common_draw_context_cutouts_add(res, dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h); + + for (i = 0; i < dc->cutout.active; ++i) { - r = (Cutout_Rect *)l; + /* Don't loop on the element just added to the list as they are already correctly clipped. */ + int active = res->active; - merge = evas_common_draw_context_cutouts_split(merge, r); - if (!merge) return in; + for (j = 0; j < active; ) + { + if (evas_common_draw_context_cutout_split(res, j, dc->cutout.rects + i)) + ++j; + else + active--; + } } - r = merge; - out = in; - while (r) - { - Cutout_Rect *r2; + return res; +} - r2 = r; - r = evas_object_list_remove(r, r); - out = evas_object_list_append(out, r2); - } - return out; +EAPI void +evas_common_draw_context_apply_clear_cutouts(Cutout_Rects* rects) +{ + evas_common_draw_context_apply_clean_cutouts(rects); + free(rects); +} + +EAPI void +evas_common_draw_context_apply_clean_cutouts(Cutout_Rects* rects) +{ + free(rects->rects); + rects->rects = NULL; + rects->active = 0; + rects->max = 0; } EAPI void diff --git a/legacy/evas/src/lib/engines/common/evas_pipe.c b/legacy/evas/src/lib/engines/common/evas_pipe.c index a05a57ee4e..74735ae795 100644 --- a/legacy/evas/src/lib/engines/common/evas_pipe.c +++ b/legacy/evas/src/lib/engines/common/evas_pipe.c @@ -38,27 +38,16 @@ static void evas_common_pipe_draw_context_copy(RGBA_Draw_Context *dc, RGBA_Pipe_Op *op) { Cutout_Rect *r, *r2; - + memcpy(&(op->context), dc, sizeof(RGBA_Draw_Context)); - op->context.cutout.rects = NULL; - for (r = dc->cutout.rects; r; r = (Cutout_Rect *)((Evas_Object_List *)r)->next) - { - r2 = calloc(1, sizeof(Cutout_Rect)); - if (r2) - { - r2->x = r->x; - r2->y = r->y; - r2->w = r->w; - r2->h = r->h; - op->context.cutout.rects = evas_object_list_append(op->context.cutout.rects, r2); - } - } + op->context.cutout.rects = malloc(sizeof(Cutout_Rect) * op->context.cutout.active); + memcpy(op->context.cutout.rects, dc->cutout.rects, sizeof(Cutout_Rect) * op->context.cutout.active); } static void evas_common_pipe_op_free(RGBA_Pipe_Op *op) { - evas_common_draw_context_apply_free_cutouts(op->context.cutout.rects); + evas_common_draw_context_apply_clean_cutouts(&op->context.cutout); } /* main api calls */ diff --git a/legacy/evas/src/lib/engines/common/evas_rectangle_main.c b/legacy/evas/src/lib/engines/common/evas_rectangle_main.c index f9fae5ad73..17c5f878f3 100644 --- a/legacy/evas/src/lib/engines/common/evas_rectangle_main.c +++ b/legacy/evas/src/lib/engines/common/evas_rectangle_main.c @@ -10,9 +10,10 @@ evas_common_rectangle_init(void) EAPI void evas_common_rectangle_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, int w, int h) { - int c, cx, cy, cw, ch; - Cutout_Rect *rects, *r; - Evas_Object_List *l; + Cutout_Rects *rects; + Cutout_Rect *r; + int c, cx, cy, cw, ch; + int i; /* handle cutouts here! */ if ((w <= 0) || (h <= 0)) return; @@ -35,13 +36,13 @@ evas_common_rectangle_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, return; } rects = evas_common_draw_context_apply_cutouts(dc); - for (l = (Evas_Object_List *)rects; l; l = l->next) + for (i = 0; i < rects->active; ++i) { - r = (Cutout_Rect *)l; + r = rects->rects + i; evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); rectangle_draw_internal(dst, dc, x, y, w, h); } - evas_common_draw_context_apply_free_cutouts(rects); + evas_common_draw_context_apply_clear_cutouts(rects); /* restore clip info */ dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; } diff --git a/legacy/evas/src/lib/engines/common/evas_scale_sample.c b/legacy/evas/src/lib/engines/common/evas_scale_sample.c index 54d255f31c..c8aef859a6 100644 --- a/legacy/evas/src/lib/engines/common/evas_scale_sample.c +++ b/legacy/evas/src/lib/engines/common/evas_scale_sample.c @@ -30,9 +30,10 @@ evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h) { - int c, cx, cy, cw, ch; - Cutout_Rect *rects, *r; - Evas_Object_List *l; + Cutout_Rects *rects; + Cutout_Rect *r; + int c, cx, cy, cw, ch; + int i; /* handle cutouts here! */ if ((dst_region_w <= 0) || (dst_region_h <= 0)) return; @@ -59,9 +60,9 @@ evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst, return; } rects = evas_common_draw_context_apply_cutouts(dc); - for (l = (Evas_Object_List *)rects; l; l = l->next) + for (i = 0; i < rects->active; ++i) { - r = (Cutout_Rect *)l; + r = rects->rects + i; evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); scale_rgba_in_to_out_clip_sample_internal(src, dst, dc, src_region_x, src_region_y, @@ -70,7 +71,7 @@ evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst, dst_region_w, dst_region_h); } - evas_common_draw_context_apply_free_cutouts(rects); + evas_common_draw_context_apply_clear_cutouts(rects); /* restore clip info */ dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; } diff --git a/legacy/evas/src/lib/engines/common/evas_scale_smooth.c b/legacy/evas/src/lib/engines/common/evas_scale_smooth.c index 67bef6e5dd..4244b05eae 100644 --- a/legacy/evas/src/lib/engines/common/evas_scale_smooth.c +++ b/legacy/evas/src/lib/engines/common/evas_scale_smooth.c @@ -447,9 +447,10 @@ evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst, # ifdef BUILD_MMX int mmx, sse, sse2; # endif - int c, cx, cy, cw, ch; - Cutout_Rect *rects, *r; - Evas_Object_List *l; + Cutout_Rects *rects; + Cutout_Rect *r; + int c, cx, cy, cw, ch; + int i; /* handle cutouts here! */ if ((dst_region_w <= 0) || (dst_region_h <= 0)) return; @@ -490,9 +491,9 @@ evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst, return; } rects = evas_common_draw_context_apply_cutouts(dc); - for (l = (Evas_Object_List *)rects; l; l = l->next) + for (i = 0; i < rects->active; ++i) { - r = (Cutout_Rect *)l; + r = rects->rects + i; evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); # ifdef BUILD_MMX if (mmx) @@ -511,7 +512,7 @@ evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst, dst_region_w, dst_region_h); # endif } - evas_common_draw_context_apply_free_cutouts(rects); + evas_common_draw_context_apply_clear_cutouts(rects); /* restore clip info */ dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; } diff --git a/legacy/evas/src/lib/include/evas_common.h b/legacy/evas/src/lib/include/evas_common.h index 3321145c18..f00fdcbfc9 100644 --- a/legacy/evas/src/lib/include/evas_common.h +++ b/legacy/evas/src/lib/include/evas_common.h @@ -140,6 +140,7 @@ typedef struct _RGBA_Font_Glyph RGBA_Font_Glyph; typedef struct _RGBA_Gfx_Compositor RGBA_Gfx_Compositor; typedef struct _Cutout_Rect Cutout_Rect; +typedef struct _Cutout_Rects Cutout_Rects; typedef struct _Convert_Pal Convert_Pal; @@ -235,6 +236,18 @@ struct _Evas_Hash_El void *data; }; +struct _Cutout_Rect +{ + int x, y, w, h; +}; + +struct _Cutout_Rects +{ + Cutout_Rect* rects; + int active; + int max; +}; + struct _RGBA_Draw_Context { struct { @@ -248,9 +261,7 @@ struct _RGBA_Draw_Context char use : 1; int x, y, w, h; } clip; - struct { - Cutout_Rect *rects; - } cutout; + Cutout_Rects cutout; struct { struct { void *(*gl_new) (void *data, RGBA_Font_Glyph *fg); @@ -572,11 +583,6 @@ struct _Regionspan int x1, x2; }; */ -struct _Cutout_Rect -{ - Evas_Object_List _list_data; - int x, y, w, h; -}; struct _Convert_Pal { @@ -1012,11 +1018,9 @@ EAPI void evas_common_draw_context_set_multiplier (RGBA_Draw_Co EAPI void evas_common_draw_context_unset_multiplier (RGBA_Draw_Context *dc); EAPI void evas_common_draw_context_add_cutout (RGBA_Draw_Context *dc, int x, int y, int w, int h); EAPI void evas_common_draw_context_clear_cutouts (RGBA_Draw_Context *dc); -EAPI Cutout_Rect *evas_common_draw_context_apply_cutouts (RGBA_Draw_Context *dc); -EAPI void evas_common_draw_context_apply_free_cutouts(Cutout_Rect *rects); -EAPI Cutout_Rect *evas_common_draw_context_cutouts_split (Cutout_Rect *in, Cutout_Rect *split); -EAPI Cutout_Rect *evas_common_draw_context_cutout_split (Cutout_Rect *in, Cutout_Rect *split); -EAPI Cutout_Rect *evas_common_draw_context_cutout_merge (Cutout_Rect *in, Cutout_Rect *merge); +EAPI Cutout_Rects *evas_common_draw_context_apply_cutouts (RGBA_Draw_Context *dc); +EAPI void evas_common_draw_context_apply_clear_cutouts(Cutout_Rects* rects); +EAPI void evas_common_draw_context_apply_clean_cutouts(Cutout_Rects* rects); EAPI void evas_common_draw_context_set_anti_alias (RGBA_Draw_Context *dc, unsigned char aa); EAPI void evas_common_draw_context_set_color_interpolation(RGBA_Draw_Context *dc, int color_space); EAPI void evas_common_draw_context_set_render_op (RGBA_Draw_Context *dc, int op); diff --git a/legacy/evas/src/modules/engines/directfb/evas_engine_dfb.c b/legacy/evas/src/modules/engines/directfb/evas_engine_dfb.c index 161c25698e..442f96e628 100644 --- a/legacy/evas/src/modules/engines/directfb/evas_engine_dfb.c +++ b/legacy/evas/src/modules/engines/directfb/evas_engine_dfb.c @@ -596,10 +596,11 @@ void evas_engine_directfb_draw_rectangle(void *data, void *context, void *surface, int x, int y, int w, int h) { + int i; int c, cx, cy, cw, ch; - Cutout_Rect *rects, *r; + Cutout_Rects *rects; + Cutout_Rect *r; RGBA_Draw_Context *dc = (RGBA_Draw_Context *) context; - Evas_Object_List *l; Render_Engine *re = (Render_Engine *) data; /* handle cutouts here! */ @@ -629,13 +630,13 @@ evas_engine_directfb_draw_rectangle(void *data, void *context, void *surface, return; } rects = evas_common_draw_context_apply_cutouts(dc); - for (l = (Evas_Object_List *) rects; l; l = l->next) + for (i = 0; i < rects->active; ++i) { - r = (Cutout_Rect *) l; + r = rects->rects + i; evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); rectangle_draw_internal(data, dc, x, y, w, h); } - evas_common_draw_context_apply_free_cutouts(rects); + evas_common_draw_context_clear_cutouts(rects); /* restore clip info */ dc->clip.use = c; dc->clip.x = cx; diff --git a/legacy/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c b/legacy/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c index 35cc8fc403..e9bb7c31fb 100644 --- a/legacy/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c +++ b/legacy/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c @@ -283,23 +283,23 @@ _xr_render_surface_clips_set(Xrender_Surface *rs, RGBA_Draw_Context *dc, int rx, } else { - int i; - Cutout_Rect *rects, *r; - Evas_Object_List *l; - - rects = evas_common_draw_context_apply_cutouts(dc); - for (num = 0, l = (Evas_Object_List *)rects; l; l = l->next) num++; + Cutout_Rects *rects; + Cutout_Rect *r; + int i; + + rects = evas_common_draw_context_apply_cutouts(dc); + num = rects->active; rect = malloc(num * sizeof(XRectangle)); if (!rect) return; - for (i = 0, l = (Evas_Object_List *)rects; l; l = l->next, i++) + for (i = 0; i < num; i++) { - r = (Cutout_Rect *)l; + r = rects->rects + i; rect[i].x = r->x; rect[i].y = r->y; rect[i].width = r->w; rect[i].height = r->h; } - evas_common_draw_context_apply_free_cutouts(rects); + evas_common_draw_context_apply_clear_cutouts(rects); } if (!rect) return; XRenderSetPictureClipRectangles(rs->xinf->disp, rs->pic, 0, 0, rect, num); diff --git a/legacy/evas/src/modules/engines/xrender_xcb/evas_engine_xrender.c b/legacy/evas/src/modules/engines/xrender_xcb/evas_engine_xrender.c index 752d0c4367..d84297d232 100644 --- a/legacy/evas/src/modules/engines/xrender_xcb/evas_engine_xrender.c +++ b/legacy/evas/src/modules/engines/xrender_xcb/evas_engine_xrender.c @@ -413,23 +413,23 @@ _xr_render_surface_clips_set(Xcb_Render_Surface *rs, RGBA_Draw_Context *dc, int } else { - int i; - Cutout_Rect *rects, *r; - Evas_Object_List *l; + Cutout_Rect *rects; + Cutout_Rect *r; + int i; rects = evas_common_draw_context_apply_cutouts(dc); - for (num = 0, l = (Evas_Object_List *)rects; l; l = l->next) num++; + num = rects->active; rect = malloc(num * sizeof(xcb_rectangle_t)); if (!rect) return; - for (i = 0, l = (Evas_Object_List *)rects; l; l = l->next, i++) + for (i = 0; i < num; i++) { - r = (Cutout_Rect *)l; + r = rects->rects + i; rect[i].x = r->x; rect[i].y = r->y; rect[i].width = r->w; rect[i].height = r->h; } - evas_common_draw_context_apply_free_cutouts(rects); + evas_common_draw_context_apply_clear_cutouts(rects); } if (!rect) return; xcb_render_set_picture_clip_rectangles(rs->xcbinf->conn, rs->pic, 0, 0, num, rect);