summaryrefslogtreecommitdiff
path: root/src/static_libs/draw
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-12-04 15:43:27 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-12-04 16:10:06 +0900
commit8f4018b690de4e052c7ac74c4d5933f6a0ccd9ee (patch)
treeb39cf5c6220722c299b1c66e7c0367c39edcc380 /src/static_libs/draw
parentecc7da9cbacaeda9d8bc414855e970cfc73d4612 (diff)
Evas filters: Implement mix3 func for rgba masking
This operation was faked by running a mul and a blend ops. Now they are combined into one. A GL shader should also be able to do this in a single pass.
Diffstat (limited to 'src/static_libs/draw')
-rw-r--r--src/static_libs/draw/draw.h3
-rw-r--r--src/static_libs/draw/draw_main.c82
2 files changed, 82 insertions, 3 deletions
diff --git a/src/static_libs/draw/draw.h b/src/static_libs/draw/draw.h
index 2a3d63575f..51bf917a30 100644
--- a/src/static_libs/draw/draw.h
+++ b/src/static_libs/draw/draw.h
@@ -11,6 +11,7 @@
11typedef void (*RGBA_Comp_Func) (uint32_t *dest, const uint32_t *src, int length, uint32_t mul_col, uint32_t const_alpha); 11typedef void (*RGBA_Comp_Func) (uint32_t *dest, const uint32_t *src, int length, uint32_t mul_col, uint32_t const_alpha);
12typedef void (*RGBA_Comp_Func_Solid) (uint32_t *dest, int length, uint32_t color, uint32_t const_alpha); 12typedef void (*RGBA_Comp_Func_Solid) (uint32_t *dest, int length, uint32_t color, uint32_t const_alpha);
13typedef void (*RGBA_Comp_Func_Mask) (uint32_t *dest, uint8_t *mask, int length, uint32_t color); 13typedef void (*RGBA_Comp_Func_Mask) (uint32_t *dest, uint8_t *mask, int length, uint32_t color);
14typedef void (*Draw_Func_ARGB_Mix3) (uint32_t *dest, uint32_t *src, uint32_t *mul, int len, uint32_t color);
14typedef void (*Alpha_Gfx_Func) (uint8_t *src, uint8_t *dst, int len); 15typedef void (*Alpha_Gfx_Func) (uint8_t *src, uint8_t *dst, int len);
15 16
16int efl_draw_init(void); 17int efl_draw_init(void);
@@ -18,6 +19,7 @@ int efl_draw_init(void);
18RGBA_Comp_Func efl_draw_func_span_get (Efl_Gfx_Render_Op op, uint32_t color, Eina_Bool src_alpha); 19RGBA_Comp_Func efl_draw_func_span_get (Efl_Gfx_Render_Op op, uint32_t color, Eina_Bool src_alpha);
19RGBA_Comp_Func_Solid efl_draw_func_solid_span_get (Efl_Gfx_Render_Op op, uint32_t color); 20RGBA_Comp_Func_Solid efl_draw_func_solid_span_get (Efl_Gfx_Render_Op op, uint32_t color);
20RGBA_Comp_Func_Mask efl_draw_func_mask_span_get (Efl_Gfx_Render_Op op, uint32_t color); 21RGBA_Comp_Func_Mask efl_draw_func_mask_span_get (Efl_Gfx_Render_Op op, uint32_t color);
22Draw_Func_ARGB_Mix3 efl_draw_func_argb_mix3_get (Efl_Gfx_Render_Op op, uint32_t color);
21Alpha_Gfx_Func efl_draw_alpha_func_get (Efl_Gfx_Render_Op op, Eina_Bool has_mask); 23Alpha_Gfx_Func efl_draw_alpha_func_get (Efl_Gfx_Render_Op op, Eina_Bool has_mask);
22 24
23 25
@@ -54,6 +56,7 @@ Alpha_Gfx_Func efl_draw_alpha_func_get (Efl_Gfx_Render_Op op, Eina_
54#define DRAW_ARGB_JOIN(a,r,g,b) \ 56#define DRAW_ARGB_JOIN(a,r,g,b) \
55 (((a) << 24) + ((r) << 16) + ((g) << 8) + (b)) 57 (((a) << 24) + ((r) << 16) + ((g) << 8) + (b))
56 58
59/* argb multiply */
57#define DRAW_MUL4_SYM(x, y) \ 60#define DRAW_MUL4_SYM(x, y) \
58 ( ((((((x) >> 16) & 0xff00) * (((y) >> 16) & 0xff00)) + 0xff0000) & 0xff000000) + \ 61 ( ((((((x) >> 16) & 0xff00) * (((y) >> 16) & 0xff00)) + 0xff0000) & 0xff000000) + \
59 ((((((x) >> 8) & 0xff00) * (((y) >> 16) & 0xff)) + 0xff00) & 0xff0000) + \ 62 ((((((x) >> 8) & 0xff00) * (((y) >> 16) & 0xff)) + 0xff00) & 0xff0000) + \
diff --git a/src/static_libs/draw/draw_main.c b/src/static_libs/draw/draw_main.c
index 915adf1e44..0e423aaa38 100644
--- a/src/static_libs/draw/draw_main.c
+++ b/src/static_libs/draw/draw_main.c
@@ -138,12 +138,15 @@ _comp_func_mask_blend(uint32_t *dest, uint8_t *mask, int length, uint32_t color)
138 138
139 for (k = 0; k < length; k++, dest++, mask++) 139 for (k = 0; k < length; k++, dest++, mask++)
140 { 140 {
141 uint32_t c = draw_mul_256(*mask, color); 141 uint32_t c = draw_mul_256((*mask + 1), color);
142 int a = 256 - (c >> 24); 142 int a = 256 - (c >> 24);
143 *dest = c + draw_mul_256(a, *dest); 143 *dest = c + draw_mul_256(a, *dest);
144 } 144 }
145} 145}
146 146
147/* s = m * color
148 * d = s * sa
149 */
147static void 150static void
148_comp_func_mask_copy(uint32_t *dest, uint8_t *mask, int length, uint32_t color) 151_comp_func_mask_copy(uint32_t *dest, uint8_t *mask, int length, uint32_t color)
149{ 152{
@@ -151,8 +154,65 @@ _comp_func_mask_copy(uint32_t *dest, uint8_t *mask, int length, uint32_t color)
151 154
152 for (k = 0; k < length; k++, dest++, mask++) 155 for (k = 0; k < length; k++, dest++, mask++)
153 { 156 {
154 int a = (*mask & 0x80) ? *mask + 1 : *mask; 157 *dest = draw_mul_256(*mask + 1, color);
155 *dest = draw_mul_256(a, color); 158 }
159}
160
161/* w = s * m * c
162 * d = d * (1-wa) + w * wa
163 */
164static void
165_comp_func_mix3_blend(uint32_t *dest, uint32_t *src, uint32_t *mul, int len, uint32_t color)
166{
167 int k, a;
168
169 for (k = 0; k < len; k++, dest++, src++, mul++)
170 {
171 uint32_t c = DRAW_MUL4_SYM(*mul, color);
172 c = DRAW_MUL4_SYM(c, *src);
173 a = 256 - (c >> 24);
174 *dest = c + draw_mul_256(a, *dest);
175 }
176}
177
178/* d = s * m * c */
179static void
180_comp_func_mix3_copy(uint32_t *dest, uint32_t *src, uint32_t *mul, int len, uint32_t color)
181{
182 int k;
183
184 for (k = 0; k < len; k++, dest++, src++, mul++)
185 {
186 uint32_t c = DRAW_MUL4_SYM(*mul, color);
187 *dest = DRAW_MUL4_SYM(c, *src);
188 }
189}
190
191/* w = s * m
192 * d = d * (1-wa) + w * wa
193 */
194static void
195_comp_func_mix3_blend_nomul(uint32_t *dest, uint32_t *src, uint32_t *mul, int len, uint32_t color EINA_UNUSED)
196{
197 int k, a;
198
199 for (k = 0; k < len; k++, dest++, src++, mul++)
200 {
201 uint32_t c = DRAW_MUL4_SYM(*mul, *src);
202 a = 256 - (c >> 24);
203 *dest = c + draw_mul_256(a, *dest);
204 }
205}
206
207/* d = s * m */
208static void
209_comp_func_mix3_copy_nomul(uint32_t *dest, uint32_t *src, uint32_t *mul, int len, uint32_t color EINA_UNUSED)
210{
211 int k;
212
213 for (k = 0; k < len; k++, dest++, src++, mul++)
214 {
215 *dest = DRAW_MUL4_SYM(*mul, *src);
156 } 216 }
157} 217}
158 218
@@ -171,12 +231,28 @@ RGBA_Comp_Func func_for_mode[EFL_GFX_RENDER_OP_LAST] = {
171 _comp_func_source 231 _comp_func_source
172}; 232};
173 233
234Draw_Func_ARGB_Mix3 func_for_mode_argb_mix3[EFL_GFX_RENDER_OP_LAST * 2] = {
235 _comp_func_mix3_blend,
236 _comp_func_mix3_copy,
237 _comp_func_mix3_blend_nomul,
238 _comp_func_mix3_copy_nomul
239};
240
174RGBA_Comp_Func_Mask 241RGBA_Comp_Func_Mask
175efl_draw_func_mask_span_get(Efl_Gfx_Render_Op op, uint32_t color EINA_UNUSED) 242efl_draw_func_mask_span_get(Efl_Gfx_Render_Op op, uint32_t color EINA_UNUSED)
176{ 243{
177 return func_for_mode_mask[op]; 244 return func_for_mode_mask[op];
178} 245}
179 246
247Draw_Func_ARGB_Mix3
248efl_draw_func_argb_mix3_get(Efl_Gfx_Render_Op op, uint32_t color)
249{
250 if (color == 0xffffffff)
251 return func_for_mode_argb_mix3[op + 2];
252 else
253 return func_for_mode_argb_mix3[op];
254}
255
180RGBA_Comp_Func_Solid 256RGBA_Comp_Func_Solid
181efl_draw_func_solid_span_get(Efl_Gfx_Render_Op op, uint32_t color) 257efl_draw_func_solid_span_get(Efl_Gfx_Render_Op op, uint32_t color)
182{ 258{