From 6ae734468301f732c9668f4cb74bc73e47c8baae Mon Sep 17 00:00:00 2001 From: Paulo Alcantara Date: Wed, 28 Nov 2012 22:49:19 +0000 Subject: [PATCH] evas/image: Refactor common code for image drawing This patch refactors common code for image draws - so that it can be used by other engines and *threaded* X11. Signed-off-by: Paulo Alcantara Patch by: Paulo Alcantara SVN revision: 79795 --- src/lib/evas/common/evas_scale_main.c | 53 +++++++++++++++++ src/lib/evas/common/evas_scale_main.h | 3 +- src/lib/evas/common/evas_scale_sample.c | 58 ++++--------------- src/lib/evas/common/evas_scale_smooth.c | 77 +++++-------------------- 4 files changed, 79 insertions(+), 112 deletions(-) diff --git a/src/lib/evas/common/evas_scale_main.c b/src/lib/evas/common/evas_scale_main.c index 8ccfe706c1..24047c195c 100644 --- a/src/lib/evas/common/evas_scale_main.c +++ b/src/lib/evas/common/evas_scale_main.c @@ -31,3 +31,56 @@ evas_common_scale_rgba_in_to_out_clip_prepare(Cutout_Rects *reuse, const RGBA_Im return EINA_TRUE; } +EAPI void +evas_common_scale_rgba_in_to_out_clip_cb(RGBA_Image *src, RGBA_Image *dst, + RGBA_Draw_Context *dc, + int src_region_x, int src_region_y, + int src_region_w, int src_region_h, + int dst_region_x, int dst_region_y, + int dst_region_w, int dst_region_h, + Evas_Common_Scale_In_To_Out_Clip_Cb cb) +{ + static Cutout_Rects *rects = NULL; + Cutout_Rect *r; + int c, cx, cy, cw, ch; + int i; + /* handle cutouts here! */ + + if ((dst_region_w <= 0) || (dst_region_h <= 0)) return; + if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h))) + return; + + /* no cutouts - cut right to the chase */ + if (!dc->cutout.rects) + { + cb(src, dst, dc, + src_region_x, src_region_y, src_region_w, src_region_h, + dst_region_x, dst_region_y, dst_region_w, dst_region_h); + return; + } + + /* save out clip info */ + c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h; + evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h); + evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h); + + /* our clip is 0 size.. abort */ + if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) + { + dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; + return; + } + + rects = evas_common_draw_context_apply_cutouts(dc, rects); + for (i = 0; i < rects->active; ++i) + { + r = rects->rects + i; + evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); + cb(src, dst, dc, + src_region_x, src_region_y, src_region_w, src_region_h, + dst_region_x, dst_region_y, dst_region_w, dst_region_h); + } + + /* 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/src/lib/evas/common/evas_scale_main.h b/src/lib/evas/common/evas_scale_main.h index e2ef8fa9ce..a126457162 100644 --- a/src/lib/evas/common/evas_scale_main.h +++ b/src/lib/evas/common/evas_scale_main.h @@ -1,11 +1,12 @@ #ifndef _EVAS_SCALE_MAIN_H #define _EVAS_SCALE_MAIN_H +typedef void (*Evas_Common_Scale_In_To_Out_Clip_Cb)(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h); EAPI void evas_common_scale_init (void); +EAPI void evas_common_scale_rgba_in_to_out_clip_cb (RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h, Evas_Common_Scale_In_To_Out_Clip_Cb cb); EAPI void evas_common_scale_rgba_in_to_out_clip_smooth (RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h); - EAPI void evas_common_scale_rgba_in_to_out_clip_sample (RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h); EAPI void evas_common_rgba_image_scalecache_dump(void); diff --git a/src/lib/evas/common/evas_scale_sample.c b/src/lib/evas/common/evas_scale_sample.c index f78aad3879..9a94f904ea 100644 --- a/src/lib/evas/common/evas_scale_sample.c +++ b/src/lib/evas/common/evas_scale_sample.c @@ -5,55 +5,17 @@ static void scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Imag EAPI void evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst, - RGBA_Draw_Context *dc, - int src_region_x, int src_region_y, - int src_region_w, int src_region_h, - int dst_region_x, int dst_region_y, - int dst_region_w, int dst_region_h) + RGBA_Draw_Context *dc, + int src_region_x, int src_region_y, + int src_region_w, int src_region_h, + int dst_region_x, int dst_region_y, + int dst_region_w, int dst_region_h) { - static Cutout_Rects *rects = NULL; - Cutout_Rect *r; - int c, cx, cy, cw, ch; - int i; - /* handle cutouts here! */ - - if ((dst_region_w <= 0) || (dst_region_h <= 0)) return; - if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h))) - return; - /* no cutouts - cut right to the chase */ - if (!dc->cutout.rects) - { - scale_rgba_in_to_out_clip_sample_internal(src, dst, dc, - src_region_x, src_region_y, - src_region_w, src_region_h, - dst_region_x, dst_region_y, - dst_region_w, dst_region_h); - return; - } - /* save out clip info */ - c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h; - evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h); - evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h); - /* our clip is 0 size.. abort */ - if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) - { - dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; - return; - } - rects = evas_common_draw_context_apply_cutouts(dc, rects); - for (i = 0; i < rects->active; ++i) - { - 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, - src_region_w, src_region_h, - dst_region_x, dst_region_y, - dst_region_w, dst_region_h); - - } - /* restore clip info */ - dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; + evas_common_scale_rgba_in_to_out_clip_cb + (src, dst, dc, + src_region_x, src_region_y, src_region_w, src_region_h, + dst_region_x, dst_region_y, dst_region_w, dst_region_h, + scale_rgba_in_to_out_clip_sample_internal); } EAPI void diff --git a/src/lib/evas/common/evas_scale_smooth.c b/src/lib/evas/common/evas_scale_smooth.c index e4dfd2cc6f..9efcc8b575 100644 --- a/src/lib/evas/common/evas_scale_smooth.c +++ b/src/lib/evas/common/evas_scale_smooth.c @@ -110,72 +110,23 @@ evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h) { -# ifdef BUILD_MMX + Evas_Common_Scale_In_To_Out_Clip_Cb cb; +#ifdef BUILD_MMX int mmx, sse, sse2; -# endif - static Cutout_Rects *rects = NULL; - Cutout_Rect *r; - int c, cx, cy, cw, ch; - int i; - /* handle cutouts here! */ - if ((dst_region_w <= 0) || (dst_region_h <= 0)) return; - if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h))) - return; -# ifdef BUILD_MMX evas_common_cpu_can_do(&mmx, &sse, &sse2); -# endif - /* no cutouts - cut right to the chase */ - if (!dc->cutout.rects) - { -# ifdef BUILD_MMX - if (mmx) - evas_common_scale_rgba_in_to_out_clip_smooth_mmx(src, dst, dc, - src_region_x, src_region_y, - src_region_w, src_region_h, - dst_region_x, dst_region_y, - dst_region_w, dst_region_h); - else -# endif - evas_common_scale_rgba_in_to_out_clip_smooth_c(src, dst, dc, - src_region_x, src_region_y, - src_region_w, src_region_h, - dst_region_x, dst_region_y, - dst_region_w, dst_region_h); - return; - } - /* save out clip info */ - c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h; - evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h); - evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h); - /* our clip is 0 size.. abort */ - if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) - { - dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; - return; - } - rects = evas_common_draw_context_apply_cutouts(dc, rects); - for (i = 0; i < rects->active; ++i) - { - r = rects->rects + i; - evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); -# ifdef BUILD_MMX - if (mmx) - evas_common_scale_rgba_in_to_out_clip_smooth_mmx(src, dst, dc, - src_region_x, src_region_y, - src_region_w, src_region_h, - dst_region_x, dst_region_y, - dst_region_w, dst_region_h); - else -# endif - evas_common_scale_rgba_in_to_out_clip_smooth_c(src, dst, dc, - src_region_x, src_region_y, - src_region_w, src_region_h, - dst_region_x, dst_region_y, - dst_region_w, dst_region_h); - } - /* restore clip info */ - dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; + if (mmx) + cb = evas_common_scale_rgba_in_to_out_clip_smooth_mmx; + else +#endif + cb = evas_common_scale_rgba_in_to_out_clip_smooth_c; + + evas_common_scale_rgba_in_to_out_clip_cb(src, dst, dc, + src_region_x, src_region_y, + src_region_w, src_region_h, + dst_region_x, dst_region_y, + dst_region_w, dst_region_h, + cb); } EAPI void