evas/async_render: use image scalecache

SVN revision: 82890
This commit is contained in:
Ulisses Furquim 2013-01-16 16:07:46 +00:00
parent 73667b025c
commit 09f342fdeb
6 changed files with 194 additions and 153 deletions

View File

@ -55,6 +55,15 @@ EAPI void
int src_region_w, int src_region_h, int src_region_w, int src_region_h,
int dst_region_x, int dst_region_y, int dst_region_x, int dst_region_y,
int dst_region_w, int dst_region_h); int dst_region_w, int dst_region_h);
EAPI Eina_Bool
evas_common_rgba_image_scalecache_do_cbs(Image_Entry *ie, RGBA_Image *dst,
RGBA_Draw_Context *dc, int smooth,
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_sample,
Evas_Common_Scale_In_To_Out_Clip_Cb cb_smooth);
EAPI int evas_common_load_rgba_image_module_from_file (Image_Entry *im); EAPI int evas_common_load_rgba_image_module_from_file (Image_Entry *im);

View File

@ -495,19 +495,22 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst EINA_
//static int noscales = 0; //static int noscales = 0;
#endif #endif
EAPI void EAPI Eina_Bool
evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst, evas_common_rgba_image_scalecache_do_cbs(Image_Entry *ie, RGBA_Image *dst,
RGBA_Draw_Context *dc, int smooth, RGBA_Draw_Context *dc, int smooth,
int src_region_x, int src_region_y, int src_region_x, int src_region_y,
int src_region_w, int src_region_h, int src_region_w, int src_region_h,
int dst_region_x, int dst_region_y, int dst_region_x, int dst_region_y,
int dst_region_w, int dst_region_h) int dst_region_w, int dst_region_h,
Evas_Common_Scale_In_To_Out_Clip_Cb cb_sample,
Evas_Common_Scale_In_To_Out_Clip_Cb cb_smooth)
{ {
#ifdef SCALECACHE #ifdef SCALECACHE
RGBA_Image *im = (RGBA_Image *)ie; RGBA_Image *im = (RGBA_Image *)ie;
Scaleitem *sci; Scaleitem *sci;
int didpop = 0; int didpop = 0;
int dounload = 0; int dounload = 0;
Eina_Bool ret = EINA_FALSE;
/* /*
static int i = 0; static int i = 0;
@ -520,7 +523,7 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
} }
*/ */
if ((dst_region_w == 0) || (dst_region_h == 0) || if ((dst_region_w == 0) || (dst_region_h == 0) ||
(src_region_w == 0) || (src_region_h == 0)) return; (src_region_w == 0) || (src_region_h == 0)) return EINA_FALSE;
LKL(im->cache.lock); LKL(im->cache.lock);
if ((src_region_w == dst_region_w) && (src_region_h == dst_region_h)) if ((src_region_w == dst_region_w) && (src_region_h == dst_region_h))
{ {
@ -539,13 +542,13 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
LKU(im->cache.lock); LKU(im->cache.lock);
if (im->image.data) if (im->image.data)
{ {
evas_common_scale_rgba_in_to_out_clip_sample(im, dst, dc, return cb_sample(im, dst, dc,
src_region_x, src_region_y, src_region_x, src_region_y,
src_region_w, src_region_h, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_x, dst_region_y,
dst_region_w, dst_region_h); dst_region_w, dst_region_h);
} }
return; return EINA_FALSE;
} }
LKL(cache_lock); LKL(cache_lock);
sci = _sci_find(im, dc, smooth, sci = _sci_find(im, dc, smooth,
@ -570,24 +573,24 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if (im->image.data) if (im->image.data)
{ {
if (smooth) if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc, return cb_smooth(im, dst, dc,
src_region_x, src_region_y, src_region_x, src_region_y,
src_region_w, src_region_h, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_x, dst_region_y,
dst_region_w, dst_region_h); dst_region_w, dst_region_h);
else else
evas_common_scale_rgba_in_to_out_clip_sample(im, dst, dc, return cb_sample(im, dst, dc,
src_region_x, src_region_y, src_region_x, src_region_y,
src_region_w, src_region_h, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_x, dst_region_y,
dst_region_w, dst_region_h); dst_region_w, dst_region_h);
} }
return; return EINA_FALSE;
} }
if (sci->populate_me) if (sci->populate_me)
{ {
int size, osize, used; int size, osize, used;
size = dst_region_w * dst_region_h; size = dst_region_w * dst_region_h;
if (((((dst_region_w > 640) || (dst_region_h > 640)) && if (((((dst_region_w > 640) || (dst_region_h > 640)) &&
(size > (480 * 480))) || (size > (480 * 480))) ||
@ -596,7 +599,7 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
{ {
Eina_List *l; Eina_List *l;
Scaleitem *sci2; Scaleitem *sci2;
dounload = 1; dounload = 1;
osize = sci->parent_im->cache_entry.w * sci->parent_im->cache_entry.h; osize = sci->parent_im->cache_entry.w * sci->parent_im->cache_entry.h;
used = 0; used = 0;
@ -611,7 +614,7 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
osize -= used; osize -= used;
if (osize < 0) osize = 0; if (osize < 0) osize = 0;
size -= osize; size -= osize;
sci->size_adjust = size * 4; sci->size_adjust = size * 4;
} }
} }
else else
@ -632,7 +635,7 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if (sci->im) if (sci->im)
{ {
static RGBA_Draw_Context *ct = NULL; static RGBA_Draw_Context *ct = NULL;
LKL(cache_lock); LKL(cache_lock);
im->cache.orig_usage++; im->cache.orig_usage++;
im->cache.usage_count = use_counter; im->cache.usage_count = use_counter;
@ -658,29 +661,27 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if (im->image.data) if (im->image.data)
{ {
if (smooth) if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth ret = cb_smooth(im, sci->im, ct,
(im, sci->im, ct, src_region_x, src_region_y,
src_region_x, src_region_y, src_region_w, src_region_h,
src_region_w, src_region_h, 0, 0,
0, 0, dst_region_w, dst_region_h);
dst_region_w, dst_region_h);
else else
evas_common_scale_rgba_in_to_out_clip_sample ret = cb_sample(im, sci->im, ct,
(im, sci->im, ct, src_region_x, src_region_y,
src_region_x, src_region_y, src_region_w, src_region_h,
src_region_w, src_region_h, 0, 0,
0, 0, dst_region_w, dst_region_h);
dst_region_w, dst_region_h);
sci->populate_me = 0; sci->populate_me = 0;
#if 0 // visual debug of cached images #if 0 // visual debug of cached images
{ {
int xx, yy; int xx, yy;
DATA32 *pp; DATA32 *pp;
pp = sci->im->image.data; pp = sci->im->image.data;
for (yy = 0; yy < dst_region_h; yy++) for (yy = 0; yy < dst_region_h; yy++)
{ {
for (xx = 0; xx < dst_region_w; xx++) for (xx = 0; xx < dst_region_w; xx++)
{ {
if (yy & 0x1) if (yy & 0x1)
@ -688,14 +689,14 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if (xx & 0x1) *pp = 0x882288ff; if (xx & 0x1) *pp = 0x882288ff;
} }
else else
{ {
if (!(xx & 0x1)) *pp = 0x882288ff; if (!(xx & 0x1)) *pp = 0x882288ff;
} }
pp++; pp++;
} }
} }
} }
#endif #endif
} }
if (dounload) if (dounload)
{ {
@ -706,8 +707,8 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
{ {
cache_size += sci->dst_w * sci->dst_h * 4; cache_size += sci->dst_w * sci->dst_h * 4;
} }
// INF(" + %i @ flop: %i (%ix%i)", // INF(" + %i @ flop: %i (%ix%i)",
// sci->dst_w * sci->dst_h * 4, sci->flop, // sci->dst_w * sci->dst_h * 4, sci->flop,
// sci->dst_w, sci->dst_h); // sci->dst_w, sci->dst_h);
cache_list = eina_inlist_append(cache_list, (Eina_Inlist *)sci); cache_list = eina_inlist_append(cache_list, (Eina_Inlist *)sci);
_cache_prune(sci, 0); _cache_prune(sci, 0);
@ -730,39 +731,38 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
} }
// INF("use cached!"); // INF("use cached!");
LKU(im->cache.lock); LKU(im->cache.lock);
evas_common_scale_rgba_in_to_out_clip_sample ret |= cb_sample(sci->im, dst, dc,
(sci->im, dst, dc, 0, 0,
0, 0, dst_region_w, dst_region_h,
dst_region_w, dst_region_h, dst_region_x, dst_region_y,
dst_region_x, dst_region_y, dst_region_w, dst_region_h);
dst_region_w, dst_region_h);
// hits++; // hits++;
// INF("check %p %i < %i", // INF("check %p %i < %i",
// im, // im,
// (int)im->cache.orig_usage, // (int)im->cache.orig_usage,
// (int)im->cache.newest_usage); // (int)im->cache.newest_usage);
/* while framequeuing is applied, /* while framequeuing is applied,
* original image data is loaded by the main thread * original image data is loaded by the main thread
* just before enqueuing the rendering op into the pipe. * just before enqueuing the rendering op into the pipe.
* so unloading the original image data here * so unloading the original image data here
* causes only speed-down side-effect and no memory usage gain; * causes only speed-down side-effect and no memory usage gain;
* it will be loaded again for the very next rendering for this image. * it will be loaded again for the very next rendering for this image.
*/ */
if (ie->scale_hint != EVAS_IMAGE_SCALE_HINT_DYNAMIC) if (ie->scale_hint != EVAS_IMAGE_SCALE_HINT_DYNAMIC)
{ {
if ((dounload) || if ((dounload) ||
((im->cache_entry.flags.loaded) && ((im->cache_entry.flags.loaded) &&
((!im->cs.no_free) ((!im->cs.no_free)
#ifdef EVAS_CSERVE #ifdef EVAS_CSERVE
|| (ie->data1) || (ie->data1)
#endif #endif
#ifdef EVAS_CSERVE2 #ifdef EVAS_CSERVE2
|| (ie->data1) || (ie->data1)
#endif #endif
) && ) &&
(im->cache_entry.space == EVAS_COLORSPACE_ARGB8888))) (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)))
{ {
if ((dounload) || (im->cache.orig_usage < if ((dounload) || (im->cache.orig_usage <
(im->cache.newest_usage / 20))) (im->cache.newest_usage / 20)))
{ {
//FIXME: imagedataunload - inform owners //FIXME: imagedataunload - inform owners
@ -793,21 +793,26 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if (im->image.data) if (im->image.data)
{ {
if (smooth) if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc, ret |= cb_smooth(im, dst, dc,
src_region_x, src_region_y, src_region_x, src_region_y,
src_region_w, src_region_h, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_x, dst_region_y,
dst_region_w, dst_region_h); dst_region_w, dst_region_h);
else else
evas_common_scale_rgba_in_to_out_clip_sample(im, dst, dc, ret |= cb_sample(im, dst, dc,
src_region_x, src_region_y, src_region_x, src_region_y,
src_region_w, src_region_h, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_x, dst_region_y,
dst_region_w, dst_region_h); dst_region_w, dst_region_h);
} }
} }
#else
return ret;
#else
RGBA_Image *im = (RGBA_Image *)ie; RGBA_Image *im = (RGBA_Image *)ie;
if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888) if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
{ {
#ifdef EVAS_CSERVE2 #ifdef EVAS_CSERVE2
@ -821,17 +826,36 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if (im->image.data) if (im->image.data)
{ {
if (smooth) if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc, return cb_smooth(im, dst, dc,
src_region_x, src_region_y, src_region_x, src_region_y,
src_region_w, src_region_h, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_x, dst_region_y,
dst_region_w, dst_region_h); dst_region_w, dst_region_h);
else else
evas_common_scale_rgba_in_to_out_clip_sample(im, dst, dc, return cb_sample(im, dst, dc,
src_region_x, src_region_y, src_region_x, src_region_y,
src_region_w, src_region_h, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_x, dst_region_y,
dst_region_w, dst_region_h); dst_region_w, dst_region_h);
} }
return EINA_FALSE;
#endif #endif
} }
EAPI void
evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
RGBA_Draw_Context *dc, int smooth,
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_rgba_image_scalecache_do_cbs(
ie, dst, dc, smooth,
src_region_x, src_region_y, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_w, dst_region_h,
evas_common_scale_rgba_in_to_out_clip_sample,
evas_common_scale_rgba_in_to_out_clip_smooth);
}

View File

@ -6,8 +6,8 @@ typedef Eina_Bool (*Evas_Common_Scale_In_To_Out_Clip_Cb)(RGBA_Image *src, RGBA_I
EAPI void evas_common_scale_init (void); EAPI void evas_common_scale_init (void);
EAPI Eina_Bool 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 Eina_Bool 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 Eina_Bool 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 Eina_Bool 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); EAPI void evas_common_rgba_image_scalecache_dump(void);

View File

@ -3,7 +3,7 @@
static Eina_Bool scale_rgba_in_to_out_clip_sample_internal(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); static Eina_Bool scale_rgba_in_to_out_clip_sample_internal(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 EAPI Eina_Bool
evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst, evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst,
RGBA_Draw_Context *dc, RGBA_Draw_Context *dc,
int src_region_x, int src_region_y, int src_region_x, int src_region_y,
@ -11,7 +11,7 @@ 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_x, int dst_region_y,
int dst_region_w, int dst_region_h) int dst_region_w, int dst_region_h)
{ {
evas_common_scale_rgba_in_to_out_clip_cb return evas_common_scale_rgba_in_to_out_clip_cb
(src, dst, dc, (src, dst, dc,
src_region_x, src_region_y, src_region_w, src_region_h, src_region_x, src_region_y, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_w, dst_region_h, dst_region_x, dst_region_y, dst_region_w, dst_region_h,

View File

@ -180,7 +180,7 @@ evas_common_scale_rgba_in_to_out_clip_smooth_c(RGBA_Image *src, RGBA_Image *dst,
return EINA_TRUE; return EINA_TRUE;
} }
EAPI void EAPI Eina_Bool
evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst, evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst,
RGBA_Draw_Context *dc, RGBA_Draw_Context *dc,
int src_region_x, int src_region_y, int src_region_x, int src_region_y,
@ -199,12 +199,12 @@ evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst,
#endif #endif
cb = evas_common_scale_rgba_in_to_out_clip_smooth_c; cb = evas_common_scale_rgba_in_to_out_clip_smooth_c;
evas_common_scale_rgba_in_to_out_clip_cb(src, dst, dc, return evas_common_scale_rgba_in_to_out_clip_cb(src, dst, dc,
src_region_x, src_region_y, src_region_x, src_region_y,
src_region_w, src_region_h, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_x, dst_region_y,
dst_region_w, dst_region_h, dst_region_w, dst_region_h,
cb); cb);
} }
EAPI void EAPI void

View File

@ -1187,13 +1187,13 @@ _draw_thread_image_draw(void *data)
} }
static Eina_Bool static Eina_Bool
_image_draw_thread_cmd(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, int smooth) _image_draw_thread_cmd(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
{ {
Evas_Thread_Command_Image *cr; Evas_Thread_Command_Image *cr;
int clip_x, clip_y, clip_w, clip_h; int clip_x, clip_y, clip_w, clip_h;
if ((dst_region_w <= 0) || (dst_region_h <= 0)) return EINA_FALSE; if ((dst_w <= 0) || (dst_h <= 0)) return EINA_FALSE;
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, if (!(RECTS_INTERSECT(dst_x, dst_y, dst_w, dst_h,
0, 0, dst->cache_entry.w, dst->cache_entry.h))) return EINA_FALSE; 0, 0, dst->cache_entry.w, dst->cache_entry.h))) return EINA_FALSE;
cr = eina_mempool_malloc(_mp_command_image, sizeof (Evas_Thread_Command_Image)); cr = eina_mempool_malloc(_mp_command_image, sizeof (Evas_Thread_Command_Image));
@ -1201,8 +1201,8 @@ _image_draw_thread_cmd(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc,
cr->image = src; cr->image = src;
cr->surface = dst; cr->surface = dst;
EINA_RECTANGLE_SET(&cr->src, src_region_x, src_region_y, src_region_w, src_region_h); EINA_RECTANGLE_SET(&cr->src, src_x, src_y, src_w, src_h);
EINA_RECTANGLE_SET(&cr->dst, dst_region_x, dst_region_y, dst_region_w, dst_region_h); EINA_RECTANGLE_SET(&cr->dst, dst_x, dst_y, dst_w, dst_h);
if (dc->clip.use) if (dc->clip.use)
{ {
@ -1231,23 +1231,39 @@ _image_draw_thread_cmd(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc,
} }
static Eina_Bool static Eina_Bool
_image_draw_thread_cmd_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) _image_draw_thread_cmd_smooth(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h)
{ {
return _image_draw_thread_cmd return _image_draw_thread_cmd(src, dst, dc,
(src, dst, dc, src_x, src_y, src_w, src_h,
src_region_x, src_region_y, src_region_w, src_region_h, dst_x, dst_y, dst_w, dst_h,
dst_region_x, dst_region_y, dst_region_w, dst_region_h, 1);
1);
} }
static Eina_Bool static Eina_Bool
_image_draw_thread_cmd_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) _image_draw_thread_cmd_sample(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h)
{ {
return _image_draw_thread_cmd return _image_draw_thread_cmd(src, dst, dc,
(src, dst, dc, src_x, src_y, src_w, src_h,
src_region_x, src_region_y, src_region_w, src_region_h, dst_x, dst_y, dst_w, dst_h,
dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0);
0); }
static Eina_Bool
_image_thr_cb_smooth(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h)
{
return evas_common_scale_rgba_in_to_out_clip_cb(src, dst, dc,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h,
_image_draw_thread_cmd_smooth);
}
static Eina_Bool
_image_thr_cb_sample(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h)
{
return evas_common_scale_rgba_in_to_out_clip_cb(src, dst, dc,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h,
_image_draw_thread_cmd_sample);
} }
static Eina_Bool static Eina_Bool
@ -1272,20 +1288,16 @@ eng_image_draw(void *data EINA_UNUSED, void *context, void *surface, void *image
if (!im->cache_entry.flags.loaded) return EINA_FALSE; if (!im->cache_entry.flags.loaded) return EINA_FALSE;
} }
evas_common_image_colorspace_normalize(im); evas_common_rgba_image_scalecache_prepare(image, surface, context, smooth,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h);
if (smooth) return evas_common_rgba_image_scalecache_do_cbs(image, surface,
return evas_common_scale_rgba_in_to_out_clip_cb context, smooth,
(image, surface, context, src_x, src_y, src_w, src_h,
src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h,
dst_x, dst_y, dst_w, dst_h, _image_thr_cb_sample,
_image_draw_thread_cmd_smooth); _image_thr_cb_smooth);
else
return evas_common_scale_rgba_in_to_out_clip_cb
(image, surface, context,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h,
_image_draw_thread_cmd_sample);
} }
#ifdef BUILD_PIPE_RENDER #ifdef BUILD_PIPE_RENDER
else if ((cpunum > 1)) else if ((cpunum > 1))
@ -1294,11 +1306,11 @@ eng_image_draw(void *data EINA_UNUSED, void *context, void *surface, void *image
if (evas_cserve2_use_get()) if (evas_cserve2_use_get())
evas_cache2_image_load_data(&im->cache_entry); evas_cache2_image_load_data(&im->cache_entry);
#endif #endif
evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im), evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im),
surface, context, smooth, surface, context, smooth,
src_x, src_y, src_w, src_h, src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h); dst_x, dst_y, dst_w, dst_h);
evas_common_pipe_image_draw(im, surface, context, smooth, evas_common_pipe_image_draw(im, surface, context, smooth,
src_x, src_y, src_w, src_h, src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h); dst_x, dst_y, dst_w, dst_h);
@ -1359,13 +1371,13 @@ image_loaded:
} }
static void static void
_map_image_draw(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, int smooth) _map_image_draw(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
{ {
int clip_x, clip_y, clip_w, clip_h; int clip_x, clip_y, clip_w, clip_h;
DATA32 mul_col; DATA32 mul_col;
if ((dst_region_w <= 0) || (dst_region_h <= 0)) return; if ((dst_w <= 0) || (dst_h <= 0)) return;
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, if (!(RECTS_INTERSECT(dst_x, dst_y, dst_w, dst_h,
0, 0, dst->cache_entry.w, dst->cache_entry.h))) return; 0, 0, dst->cache_entry.w, dst->cache_entry.h))) return;
if (dc->clip.use) if (dc->clip.use)
@ -1385,38 +1397,34 @@ _map_image_draw(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src
mul_col = dc->mul.use ? dc->mul.col : 0xffffffff; mul_col = dc->mul.use ? dc->mul.col : 0xffffffff;
if (smooth) if (smooth)
evas_common_scale_rgba_smooth_draw evas_common_scale_rgba_smooth_draw(src, dst,
(src, dst, clip_x, clip_y, clip_w, clip_h,
clip_x, clip_y, clip_w, clip_h, mul_col, dc->render_op,
mul_col, dc->render_op, src_x, src_y, src_w, src_h,
src_region_x, src_region_y, src_region_w, src_region_h, dst_x, dst_y, dst_w, dst_h);
dst_region_x, dst_region_y, dst_region_w, dst_region_h);
else else
evas_common_scale_rgba_sample_draw evas_common_scale_rgba_sample_draw(src, dst,
(src, dst, clip_x, clip_y, clip_w, clip_h,
clip_x, clip_y, clip_w, clip_h, mul_col, dc->render_op,
mul_col, dc->render_op, src_x, src_y, src_w, src_h,
src_region_x, src_region_y, src_region_w, src_region_h, dst_x, dst_y, dst_w, dst_h);
dst_region_x, dst_region_y, dst_region_w, dst_region_h);
} }
static Eina_Bool static Eina_Bool
_map_image_sample_draw(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) _map_image_sample_draw(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h)
{ {
_map_image_draw(src, dst, dc, _map_image_draw(src, dst, dc,
src_region_x, src_region_y, src_region_w, src_region_h, src_x, src_y, src_w, src_h,
dst_region_x, dst_region_y, dst_region_w, dst_region_h, dst_x, dst_y, dst_w, dst_h, 0);
0);
return EINA_TRUE; return EINA_TRUE;
} }
static Eina_Bool static Eina_Bool
_map_image_smooth_draw(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) _map_image_smooth_draw(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h)
{ {
_map_image_draw(src, dst, dc, _map_image_draw(src, dst, dc,
src_region_x, src_region_y, src_region_w, src_region_h, src_x, src_y, src_w, src_h,
dst_region_x, dst_region_y, dst_region_w, dst_region_h, dst_x, dst_y, dst_w, dst_h, 1);
1);
return EINA_TRUE; return EINA_TRUE;
} }
@ -1484,7 +1492,7 @@ _draw_thread_map_draw(void *data)
while ((m->count > 4) && (m->count - offset >= 3)); while ((m->count > 4) && (m->count - offset >= 3));
free_out: free_out:
free(m); // FIXME: allocating and destroying map do have perf impact... ref counting would be better free(m);
eina_mempool_free(_mp_command_map, map); eina_mempool_free(_mp_command_map, map);
} }