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 dst_region_x, int dst_region_y,
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);

View File

@ -495,19 +495,22 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst EINA_
//static int noscales = 0;
#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)
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)
{
#ifdef SCALECACHE
RGBA_Image *im = (RGBA_Image *)ie;
Scaleitem *sci;
int didpop = 0;
int dounload = 0;
Eina_Bool ret = EINA_FALSE;
/*
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) ||
(src_region_w == 0) || (src_region_h == 0)) return;
(src_region_w == 0) || (src_region_h == 0)) return EINA_FALSE;
LKL(im->cache.lock);
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);
if (im->image.data)
{
evas_common_scale_rgba_in_to_out_clip_sample(im, 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 cb_sample(im, 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;
return EINA_FALSE;
}
LKL(cache_lock);
sci = _sci_find(im, dc, smooth,
@ -570,19 +573,19 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if (im->image.data)
{
if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, 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 cb_smooth(im, 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
evas_common_scale_rgba_in_to_out_clip_sample(im, 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 cb_sample(im, 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;
return EINA_FALSE;
}
if (sci->populate_me)
{
@ -658,19 +661,17 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if (im->image.data)
{
if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth
(im, sci->im, ct,
src_region_x, src_region_y,
src_region_w, src_region_h,
0, 0,
dst_region_w, dst_region_h);
ret = cb_smooth(im, sci->im, ct,
src_region_x, src_region_y,
src_region_w, src_region_h,
0, 0,
dst_region_w, dst_region_h);
else
evas_common_scale_rgba_in_to_out_clip_sample
(im, sci->im, ct,
src_region_x, src_region_y,
src_region_w, src_region_h,
0, 0,
dst_region_w, dst_region_h);
ret = cb_sample(im, sci->im, ct,
src_region_x, src_region_y,
src_region_w, src_region_h,
0, 0,
dst_region_w, dst_region_h);
sci->populate_me = 0;
#if 0 // visual debug of cached images
{
@ -690,7 +691,7 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
else
{
if (!(xx & 0x1)) *pp = 0x882288ff;
}
}
pp++;
}
}
@ -730,12 +731,11 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
}
// INF("use cached!");
LKU(im->cache.lock);
evas_common_scale_rgba_in_to_out_clip_sample
(sci->im, dst, dc,
0, 0,
dst_region_w, dst_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
ret |= cb_sample(sci->im, dst, dc,
0, 0,
dst_region_w, dst_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
// hits++;
// INF("check %p %i < %i",
// im,
@ -793,21 +793,26 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if (im->image.data)
{
if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, 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);
ret |= cb_smooth(im, 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
evas_common_scale_rgba_in_to_out_clip_sample(im, 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);
ret |= cb_sample(im, 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 ret;
#else
RGBA_Image *im = (RGBA_Image *)ie;
if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
{
#ifdef EVAS_CSERVE2
@ -821,17 +826,36 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if (im->image.data)
{
if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, 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 cb_smooth(im, 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
evas_common_scale_rgba_in_to_out_clip_sample(im, 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 cb_sample(im, 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 EINA_FALSE;
#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 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 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_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_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);

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);
EAPI void
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,
@ -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_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_region_x, src_region_y, src_region_w, src_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;
}
EAPI void
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,
@ -199,12 +199,12 @@ evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst,
#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);
return 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

View File

@ -1187,13 +1187,13 @@ _draw_thread_image_draw(void *data)
}
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;
int clip_x, clip_y, clip_w, clip_h;
if ((dst_region_w <= 0) || (dst_region_h <= 0)) return EINA_FALSE;
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h,
if ((dst_w <= 0) || (dst_h <= 0)) return EINA_FALSE;
if (!(RECTS_INTERSECT(dst_x, dst_y, dst_w, dst_h,
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));
@ -1201,8 +1201,8 @@ _image_draw_thread_cmd(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc,
cr->image = src;
cr->surface = dst;
EINA_RECTANGLE_SET(&cr->src, src_region_x, src_region_y, src_region_w, src_region_h);
EINA_RECTANGLE_SET(&cr->dst, dst_region_x, dst_region_y, dst_region_w, dst_region_h);
EINA_RECTANGLE_SET(&cr->src, src_x, src_y, src_w, src_h);
EINA_RECTANGLE_SET(&cr->dst, dst_x, dst_y, dst_w, dst_h);
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
_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
(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,
1);
return _image_draw_thread_cmd(src, dst, dc,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h,
1);
}
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
(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,
0);
return _image_draw_thread_cmd(src, dst, dc,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h,
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
@ -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;
}
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_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_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);
return evas_common_rgba_image_scalecache_do_cbs(image, surface,
context, smooth,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h,
_image_thr_cb_sample,
_image_thr_cb_smooth);
}
#ifdef BUILD_PIPE_RENDER
else if ((cpunum > 1))
@ -1359,13 +1371,13 @@ image_loaded:
}
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;
DATA32 mul_col;
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,
if ((dst_w <= 0) || (dst_h <= 0)) return;
if (!(RECTS_INTERSECT(dst_x, dst_y, dst_w, dst_h,
0, 0, dst->cache_entry.w, dst->cache_entry.h))) return;
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;
if (smooth)
evas_common_scale_rgba_smooth_draw
(src, dst,
clip_x, clip_y, clip_w, clip_h,
mul_col, dc->render_op,
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_smooth_draw(src, dst,
clip_x, clip_y, clip_w, clip_h,
mul_col, dc->render_op,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h);
else
evas_common_scale_rgba_sample_draw
(src, dst,
clip_x, clip_y, clip_w, clip_h,
mul_col, dc->render_op,
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_sample_draw(src, dst,
clip_x, clip_y, clip_w, clip_h,
mul_col, dc->render_op,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h);
}
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,
src_region_x, src_region_y, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_w, dst_region_h,
0);
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h, 0);
return EINA_TRUE;
}
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,
src_region_x, src_region_y, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_w, dst_region_h,
1);
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h, 1);
return EINA_TRUE;
}
@ -1484,7 +1492,7 @@ _draw_thread_map_draw(void *data)
while ((m->count > 4) && (m->count - offset >= 3));
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);
}