jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=b5500a864434f53240cb774c92731341b21ff3ad

commit b5500a864434f53240cb774c92731341b21ff3ad
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Thu Dec 3 15:29:32 2015 +0900

    Evas: Move alpha functions to static_libs/draw
    
    This is a pretty simple code refactor, moving pixel handling
    to the new draw lib.
---
 src/Makefile_Evas.am                       |  5 +-
 src/lib/evas/common/evas_alpha_main.c      | 81 ------------------------------
 src/lib/evas/common/evas_blend_private.h   |  4 --
 src/lib/evas/common/evas_font_compress.c   |  3 +-
 src/lib/evas/filters/evas_filter_blend.c   |  3 +-
 src/lib/evas/filters/evas_filter_mask.c    |  6 +--
 src/lib/evas/include/evas_common_private.h |  1 -
 src/static_libs/draw/draw.h                |  6 ++-
 src/static_libs/draw/draw_alpha_main.c     | 59 ++++++++++++++++++++++
 9 files changed, 74 insertions(+), 94 deletions(-)

diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 8f234af..1f52b28 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -259,6 +259,10 @@ lib/evas/canvas/evas_vg_gradient_radial.c \
 lib/evas/canvas/evas_vg_utils.c \
 lib/evas/canvas/evas_vg_shape.c
 
+# Static draw lib
+lib_evas_libevas_la_SOURCES += \
+static_libs/draw/draw_alpha_main.c
+
 # Engine
 lib_evas_libevas_la_SOURCES += \
 lib/evas/common/evas_op_copy_main_.c \
@@ -267,7 +271,6 @@ lib/evas/common/evas_op_add_main_.c \
 lib/evas/common/evas_op_sub_main_.c \
 lib/evas/common/evas_op_mask_main_.c \
 lib/evas/common/evas_op_mul_main_.c \
-lib/evas/common/evas_alpha_main.c \
 lib/evas/common/evas_blend_main.c \
 lib/evas/common/evas_blit_main.c \
 lib/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 74bc75b..0000000
--- a/src/lib/evas/common/evas_alpha_main.c
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "evas_common_private.h"
-#include "evas_blend_private.h"
-
-/** default op: d = d*(1-sa) + s */
-static void
-_alpha_func_blend(DATA8 *src, DATA8 *dst, int len)
-{
-   int k;
-
-   EINA_SAFETY_ON_NULL_RETURN(src);
-   EINA_SAFETY_ON_NULL_RETURN(dst);
-
-   for (k = len; k; k--)
-     {
-        int val = (*dst * (255 - *src)) / 255 + *src;
-        *dst++ = val;
-        src++;
-     }
-}
-
-/** d = s */
-static void
-_alpha_func_copy(DATA8 *src, DATA8 *dst, int len)
-{
-   EINA_SAFETY_ON_NULL_RETURN(src);
-   EINA_SAFETY_ON_NULL_RETURN(dst);
-
-   memcpy(dst, src, len);
-}
-
-/** d = d*s */
-static void
-_alpha_func_mul(DATA8 *src, DATA8 *dst, int len)
-{
-   int k;
-
-   EINA_SAFETY_ON_NULL_RETURN(src);
-   EINA_SAFETY_ON_NULL_RETURN(dst);
-
-   for (k = len; k; k--)
-     {
-        int val = (*dst * *src) / 255;
-        *dst++ = val;
-        src++;
-     }
-}
-
-
-#if 0
-// Reference ops. In case of alpha, s == sa.
-EVAS_RENDER_BLEND = 0, /**< default op: d = d*(1-sa) + s */
-EVAS_RENDER_BLEND_REL = 1, /**< d = d*(1 - sa) + s*da */
-EVAS_RENDER_COPY = 2, /**< d = s */
-EVAS_RENDER_COPY_REL = 3, /**< d = s*da */
-EVAS_RENDER_ADD = 4, /* d = d + s */
-EVAS_RENDER_ADD_REL = 5, /**< d = d + s*da */
-EVAS_RENDER_SUB = 6, /**< d = d - s */
-EVAS_RENDER_SUB_REL = 7, /* d = d - s*da */
-EVAS_RENDER_TINT = 8, /**< d = d*s + d*(1 - sa) + s*(1 - da) */
-EVAS_RENDER_TINT_REL = 9, /**< d = d*(1 - sa + s) */
-EVAS_RENDER_MASK = 10, /**< d = d*sa */
-EVAS_RENDER_MUL = 11, /**< d = d*s */
-#endif
-
-Alpha_Gfx_Func
-evas_common_alpha_func_get(int op)
-{
-   switch (op)
-     {
-      case EVAS_RENDER_BLEND:
-        return _alpha_func_blend;
-      case EVAS_RENDER_COPY:
-        return _alpha_func_copy;
-      case EVAS_RENDER_MASK:
-      case EVAS_RENDER_MUL:
-        return _alpha_func_mul;
-      default:
-        ERR("Not implemented yet.");
-        return NULL;
-     }
-}
diff --git a/src/lib/evas/common/evas_blend_private.h 
b/src/lib/evas/common/evas_blend_private.h
index f96e004..5b17993 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
 RGBA_Gfx_Pt_Func     evas_common_gfx_func_composite_mask_color_pt_get    
