summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Evas.am5
-rw-r--r--src/lib/evas/common/evas_alpha_main.c81
-rw-r--r--src/lib/evas/common/evas_blend_private.h4
-rw-r--r--src/lib/evas/common/evas_font_compress.c3
-rw-r--r--src/lib/evas/filters/evas_filter_blend.c3
-rw-r--r--src/lib/evas/filters/evas_filter_mask.c6
-rw-r--r--src/lib/evas/include/evas_common_private.h1
-rw-r--r--src/static_libs/draw/draw.h6
-rw-r--r--src/static_libs/draw/draw_alpha_main.c59
9 files changed, 74 insertions, 94 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 8f234af829..1f52b28512 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -259,6 +259,10 @@ lib/evas/canvas/evas_vg_gradient_radial.c \
259lib/evas/canvas/evas_vg_utils.c \ 259lib/evas/canvas/evas_vg_utils.c \
260lib/evas/canvas/evas_vg_shape.c 260lib/evas/canvas/evas_vg_shape.c
261 261
262# Static draw lib
263lib_evas_libevas_la_SOURCES += \
264static_libs/draw/draw_alpha_main.c
265
262# Engine 266# Engine
263lib_evas_libevas_la_SOURCES += \ 267lib_evas_libevas_la_SOURCES += \
264lib/evas/common/evas_op_copy_main_.c \ 268lib/evas/common/evas_op_copy_main_.c \
@@ -267,7 +271,6 @@ lib/evas/common/evas_op_add_main_.c \
267lib/evas/common/evas_op_sub_main_.c \ 271lib/evas/common/evas_op_sub_main_.c \
268lib/evas/common/evas_op_mask_main_.c \ 272lib/evas/common/evas_op_mask_main_.c \
269lib/evas/common/evas_op_mul_main_.c \ 273lib/evas/common/evas_op_mul_main_.c \
270lib/evas/common/evas_alpha_main.c \
271lib/evas/common/evas_blend_main.c \ 274lib/evas/common/evas_blend_main.c \
272lib/evas/common/evas_blit_main.c \ 275lib/evas/common/evas_blit_main.c \
273lib/evas/common/evas_convert_color.c \ 276lib/evas/common/evas_convert_color.c \
diff --git a/src/lib/evas/common/evas_alpha_main.c b/src/lib/evas/common/evas_alpha_main.c
deleted file mode 100644
index 74bc75b176..0000000000
--- a/src/lib/evas/common/evas_alpha_main.c
+++ /dev/null
@@ -1,81 +0,0 @@
1#include "evas_common_private.h"
2#include "evas_blend_private.h"
3
4/** default op: d = d*(1-sa) + s */
5static void
6_alpha_func_blend(DATA8 *src, DATA8 *dst, int len)
7{
8 int k;
9
10 EINA_SAFETY_ON_NULL_RETURN(src);
11 EINA_SAFETY_ON_NULL_RETURN(dst);
12
13 for (k = len; k; k--)
14 {
15 int val = (*dst * (255 - *src)) / 255 + *src;
16 *dst++ = val;
17 src++;
18 }
19}
20
21/** d = s */
22static void
23_alpha_func_copy(DATA8 *src, DATA8 *dst, int len)
24{
25 EINA_SAFETY_ON_NULL_RETURN(src);
26 EINA_SAFETY_ON_NULL_RETURN(dst);
27
28 memcpy(dst, src, len);
29}
30
31/** d = d*s */
32static void
33_alpha_func_mul(DATA8 *src, DATA8 *dst, int len)
34{
35 int k;
36
37 EINA_SAFETY_ON_NULL_RETURN(src);
38 EINA_SAFETY_ON_NULL_RETURN(dst);
39
40 for (k = len; k; k--)
41 {
42 int val = (*dst * *src) / 255;
43 *dst++ = val;
44 src++;
45 }
46}
47
48
49#if 0
50// Reference ops. In case of alpha, s == sa.
51EVAS_RENDER_BLEND = 0, /**< default op: d = d*(1-sa) + s */
52EVAS_RENDER_BLEND_REL = 1, /**< d = d*(1 - sa) + s*da */
53EVAS_RENDER_COPY = 2, /**< d = s */
54EVAS_RENDER_COPY_REL = 3, /**< d = s*da */
55EVAS_RENDER_ADD = 4, /* d = d + s */
56EVAS_RENDER_ADD_REL = 5, /**< d = d + s*da */
57EVAS_RENDER_SUB = 6, /**< d = d - s */
58EVAS_RENDER_SUB_REL = 7, /* d = d - s*da */
59EVAS_RENDER_TINT = 8, /**< d = d*s + d*(1 - sa) + s*(1 - da) */
60EVAS_RENDER_TINT_REL = 9, /**< d = d*(1 - sa + s) */
61EVAS_RENDER_MASK = 10, /**< d = d*sa */
62EVAS_RENDER_MUL = 11, /**< d = d*s */
63#endif
64
65Alpha_Gfx_Func
66evas_common_alpha_func_get(int op)
67{
68 switch (op)
69 {
70 case EVAS_RENDER_BLEND:
71 return _alpha_func_blend;
72 case EVAS_RENDER_COPY:
73 return _alpha_func_copy;
74 case EVAS_RENDER_MASK:
75 case EVAS_RENDER_MUL:
76 return _alpha_func_mul;
77 default:
78 ERR("Not implemented yet.");
79 return NULL;
80 }
81}
diff --git a/src/lib/evas/common/evas_blend_private.h b/src/lib/evas/common/evas_blend_private.h
index f96e004985..5b17993244 100644
--- a/src/lib/evas/common/evas_blend_private.h
+++ b/src/lib/evas/common/evas_blend_private.h
@@ -27,8 +27,4 @@ RGBA_Gfx_Pt_Func evas_common_gfx_func_composite_pixel_color_pt_get (Eina_B
27RGBA_Gfx_Pt_Func evas_common_gfx_func_composite_mask_color_pt_get (DATA32 col, Eina_Bool dst_alpha, int op); 27RGBA_Gfx_Pt_Func evas_common_gfx_func_composite_mask_color_pt_get (DATA32 col, Eina_Bool dst_alpha, int op);
28RGBA_Gfx_Pt_Func evas_common_gfx_func_composite_pixel_mask_pt_get (Eina_Bool src_alpha, Eina_Bool dst_alpha, int op); 28RGBA_Gfx_Pt_Func evas_common_gfx_func_composite_pixel_mask_pt_get (Eina_Bool src_alpha, Eina_Bool dst_alpha, int op);
29 29
30/* Alpha/mask functions */
31Alpha_Gfx_Func evas_common_alpha_func_get (int op);
32
33
34#endif /* _EVAS_BLEND_PRIVATE_H */ 30#endif /* _EVAS_BLEND_PRIVATE_H */
diff --git a/src/lib/evas/common/evas_font_compress.c b/src/lib/evas/common/evas_font_compress.c
index 1e13e53d74..7788ba52ea 100644
--- a/src/lib/evas/common/evas_font_compress.c
+++ b/src/lib/evas/common/evas_font_compress.c
@@ -9,6 +9,7 @@
9 9
10#include "evas_font_private.h" 10#include "evas_font_private.h"
11#include "evas_blend_private.h" 11#include "evas_blend_private.h"
12#include "draw.h"
12 13
13#ifdef EVAS_CSERVE2 14#ifdef EVAS_CSERVE2
14# include "../cserve2/evas_cs2_private.h" 15# include "../cserve2/evas_cs2_private.h"
@@ -512,7 +513,7 @@ evas_common_font_glyph_draw(RGBA_Font_Glyph *fg,
512 DATA8 *src8; 513 DATA8 *src8;
513 int row; 514 int row;
514 515
515 func = evas_common_alpha_func_get(dc->render_op); 516 func = efl_draw_alpha_func_get(dc->render_op, EINA_FALSE);
516 src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL); 517 src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL);
517 if (!src8) return; 518 if (!src8) return;
518 519
diff --git a/src/lib/evas/filters/evas_filter_blend.c b/src/lib/evas/filters/evas_filter_blend.c
index 17be2bc3f8..407563afef 100644
--- a/src/lib/evas/filters/evas_filter_blend.c
+++ b/src/lib/evas/filters/evas_filter_blend.c
@@ -1,6 +1,7 @@
1#include "evas_filter.h" 1#include "evas_filter.h"
2#include "evas_filter_private.h" 2#include "evas_filter_private.h"
3#include "evas_blend_private.h" 3#include "evas_blend_private.h"
4#include "draw.h"
4 5
5// Use a better formula than R+G+B for rgba to alpha conversion (RGB to YCbCr) 6// Use a better formula than R+G+B for rgba to alpha conversion (RGB to YCbCr)
6#define RGBA2ALPHA_WEIGHTED 1 7#define RGBA2ALPHA_WEIGHTED 1
@@ -32,7 +33,7 @@ _image_draw_cpu_alpha2alpha(void *data EINA_UNUSED, void *context,
32 33
33 EINA_SAFETY_ON_FALSE_RETURN_VAL((src_w == dst_w) && (src_h == dst_h), EINA_FALSE); 34 EINA_SAFETY_ON_FALSE_RETURN_VAL((src_w == dst_w) && (src_h == dst_h), EINA_FALSE);
34 35
35 func = evas_common_alpha_func_get(dc->render_op); 36 func = efl_draw_alpha_func_get(dc->render_op, EINA_FALSE);
36 EINA_SAFETY_ON_NULL_RETURN_VAL(func, EINA_FALSE); 37 EINA_SAFETY_ON_NULL_RETURN_VAL(func, EINA_FALSE);
37 38
38 sw = src->cache_entry.w; 39 sw = src->cache_entry.w;
diff --git a/src/lib/evas/filters/evas_filter_mask.c b/src/lib/evas/filters/evas_filter_mask.c
index 8c900d04a6..6befcf2d72 100644
--- a/src/lib/evas/filters/evas_filter_mask.c
+++ b/src/lib/evas/filters/evas_filter_mask.c
@@ -2,7 +2,7 @@
2 2
3#include "evas_filter_private.h" 3#include "evas_filter_private.h"
4#include "evas_blend_private.h" 4#include "evas_blend_private.h"
5 5#include "draw.h"
6 6
7// Naming convention: _func_engine_incolor_maskcolor_outcolor() 7// Naming convention: _func_engine_incolor_maskcolor_outcolor()
8static Eina_Bool _mask_cpu_alpha_alpha_alpha(Evas_Filter_Command *cmd); 8static Eina_Bool _mask_cpu_alpha_alpha_alpha(Evas_Filter_Command *cmd);
@@ -110,7 +110,7 @@ _mask_cpu_alpha_alpha_alpha(Evas_Filter_Command *cmd)
110 memcpy(dst, src, w * h * sizeof(DATA8)); 110 memcpy(dst, src, w * h * sizeof(DATA8));
111 111
112 // Second pass: apply render op 112 // Second pass: apply render op
113 func = evas_common_alpha_func_get(render_op); 113 func = efl_draw_alpha_func_get(render_op, EINA_FALSE);
114 for (y = 0, my = 0; y < h; y++, my++, msk += mw) 114 for (y = 0, my = 0; y < h; y++, my++, msk += mw)
115 { 115 {
116 if (my >= mh) 116 if (my >= mh)
@@ -314,7 +314,7 @@ _mask_cpu_alpha_alpha_rgba(Evas_Filter_Command *cmd)
314 span = malloc(stepsize * sizeof(DATA8)); 314 span = malloc(stepsize * sizeof(DATA8));
315 315
316 func = evas_common_gfx_func_composite_mask_color_span_get(color, out->cache_entry.flags.alpha, 1, op); 316 func = evas_common_gfx_func_composite_mask_color_span_get(color, out->cache_entry.flags.alpha, 1, op);
317 span_func = evas_common_alpha_func_get(EVAS_RENDER_MASK); 317 span_func = efl_draw_alpha_func_get(cmd->draw.render_op, EINA_TRUE);
318 318
319 for (y = 0, my = 0; y < h; y++, my++, msk += mw) 319 for (y = 0, my = 0; y < h; y++, my++, msk += mw)
320 { 320 {
diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h
index bb21bc1bf5..f7deaa7f42 100644
--- a/src/lib/evas/include/evas_common_private.h
+++ b/src/lib/evas/include/evas_common_private.h
@@ -456,7 +456,6 @@ typedef void (*RGBA_Gfx_Pt_Func) (DATA32 src, DATA8 mask, DATA32 col, DATA32 *ds
456typedef void (*Gfx_Func_Copy) (DATA32 *src, DATA32 *dst, int len); 456typedef void (*Gfx_Func_Copy) (DATA32 *src, DATA32 *dst, int len);
457 457
458typedef void (*Gfx_Func_Convert) (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal); 458typedef void (*Gfx_Func_Convert) (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal);
459typedef void (*Alpha_Gfx_Func) (DATA8 *src, DATA8 *dst, int len);
460 459
461typedef void (*Evas_Render_Done_Cb)(void *); 460typedef void (*Evas_Render_Done_Cb)(void *);
462 461
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}