forked from enlightenment/efl
evas/scale_sample: further deduplicate masking code
Summary: by adding a couple extra params to existing functions, we can reuse existing code instead of copying it around and adding more bugs no functional changes Depends on D8846 Reviewers: segfaultxavi Reviewed By: segfaultxavi Subscribers: segfaultxavi, cedric, #reviewers, #committers Tags: #efl_rendering Differential Revision: https://phab.enlightenment.org/D8847
This commit is contained in:
parent
4542cfcbea
commit
6d0233afb8
|
@ -100,18 +100,22 @@ static void
|
||||||
_evas_common_scale_rgba_sample_scale_nomask(int y,
|
_evas_common_scale_rgba_sample_scale_nomask(int y,
|
||||||
int dst_clip_w, int dst_clip_h, int dst_w,
|
int dst_clip_w, int dst_clip_h, int dst_w,
|
||||||
DATA32 **row_ptr, int *lin_ptr,
|
DATA32 **row_ptr, int *lin_ptr,
|
||||||
DATA32 *dptr, RGBA_Gfx_Func func, unsigned int mul_col)
|
DATA32 *dptr, RGBA_Gfx_Func func, unsigned int mul_col,
|
||||||
|
DATA32 *srcptr, int src_w)
|
||||||
{
|
{
|
||||||
DATA32 *buf, *dst_ptr;
|
DATA32 *buf;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
/* a scanline buffer */
|
/* a scanline buffer */
|
||||||
|
if (!srcptr)
|
||||||
buf = alloca(dst_clip_w * sizeof(DATA32));
|
buf = alloca(dst_clip_w * sizeof(DATA32));
|
||||||
|
|
||||||
dptr = dptr + dst_w * y;
|
dptr = dptr + dst_w * y;
|
||||||
for (; y < dst_clip_h; y++)
|
for (; y < dst_clip_h; y++)
|
||||||
{
|
{
|
||||||
dst_ptr = buf;
|
if (!srcptr)
|
||||||
|
{
|
||||||
|
DATA32 *dst_ptr = buf;
|
||||||
for (x = 0; x < dst_clip_w; x++)
|
for (x = 0; x < dst_clip_w; x++)
|
||||||
{
|
{
|
||||||
DATA32 *ptr;
|
DATA32 *ptr;
|
||||||
|
@ -120,11 +124,13 @@ _evas_common_scale_rgba_sample_scale_nomask(int y,
|
||||||
*dst_ptr = *ptr;
|
*dst_ptr = *ptr;
|
||||||
dst_ptr++;
|
dst_ptr++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* * blend here [clip_w *] buf -> dptr * */
|
/* * blend here [clip_w *] buf -> dptr * */
|
||||||
func(buf, NULL, mul_col, dptr, dst_clip_w);
|
func(srcptr ?: buf, NULL, mul_col, dptr, dst_clip_w);
|
||||||
|
|
||||||
dptr += dst_w;
|
dptr += dst_w;
|
||||||
|
if (srcptr) srcptr += src_w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,9 +141,10 @@ _evas_common_scale_rgba_sample_scale_mask(int y,
|
||||||
int mask_x, int mask_y,
|
int mask_x, int mask_y,
|
||||||
DATA32 **row_ptr, int *lin_ptr, RGBA_Image *mask_ie,
|
DATA32 **row_ptr, int *lin_ptr, RGBA_Image *mask_ie,
|
||||||
DATA32 *dptr, RGBA_Gfx_Func func, RGBA_Gfx_Func func2,
|
DATA32 *dptr, RGBA_Gfx_Func func, RGBA_Gfx_Func func2,
|
||||||
unsigned int mul_col)
|
unsigned int mul_col,
|
||||||
|
DATA32 *srcptr, int src_w)
|
||||||
{
|
{
|
||||||
DATA32 *buf, *dst_ptr;
|
DATA32 *buf;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
/* clamp/map to mask geometry */
|
/* clamp/map to mask geometry */
|
||||||
|
@ -158,11 +165,13 @@ _evas_common_scale_rgba_sample_scale_mask(int y,
|
||||||
{
|
{
|
||||||
DATA8 *mask;
|
DATA8 *mask;
|
||||||
|
|
||||||
dst_ptr = buf;
|
|
||||||
mask = mask_ie->image.data8
|
mask = mask_ie->image.data8
|
||||||
+ ((dst_clip_y - mask_y + y) * mask_ie->cache_entry.w)
|
+ ((dst_clip_y - mask_y + y) * mask_ie->cache_entry.w)
|
||||||
+ (dst_clip_x - mask_x);
|
+ (dst_clip_x - mask_x);
|
||||||
|
|
||||||
|
if (!srcptr)
|
||||||
|
{
|
||||||
|
DATA32 *dst_ptr = buf;
|
||||||
for (x = 0; x < dst_clip_w; x++)
|
for (x = 0; x < dst_clip_w; x++)
|
||||||
{
|
{
|
||||||
DATA32 *ptr;
|
DATA32 *ptr;
|
||||||
|
@ -171,12 +180,19 @@ _evas_common_scale_rgba_sample_scale_mask(int y,
|
||||||
*dst_ptr = *ptr;
|
*dst_ptr = *ptr;
|
||||||
dst_ptr++;
|
dst_ptr++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* * blend here [clip_w *] buf -> dptr * */
|
/* * blend here [clip_w *] buf -> dptr * */
|
||||||
if (mul_col != 0xFFFFFFFF) func2(buf, NULL, mul_col, buf, dst_clip_w);
|
if (mul_col != 0xFFFFFFFF)
|
||||||
|
{
|
||||||
|
func2(srcptr ?: buf, NULL, mul_col, buf, dst_clip_w);
|
||||||
func(buf, mask, 0, dptr, dst_clip_w);
|
func(buf, mask, 0, dptr, dst_clip_w);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
func(srcptr ?: buf, mask, 0, dptr, dst_clip_w);
|
||||||
|
|
||||||
dptr += dst_w;
|
dptr += dst_w;
|
||||||
|
if (srcptr) srcptr += src_w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,10 +201,8 @@ evas_common_scale_rgba_sample_draw(RGBA_Image *src, RGBA_Image *dst, int dst_cli
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
int *lin_ptr;
|
int *lin_ptr;
|
||||||
DATA32 *buf, *dptr;
|
|
||||||
DATA32 **row_ptr;
|
DATA32 **row_ptr;
|
||||||
DATA32 *ptr, *dst_ptr, *src_data, *dst_data;
|
DATA32 *ptr, *dst_ptr, *src_data, *dst_data;
|
||||||
DATA8 *mask;
|
|
||||||
int src_w, src_h, dst_w, dst_h;
|
int src_w, src_h, dst_w, dst_h;
|
||||||
RGBA_Gfx_Func func, func2 = NULL;
|
RGBA_Gfx_Func func, func2 = NULL;
|
||||||
|
|
||||||
|
@ -353,42 +367,22 @@ evas_common_scale_rgba_sample_draw(RGBA_Image *src, RGBA_Image *dst, int dst_cli
|
||||||
{
|
{
|
||||||
ptr = src_data + (((dst_clip_y - dst_region_y) + src_region_y) * src_w) + ((dst_clip_x - dst_region_x) + src_region_x);
|
ptr = src_data + (((dst_clip_y - dst_region_y) + src_region_y) * src_w) + ((dst_clip_x - dst_region_x) + src_region_x);
|
||||||
|
|
||||||
/* image masking */
|
|
||||||
if (mask_ie)
|
if (mask_ie)
|
||||||
{
|
_evas_common_scale_rgba_sample_scale_mask(0,
|
||||||
if (mul_col != 0xffffffff)
|
dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h,
|
||||||
buf = alloca(dst_clip_w * sizeof(DATA32));
|
dst_w, mask_x, mask_y,
|
||||||
|
NULL, NULL,
|
||||||
for (y = 0; y < dst_clip_h; y++)
|
mask_ie, dst_ptr,
|
||||||
{
|
func, func2, mul_col,
|
||||||
mask = mask_ie->image.data8
|
ptr, src_w);
|
||||||
+ ((dst_clip_y - mask_y + y) * mask_ie->cache_entry.w)
|
|
||||||
+ (dst_clip_x - mask_x);
|
|
||||||
|
|
||||||
/* * blend here [clip_w *] ptr -> dst_ptr * */
|
|
||||||
if (mul_col != 0xffffffff)
|
|
||||||
{
|
|
||||||
func2(ptr, NULL, mul_col, buf, dst_clip_w);
|
|
||||||
func(buf, mask, 0, dst_ptr, dst_clip_w);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
func(ptr, mask, 0, dst_ptr, dst_clip_w);
|
_evas_common_scale_rgba_sample_scale_nomask(0,
|
||||||
|
dst_clip_w, dst_clip_h, dst_w,
|
||||||
ptr += src_w;
|
NULL, NULL,
|
||||||
dst_ptr += dst_w;
|
dst_ptr,
|
||||||
}
|
func, mul_col,
|
||||||
}
|
ptr, src_w);
|
||||||
else
|
|
||||||
{
|
|
||||||
for (y = 0; y < dst_clip_h; y++)
|
|
||||||
{
|
|
||||||
/* * blend here [clip_w *] ptr -> dst_ptr * */
|
|
||||||
func(ptr, NULL, mul_col, dst_ptr, dst_clip_w);
|
|
||||||
|
|
||||||
ptr += src_w;
|
|
||||||
dst_ptr += dst_w;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -409,13 +403,15 @@ evas_common_scale_rgba_sample_draw(RGBA_Image *src, RGBA_Image *dst, int dst_cli
|
||||||
dst_w, mask_x, mask_y,
|
dst_w, mask_x, mask_y,
|
||||||
row_ptr, lin_ptr,
|
row_ptr, lin_ptr,
|
||||||
mask_ie, dst_ptr,
|
mask_ie, dst_ptr,
|
||||||
func, func2, mul_col);
|
func, func2, mul_col,
|
||||||
|
NULL, 0);
|
||||||
else
|
else
|
||||||
_evas_common_scale_rgba_sample_scale_nomask(0,
|
_evas_common_scale_rgba_sample_scale_nomask(0,
|
||||||
dst_clip_w, dst_clip_h, dst_w,
|
dst_clip_w, dst_clip_h, dst_w,
|
||||||
row_ptr, lin_ptr,
|
row_ptr, lin_ptr,
|
||||||
dst_ptr,
|
dst_ptr,
|
||||||
func, mul_col);
|
func, mul_col,
|
||||||
|
NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +726,8 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
|
||||||
dst_clip_w, dst_clip_h >> 1, dst_w,
|
dst_clip_w, dst_clip_h >> 1, dst_w,
|
||||||
dc->clip.mask_x, dc->clip.mask_y,
|
dc->clip.mask_x, dc->clip.mask_y,
|
||||||
row_ptr, lin_ptr, dc->clip.mask,
|
row_ptr, lin_ptr, dc->clip.mask,
|
||||||
dptr, func, func2, mul_col);
|
dptr, func, func2, mul_col,
|
||||||
|
NULL, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -738,7 +735,8 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
|
||||||
_evas_common_scale_rgba_sample_scale_nomask(0,
|
_evas_common_scale_rgba_sample_scale_nomask(0,
|
||||||
dst_clip_w, dst_clip_h >> 1, dst_w,
|
dst_clip_w, dst_clip_h >> 1, dst_w,
|
||||||
row_ptr, lin_ptr,
|
row_ptr, lin_ptr,
|
||||||
dptr, func, mul_col);
|
dptr, func, mul_col,
|
||||||
|
NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = eina_thread_queue_wait(main_queue, &ref);
|
msg = eina_thread_queue_wait(main_queue, &ref);
|
||||||
|
@ -756,7 +754,8 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
|
||||||
dst_clip_w, dst_clip_h, dst_w,
|
dst_clip_w, dst_clip_h, dst_w,
|
||||||
dc->clip.mask_x, dc->clip.mask_y,
|
dc->clip.mask_x, dc->clip.mask_y,
|
||||||
row_ptr, lin_ptr, dc->clip.mask,
|
row_ptr, lin_ptr, dc->clip.mask,
|
||||||
dptr, func, func2, mul_col);
|
dptr, func, func2, mul_col,
|
||||||
|
NULL, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -764,7 +763,8 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
|
||||||
_evas_common_scale_rgba_sample_scale_nomask(0,
|
_evas_common_scale_rgba_sample_scale_nomask(0,
|
||||||
dst_clip_w, dst_clip_h, dst_w,
|
dst_clip_w, dst_clip_h, dst_w,
|
||||||
row_ptr, lin_ptr,
|
row_ptr, lin_ptr,
|
||||||
dptr, func, mul_col);
|
dptr, func, mul_col,
|
||||||
|
NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -807,13 +807,15 @@ _evas_common_scale_sample_thread(void *data EINA_UNUSED,
|
||||||
todo->mask_x, todo->mask_y,
|
todo->mask_x, todo->mask_y,
|
||||||
todo->row_ptr, todo->lin_ptr, todo->mask8,
|
todo->row_ptr, todo->lin_ptr, todo->mask8,
|
||||||
todo->dptr, todo->func, todo->func2,
|
todo->dptr, todo->func, todo->func2,
|
||||||
todo->mul_col);
|
todo->mul_col,
|
||||||
|
NULL, 0);
|
||||||
else
|
else
|
||||||
_evas_common_scale_rgba_sample_scale_nomask(h,
|
_evas_common_scale_rgba_sample_scale_nomask(h,
|
||||||
todo->dst_clip_w, todo->dst_clip_h,
|
todo->dst_clip_w, todo->dst_clip_h,
|
||||||
todo->dst_w,
|
todo->dst_w,
|
||||||
todo->row_ptr, todo->lin_ptr,
|
todo->row_ptr, todo->lin_ptr,
|
||||||
todo->dptr, todo->func, todo->mul_col);
|
todo->dptr, todo->func, todo->mul_col,
|
||||||
|
NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
Loading…
Reference in New Issue