(DATA32 col, Eina_Bool dst_alpha, int op);
 RGBA_Gfx_Pt_Func     evas_common_gfx_func_composite_pixel_mask_pt_get    
(Eina_Bool src_alpha, Eina_Bool dst_alpha, int op);
 
-/* Alpha/mask functions */
-Alpha_Gfx_Func       evas_common_alpha_func_get (int op);
-
-
 #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 1e13e53..7788ba5 100644
--- a/src/lib/evas/common/evas_font_compress.c
+++ b/src/lib/evas/common/evas_font_compress.c
@@ -9,6 +9,7 @@
 
 #include "evas_font_private.h"
 #include "evas_blend_private.h"
+#include "draw.h"
 
 #ifdef EVAS_CSERVE2
 # include "../cserve2/evas_cs2_private.h"
@@ -512,7 +513,7 @@ evas_common_font_glyph_draw(RGBA_Font_Glyph *fg,
         DATA8 *src8;
         int row;
 
-        func = evas_common_alpha_func_get(dc->render_op);
+        func = efl_draw_alpha_func_get(dc->render_op, EINA_FALSE);
         src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL);
         if (!src8) return;
 
diff --git a/src/lib/evas/filters/evas_filter_blend.c 
b/src/lib/evas/filters/evas_filter_blend.c
index 17be2bc..407563a 100644
--- a/src/lib/evas/filters/evas_filter_blend.c
+++ b/src/lib/evas/filters/evas_filter_blend.c
@@ -1,6 +1,7 @@
 #include "evas_filter.h"
 #include "evas_filter_private.h"
 #include "evas_blend_private.h"
+#include "draw.h"
 
 // Use a better formula than R+G+B for rgba to alpha conversion (RGB to YCbCr)
 #define RGBA2ALPHA_WEIGHTED 1
