summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-02-14 16:28:35 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-17 10:02:19 +0900
commit9472e035461dd42a533cf893362063bb95811f34 (patch)
tree29325aaee3170d8e82d0379666c5bb1f8d594195
parent064307edee5d9d099655275ad325ad89828c161c (diff)
Evas filters: Fix RGBA displacement filter
Well... it was just broken: typo, lack of normalization on alpha, invalid formula for blending. Duh!
-rw-r--r--src/lib/evas/filters/evas_filter_displace.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/lib/evas/filters/evas_filter_displace.c b/src/lib/evas/filters/evas_filter_displace.c
index 37ce266d89..994cbe990a 100644
--- a/src/lib/evas/filters/evas_filter_displace.c
+++ b/src/lib/evas/filters/evas_filter_displace.c
@@ -95,6 +95,7 @@ _filter_displace_cpu_rgba_do(int w, int h, int map_w, int map_h, int intensity,
95 for (x = 0, map_x = 0; x < w; x++, dst++, src++, map_x++) 95 for (x = 0, map_x = 0; x < w; x++, dst++, src++, map_x++)
96 { 96 {
97 int offx = 0, offy = 0, offx_dec = 0, offy_dec = 0, val = 0; 97 int offx = 0, offy = 0, offx_dec = 0, offy_dec = 0, val = 0;
98 DATA32 col = 0;
98 Eina_Bool out = 0; 99 Eina_Bool out = 0;
99 100
100 // wrap (x) 101 // wrap (x)
@@ -121,16 +122,16 @@ _filter_displace_cpu_rgba_do(int w, int h, int map_w, int map_h, int intensity,
121 122
122 // get value 123 // get value
123 if (out && !stretch) 124 if (out && !stretch)
124 val = A_VAL(src + offx + offy * w) << (ALPHA * 8); 125 col = A_VAL(src + offx + offy * w) << (ALPHA * 8);
125 else if (!smooth) 126 else if (!smooth)
126 val = src[offx + offy * w]; 127 col = src[offx + offy * w];
127 else 128 else
128 { 129 {
129 int R, G, B, A; 130 int R, G, B, A;
130 DATA32 s00, s01, s10, s11; // indexes represent x,y 131 DATA32 s00, s01, s10, s11; // indexes represent x,y
131 int mul00, mul01, mul10, mul11; 132 int mul00, mul01, mul10, mul11;
132 133
133 mul00 = (128 - offx_dec) * (128 * offy_dec); 134 mul00 = (128 - offx_dec) * (128 - offy_dec);
134 mul01 = (128 - offx_dec) * offy_dec; 135 mul01 = (128 - offx_dec) * offy_dec;
135 mul10 = offx_dec * (128 - offy_dec); 136 mul10 = offx_dec * (128 - offy_dec);
136 mul11 = offx_dec * offy_dec; 137 mul11 = offx_dec * offy_dec;
@@ -152,18 +153,24 @@ _filter_displace_cpu_rgba_do(int w, int h, int map_w, int map_h, int intensity,
152 B = (BLUE_OF(s00) * mul00) + (BLUE_OF(s10) * mul10) 153 B = (BLUE_OF(s00) * mul00) + (BLUE_OF(s10) * mul10)
153 + (BLUE_OF(s01) * mul01) + (BLUE_OF(s11) * mul11); 154 + (BLUE_OF(s01) * mul01) + (BLUE_OF(s11) * mul11);
154 155
156 A >>= 14;
155 R >>= 14; 157 R >>= 14;
156 G >>= 14; 158 G >>= 14;
157 B >>= 14; 159 B >>= 14;
158 160
159 val = ARGB_JOIN(A, R, G, B); 161 col = ARGB_JOIN(A, R, G, B);
160 } 162 }
161 163
162 // apply alpha 164 if (map[ALPHA] != 0xFF)
163 if (blend && map[ALPHA] != 0xFF) 165 col = MUL_256(map[ALPHA], col);
164 *dst = INTERP_256(map[ALPHA], val, *dst); 166
167 if (blend)
168 {
169 DATA32 a = 256 - ALPHA_OF(col);
170 *dst = col + MUL_256(a, *dst);
171 }
165 else 172 else
166 *dst = val; 173 *dst = col;
167 } 174 }
168 } 175 }
169} 176}