summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/software_generic/filters
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-12-14 17:22:09 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-12-14 18:03:49 +0900
commit88bfba1fdd35e3aadd4c3fde266cc48c2544db32 (patch)
tree160c62a43e4eec03191d207e4c59c600bf6e1a11 /src/modules/evas/engines/software_generic/filters
parent8bb03d8170219211be16974792d55f579806aa0d (diff)
evas filters: Add "alphaonly" flag for blend and blur
This is very useful to specify precisely which kind of RGBA -> Alpha conversion you want. If all you wanted was the alpha layer to use as a mask, set this flag to true. @feature
Diffstat (limited to 'src/modules/evas/engines/software_generic/filters')
-rw-r--r--src/modules/evas/engines/software_generic/filters/evas_filter_blend.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/modules/evas/engines/software_generic/filters/evas_filter_blend.c b/src/modules/evas/engines/software_generic/filters/evas_filter_blend.c
index 5573010b9f..12745c4037 100644
--- a/src/modules/evas/engines/software_generic/filters/evas_filter_blend.c
+++ b/src/modules/evas/engines/software_generic/filters/evas_filter_blend.c
@@ -8,11 +8,12 @@
8typedef Eina_Bool (*draw_func) (void *context, const void *src_map, unsigned int src_stride, void *dst_map, unsigned int dst_stride, 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, Eina_Bool do_async); 8typedef Eina_Bool (*draw_func) (void *context, const void *src_map, unsigned int src_stride, void *dst_map, unsigned int dst_stride, 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, Eina_Bool do_async);
9static Eina_Bool _mapped_blend(void *drawctx, const void *src_map, unsigned int src_stride, void *dst_map, unsigned int dst_stride, Evas_Filter_Fill_Mode fillmode, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, draw_func image_draw); 9static Eina_Bool _mapped_blend(void *drawctx, const void *src_map, unsigned int src_stride, void *dst_map, unsigned int dst_stride, Evas_Filter_Fill_Mode fillmode, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, draw_func image_draw);
10 10
11struct Filter_Blend_Draw_Context 11typedef struct _Filter_Blend_Draw_Context
12{ 12{
13 Efl_Gfx_Render_Op rop; 13 Efl_Gfx_Render_Op rop;
14 uint32_t color; 14 uint32_t color;
15}; 15 Eina_Bool alphaonly;
16} Filter_Blend_Draw_Context;
16 17
17#define LINELEN(stride, ptr) (stride / (sizeof(*ptr))) 18#define LINELEN(stride, ptr) (stride / (sizeof(*ptr)))
18 19
@@ -25,7 +26,7 @@ _image_draw_cpu_alpha_alpha(void *context,
25 int smooth EINA_UNUSED, 26 int smooth EINA_UNUSED,
26 Eina_Bool do_async EINA_UNUSED) 27 Eina_Bool do_async EINA_UNUSED)
27{ 28{
28 struct Filter_Blend_Draw_Context *dc = context; 29 Filter_Blend_Draw_Context *dc = context;
29 const uint8_t *srcdata = src_map; 30 const uint8_t *srcdata = src_map;
30 uint8_t *dstdata = dst_map; 31 uint8_t *dstdata = dst_map;
31 Draw_Func_Alpha func; 32 Draw_Func_Alpha func;
@@ -60,7 +61,7 @@ _image_draw_cpu_alpha_rgba(void *context,
60 int smooth EINA_UNUSED, 61 int smooth EINA_UNUSED,
61 Eina_Bool do_async EINA_UNUSED) 62 Eina_Bool do_async EINA_UNUSED)
62{ 63{
63 struct Filter_Blend_Draw_Context *dc = context; 64 Filter_Blend_Draw_Context *dc = context;
64 uint8_t *srcdata = (uint8_t *) src_map; 65 uint8_t *srcdata = (uint8_t *) src_map;
65 uint32_t *dstdata = dst_map; 66 uint32_t *dstdata = dst_map;
66 RGBA_Comp_Func_Mask func; 67 RGBA_Comp_Func_Mask func;
@@ -95,7 +96,7 @@ _image_draw_cpu_rgba_rgba(void *context,
95 int smooth EINA_UNUSED, 96 int smooth EINA_UNUSED,
96 Eina_Bool do_async EINA_UNUSED) 97 Eina_Bool do_async EINA_UNUSED)
97{ 98{
98 struct Filter_Blend_Draw_Context *dc = context; 99 Filter_Blend_Draw_Context *dc = context;
99 uint32_t *srcdata = (uint32_t *) src_map; 100 uint32_t *srcdata = (uint32_t *) src_map;
100 uint32_t *dstdata = dst_map; 101 uint32_t *dstdata = dst_map;
101 RGBA_Comp_Func func; 102 RGBA_Comp_Func func;
@@ -125,7 +126,7 @@ _image_draw_cpu_rgba_rgba(void *context,
125} 126}
126 127
127static Eina_Bool 128static Eina_Bool
128_image_draw_cpu_rgba_alpha(void *context EINA_UNUSED, 129_image_draw_cpu_rgba_alpha(void *context,
129 const void *src_map, unsigned int src_stride, 130 const void *src_map, unsigned int src_stride,
130 void *dst_map, unsigned int dst_stride, 131 void *dst_map, unsigned int dst_stride,
131 int src_x, int src_y, int src_w, int src_h, 132 int src_x, int src_y, int src_w, int src_h,
@@ -133,6 +134,8 @@ _image_draw_cpu_rgba_alpha(void *context EINA_UNUSED,
133 int smooth EINA_UNUSED, 134 int smooth EINA_UNUSED,
134 Eina_Bool do_async EINA_UNUSED) 135 Eina_Bool do_async EINA_UNUSED)
135{ 136{
137 Filter_Blend_Draw_Context *dc = context;
138 Eina_Bool alphaonly = dc && dc->alphaonly;
136 uint32_t *srcdata = (uint32_t *) src_map; 139 uint32_t *srcdata = (uint32_t *) src_map;
137 uint8_t *dstdata = dst_map; 140 uint8_t *dstdata = dst_map;
138 int x, y, sw, dw; 141 int x, y, sw, dw;
@@ -156,14 +159,30 @@ _image_draw_cpu_rgba_alpha(void *context EINA_UNUSED,
156 159
157 srcdata += src_y * sw; 160 srcdata += src_y * sw;
158 dstdata += dst_y * dw; 161 dstdata += dst_y * dw;
159 for (y = src_h; y; y--) 162
163 if (!alphaonly)
160 { 164 {
161 uint32_t *s = srcdata + src_x; 165 for (y = src_h; y; y--)
162 uint8_t *d = dstdata + dst_x; 166 {
163 for (x = src_w; x; x--, d++, s++) 167 uint32_t *s = srcdata + src_x;
164 *d = DIVIDE((R_VAL(s) * WR) + (G_VAL(s) * WG) + (B_VAL(s) * WB)); 168 uint8_t *d = dstdata + dst_x;
165 srcdata += sw; 169 for (x = src_w; x; x--, d++, s++)
166 dstdata += dw; 170 *d = (uint8_t) DIVIDE((R_VAL(s) * WR) + (G_VAL(s) * WG) + (B_VAL(s) * WB));
171 srcdata += sw;
172 dstdata += dw;
173 }
174 }
175 else
176 {
177 for (y = src_h; y; y--)
178 {
179 uint32_t *s = srcdata + src_x;
180 uint8_t *d = dstdata + dst_x;
181 for (x = src_w; x; x--, d++, s++)
182 *d = A_VAL(s);
183 srcdata += sw;
184 dstdata += dw;
185 }
167 } 186 }
168 187
169 return EINA_TRUE; 188 return EINA_TRUE;
@@ -174,7 +193,7 @@ _filter_blend_cpu_generic_do(Evas_Filter_Command *cmd, draw_func image_draw)
174{ 193{
175 unsigned int src_len, src_stride, dst_len, dst_stride; 194 unsigned int src_len, src_stride, dst_len, dst_stride;
176 int sw, sh, dx, dy, dw, dh, sx, sy; 195 int sw, sh, dx, dy, dw, dh, sx, sy;
177 struct Filter_Blend_Draw_Context dc; 196 Filter_Blend_Draw_Context dc;
178 Eina_Bool ret = EINA_FALSE; 197 Eina_Bool ret = EINA_FALSE;
179 Evas_Filter_Buffer *src_fb; 198 Evas_Filter_Buffer *src_fb;
180 void *src = NULL, *dst = NULL; 199 void *src = NULL, *dst = NULL;
@@ -220,6 +239,7 @@ _filter_blend_cpu_generic_do(Evas_Filter_Command *cmd, draw_func image_draw)
220 EINA_SAFETY_ON_FALSE_GOTO(src && dst, end); 239 EINA_SAFETY_ON_FALSE_GOTO(src && dst, end);
221 240
222 dc.rop = cmd->draw.rop; 241 dc.rop = cmd->draw.rop;
242 dc.alphaonly = cmd->draw.alphaonly;
223 dc.color = ARGB_JOIN(cmd->draw.A, cmd->draw.R, cmd->draw.G, cmd->draw.B); 243 dc.color = ARGB_JOIN(cmd->draw.A, cmd->draw.R, cmd->draw.G, cmd->draw.B);
224 244
225 ret = _mapped_blend(&dc, src, src_stride, dst, dst_stride, cmd->draw.fillmode, 245 ret = _mapped_blend(&dc, src, src_stride, dst, dst_stride, cmd->draw.fillmode,