@@ -32,7 +33,7 @@ _image_draw_cpu_alpha2alpha(void *data EINA_UNUSED, void 
*context,
 
    EINA_SAFETY_ON_FALSE_RETURN_VAL((src_w == dst_w) && (src_h == dst_h), 
EINA_FALSE);
 
-   func = evas_common_alpha_func_get(dc->render_op);
+   func = efl_draw_alpha_func_get(dc->render_op, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(func, EINA_FALSE);
 
    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 8c900d0..6befcf2 100644
--- a/src/lib/evas/filters/evas_filter_mask.c
+++ b/src/lib/evas/filters/evas_filter_mask.c
@@ -2,7 +2,7 @@
 
 #include "evas_filter_private.h"
 #include "evas_blend_private.h"
-
+#include "draw.h"
 
 // Naming convention: _func_engine_incolor_maskcolor_outcolor()
 static Eina_Bool _mask_cpu_alpha_alpha_alpha(Evas_Filter_Command *cmd);
@@ -110,7 +110,7 @@ _mask_cpu_alpha_alpha_alpha(Evas_Filter_Command *cmd)
      memcpy(dst, src, w * h * sizeof(DATA8));
 
    // Second pass: apply render op
-   func = evas_common_alpha_func_get(render_op);
+   func = efl_draw_alpha_func_get(render_op, EINA_FALSE);
    for (y = 0, my = 0; y < h; y++, my++, msk += mw)
      {
         if (my >= mh)
@@ -314,7 +314,7 @@ _mask_cpu_alpha_alpha_rgba(Evas_Filter_Command *cmd)
    span = malloc(stepsize * sizeof(DATA8));
 
    func = evas_common_gfx_func_composite_mask_color_span_get(color, 
out->cache_entry.flags.alpha, 1, op);
-   span_func = evas_common_alpha_func_get(EVAS_RENDER_MASK);
+   span_func = efl_draw_alpha_func_get(cmd->draw.render_op, EINA_TRUE);
 
    for (y = 0, my = 0; y < h; y++, my++, msk += mw)
      {
diff --git a/src/lib/evas/include/evas_common_private.h 
b/src/lib/evas/include/evas_common_private.h
index bb21bc1..f7deaa7 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
 typedef void (*Gfx_Func_Copy)    (DATA32 *src, DATA32 *dst, int len);
 
 typedef 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);
-typedef void (*Alpha_Gfx_Func)   (DATA8 *src, DATA8 *dst, int len);
 
 typedef void (*Evas_Render_Done_Cb)(void *);
 
diff --git a/src/static_libs/draw/draw.h b/src/static_libs/draw/draw.h
index 466ef7c..c2f2370 100644
--- a/src/static_libs/draw/draw.h
+++ b/src/static_libs/draw/draw.h
@@ -7,13 +7,15 @@
 
 #include <Efl.h>
 
-typedef void (*RGBA_Comp_Func)(uint *dest, const uint *src, int length, uint 
mul_col, uint const_alpha);
-typedef void (*RGBA_Comp_Func_Solid)(uint *dest, int length, uint color, uint 
const_alpha);
+typedef void (*RGBA_Comp_Func)       (uint *dest, const uint *src, int length, 
uint mul_col, uint const_alpha);
+typedef void (*RGBA_Comp_Func_Solid) (uint *dest, int length, uint color, uint 
const_alpha);
+typedef void (*Alpha_Gfx_Func)       (uint8_t *src, uint8_t *dst, int len);
 
 int efl_draw_init(void);
 
 RGBA_Comp_Func_Solid efl_draw_func_solid_span_get(Efl_Gfx_Render_Op op, uint 
color);
 RGBA_Comp_Func efl_draw_func_span_get(Efl_Gfx_Render_Op op, uint color, 
Eina_Bool src_alpha);
+Alpha_Gfx_Func efl_draw_alpha_func_get(Efl_Gfx_Render_Op op, Eina_Bool 
has_mask);
 
 
 /* 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 0000000..ebd93e8
--- /dev/null
+++ b/src/static_libs/draw/draw_alpha_main.c
@@ -0,0 +1,59 @@
+#include "draw_private.h"
+
+/** default op: d = d*(1-sa) + s */
+static void
+_alpha_func_blend(uint8_t *src, uint8_t *dst, int len)
+{
+   int k;
+
+   EINA_SAFETY_ON_NULL_RETURN(src);
+   EINA_SAFETY_ON_NULL_RETURN(dst);
+
+   for (k = len; k; k--)
+     {
+        int val = (*dst * (255 - *src)) / 255 + *src;
+        *dst++ = val;
+        src++;
+     }
+}
+
+/** d = s */
+static void
+_alpha_func_copy(uint8_t *src, uint8_t *dst, int len)
+{
+   EINA_SAFETY_ON_NULL_RETURN(src);
+   EINA_SAFETY_ON_NULL_RETURN(dst);
+
+   memcpy(dst, src, len);
+}
+
+/** d = d*s */
+static void
+_alpha_func_mul(uint8_t *src, uint8_t *dst, int len)
+{
+   int k;
+
+   EINA_SAFETY_ON_NULL_RETURN(src);
+   EINA_SAFETY_ON_NULL_RETURN(dst);
+
+   for (k = len; k; k--)
+     {
+        int val = (*dst * *src) / 255;
+        *dst++ = val;
+        src++;
+     }
+}
+
+Alpha_Gfx_Func
+efl_draw_alpha_func_get(Efl_Gfx_Render_Op op, Eina_Bool has_mask)
+{
+   if (!has_mask)
+     {
+        if (op == EFL_GFX_RENDER_OP_BLEND)
+          return _alpha_func_blend;
+        else
+          return _alpha_func_copy;
+     }
+   else
+     return _alpha_func_mul;
+}

-- 


Reply via email to