forked from enlightenment/efl
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 <pcacjr@profusion.mobi> Patch by: Paulo Alcantara <pcacjr@profusion.mobi> SVN revision: 79795
This commit is contained in:
parent
951a95c984
commit
6ae7344683
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue