summaryrefslogtreecommitdiff
path: root/src/static_libs/draw
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-12-03 15:29:32 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-12-03 18:42:50 +0900
commitb5500a864434f53240cb774c92731341b21ff3ad (patch)
tree4135624f595ef8133280335ab1e28432444a380f /src/static_libs/draw
parent4bcea3eada67332b61e175adabbcbe6dd07563f8 (diff)
Evas: Move alpha functions to static_libs/draw
This is a pretty simple code refactor, moving pixel handling to the new draw lib.
Diffstat (limited to 'src/static_libs/draw')
-rw-r--r--src/static_libs/draw/draw.h6
-rw-r--r--src/static_libs/draw/draw_alpha_main.c59
2 files changed, 63 insertions, 2 deletions
diff --git a/src/static_libs/draw/draw.h b/src/static_libs/draw/draw.h
index 466ef7c34f..c2f2370596 100644
--- a/src/static_libs/draw/draw.h
+++ b/src/static_libs/draw/draw.h
@@ -7,13 +7,15 @@
7 7
8#include <Efl.h> 8#include <Efl.h>
9 9
10typedef void (*RGBA_Comp_Func)(uint *dest, const uint *src, int length, uint mul_col, uint const_alpha); 10typedef void (*RGBA_Comp_Func) (uint *dest, const uint *src, int length, uint mul_col, uint const_alpha);
11typedef void (*RGBA_Comp_Func_Solid)(uint *dest, int length, uint color, uint const_alpha); 11typedef void (*RGBA_Comp_Func_Solid) (uint *dest, int length, uint color, uint const_alpha);
12typedef void (*Alpha_Gfx_Func) (uint8_t *src, uint8_t *dst, int len);
12 13
13int efl_draw_init(void); 14int efl_draw_init(void);
14 15
15RGBA_Comp_Func_Solid efl_draw_func_solid_span_get(Efl_Gfx_Render_Op op, uint color); 16RGBA_Comp_Func_Solid efl_draw_func_solid_span_get(Efl_Gfx_Render_Op op, uint color);
16RGBA_Comp_Func efl_draw_func_span_get(Efl_Gfx_Render_Op op, uint color, Eina_Bool src_alpha); 17RGBA_Comp_Func efl_draw_func_span_get(Efl_Gfx_Render_Op op, uint color, Eina_Bool src_alpha);
18Alpha_Gfx_Func efl_draw_alpha_func_get(Efl_Gfx_Render_Op op, Eina_Bool has_mask);
17 19
18 20
19/* common sw draw helpers */ 21/* common sw draw helpers */
diff --git a/src/static_libs/draw/draw_alpha_main.c b/src/static_libs/draw/draw_alpha_main.c
new file mode 100644
index 0000000000..ebd93e8daf
--- /dev/null
+++ b/src/static_libs/draw/draw_alpha_main.c
@@ -0,0 +1,59 @@
1#include "draw_private.h"
2
3/** default op: d = d*(1-sa) + s */
4static void
5_alpha_func_blend(uint8_t *src, uint8_t *dst, int len)
6{
7 int k;
8
9 EINA_SAFETY_ON_NULL_RETURN(src);
10 EINA_SAFETY_ON_NULL_RETURN(dst);
11
12 for (k = len; k; k--)
13 {
14 int val = (*dst * (255 - *src)) / 255 + *src;
15 *dst++ = val;
16 src++;
17 }
18}
19
20/** d = s */
21static void
22_alpha_func_copy(uint8_t *src, uint8_t *dst, int len)
23{
24 EINA_SAFETY_ON_NULL_RETURN(src);
25 EINA_SAFETY_ON_NULL_RETURN(dst);
26
27 memcpy(dst, src, len);
28}
29
30/** d = d*s */
31static void
32_alpha_func_mul(uint8_t *src, uint8_t *dst, int len)
33{
34 int k;
35
36 EINA_SAFETY_ON_NULL_RETURN(src);
37 EINA_SAFETY_ON_NULL_RETURN(dst);
38
39 for (k = len; k; k--)
40 {
41 int val = (*dst * *src) / 255;
42 *dst++ = val;
43 src++;
44 }
45}
46
47Alpha_Gfx_Func
48efl_draw_alpha_func_get(Efl_Gfx_Render_Op op, Eina_Bool has_mask)
49{
50 if (!has_mask)
51 {
52 if (op == EFL_GFX_RENDER_OP_BLEND)
53 return _alpha_func_blend;
54 else
55 return _alpha_func_copy;
56 }
57 else
58 return _alpha_func_mul;
59}