summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-01-17 20:34:16 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-04-14 11:26:42 +0900
commitb6df13b02448621e5264152e2db1de370c7a6529 (patch)
treed4d38efa7a8c7eeca4bcd7c884e9052135721c7a /src/lib/evas/common
parent09ff5f419ec102e65dc37cabf53d9854c6da978e (diff)
evas filters: Move curve to software generic (3/8)
This moves the RGBA premul/unpremul functions to static_libs/draw.
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_convert_color.c84
1 files changed, 3 insertions, 81 deletions
diff --git a/src/lib/evas/common/evas_convert_color.c b/src/lib/evas/common/evas_convert_color.c
index ee26638b3b..548c8c5d50 100644
--- a/src/lib/evas/common/evas_convert_color.c
+++ b/src/lib/evas/common/evas_convert_color.c
@@ -1,9 +1,6 @@
1#include "evas_common_private.h" 1#include "evas_common_private.h"
2#include "evas_convert_color.h" 2#include "evas_convert_color.h"
3 3#include "draw.h"
4#ifdef BUILD_NEON
5#include <arm_neon.h>
6#endif
7 4
8EAPI DATA32 5EAPI DATA32
9evas_common_convert_ag_premul(DATA16 *data, unsigned int len) 6evas_common_convert_ag_premul(DATA16 *data, unsigned int len)
@@ -57,88 +54,13 @@ evas_common_convert_ag_unpremul(DATA16 *data, unsigned int len)
57EAPI DATA32 54EAPI DATA32
58evas_common_convert_argb_premul(DATA32 *data, unsigned int len) 55evas_common_convert_argb_premul(DATA32 *data, unsigned int len)
59{ 56{
60 DATA32 *de = data + len; 57 return (DATA32) efl_draw_argb_premul(data, len);
61 DATA32 nas = 0;
62
63#ifdef BUILD_NEON
64 if (evas_common_cpu_has_feature(CPU_FEATURE_NEON))
65 {
66 uint8x8_t mask_0x00 = vdup_n_u8(0);
67 uint8x8_t mask_0x01 = vdup_n_u8(1);
68 uint8x8_t mask_0xff = vdup_n_u8(255);
69 uint8x8_t cmp;
70 uint64x1_t tmp;
71
72 while (data <= de - 8)
73 {
74 uint8x8x4_t rgba = vld4_u8((uint8_t *)data);
75
76 cmp = vand_u8(vorr_u8(vceq_u8(rgba.val[3], mask_0xff),
77 vceq_u8(rgba.val[3], mask_0x00)),
78 mask_0x01);
79 tmp = vpaddl_u32(vpaddl_u16(vpaddl_u8(cmp)));
80 nas += vget_lane_u32(vreinterpret_u32_u64(tmp), 0);
81
82 uint16x8x4_t lrgba;
83 lrgba.val[0] = vmovl_u8(rgba.val[0]);
84 lrgba.val[1] = vmovl_u8(rgba.val[1]);
85 lrgba.val[2] = vmovl_u8(rgba.val[2]);
86 lrgba.val[3] = vaddl_u8(rgba.val[3], mask_0x01);
87
88 rgba.val[0] = vshrn_n_u16(vmlaq_u16(lrgba.val[0], lrgba.val[0],
89 lrgba.val[3]), 8);
90 rgba.val[1] = vshrn_n_u16(vmlaq_u16(lrgba.val[1], lrgba.val[1],
91 lrgba.val[3]), 8);
92 rgba.val[2] = vshrn_n_u16(vmlaq_u16(lrgba.val[2], lrgba.val[2],
93 lrgba.val[3]), 8);
94 vst4_u8((uint8_t *)data, rgba);
95 data += 8;
96 }
97 }
98#endif
99
100 while (data < de)
101 {
102 DATA32 a = 1 + (*data >> 24);
103
104 *data = (*data & 0xff000000) +
105 (((((*data) >> 8) & 0xff) * a) & 0xff00) +
106 (((((*data) & 0x00ff00ff) * a) >> 8) & 0x00ff00ff);
107 data++;
108
109 if ((a == 1) || (a == 256))
110 nas++;
111 }
112
113 return nas;
114} 58}
115 59
116EAPI void 60EAPI void
117evas_common_convert_argb_unpremul(DATA32 *data, unsigned int len) 61evas_common_convert_argb_unpremul(DATA32 *data, unsigned int len)
118{ 62{
119 DATA32 *de = data + len; 63 return efl_draw_argb_unpremul(data, len);
120 DATA32 p_val = 0x00000000, p_res = 0x00000000;
121
122 while (data < de)
123 {
124 DATA32 a = (*data >> 24);
125
126 if (p_val == *data) *data = p_res;
127 else
128 {
129 p_val = *data;
130 if ((a > 0) && (a < 255))
131 *data = ARGB_JOIN(a,
132 (R_VAL(data) * 255) / a,
133 (G_VAL(data) * 255) / a,
134 (B_VAL(data) * 255) / a);
135 else if (a == 0)
136 *data = 0x00000000;
137 p_res = *data;
138 }
139 data++;
140 }
141
142} 64}
143 65
144EAPI void 66EAPI void