summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-02-17 19:54:47 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-18 10:22:50 +0900
commit3819bc7abb954dd44b5074de0cc0333c8ca71f67 (patch)
tree2c18d8065894cb243c604cf0cfaba3406e250d29
parent7cf02ca75bfddf26f1f427f0b742c8f0a9b24ed4 (diff)
Evas filters: Implement "fillmode" for displace
The fillmode (stretch or repeat map) was present and documented for displace, but not implemented. Easy copy & paste from the mask filter.
-rw-r--r--src/lib/evas/filters/evas_filter_displace.c50
1 files changed, 44 insertions, 6 deletions
diff --git a/src/lib/evas/filters/evas_filter_displace.c b/src/lib/evas/filters/evas_filter_displace.c
index aed1671897..31df1f75fe 100644
--- a/src/lib/evas/filters/evas_filter_displace.c
+++ b/src/lib/evas/filters/evas_filter_displace.c
@@ -3,12 +3,11 @@
3 3
4static void 4static void
5_filter_displace_cpu_alpha_do(int w, int h, int map_w, int map_h, int intensity, 5_filter_displace_cpu_alpha_do(int w, int h, int map_w, int map_h, int intensity,
6 DATA8 *src, DATA8 *dst, DATA8 *map_start, 6 DATA8 *src, DATA8 *dst, DATA32 *map_start,
7 Eina_Bool stretch, Eina_Bool smooth, 7 Eina_Bool stretch, Eina_Bool smooth,
8 Eina_Bool blend) 8 Eina_Bool blend)
9{ 9{
10 int x, y, map_x, map_y; 10 int x, y, map_x, map_y;
11 const int map_stride = map_w * sizeof(DATA32);
12 const int dx = RED; 11 const int dx = RED;
13 const int dy = GREEN; 12 const int dy = GREEN;
14 DATA8 *map; 13 DATA8 *map;
@@ -16,7 +15,7 @@ _filter_displace_cpu_alpha_do(int w, int h, int map_w, int map_h, int intensity,
16 for (y = 0, map_y = 0; y < h; y++, map_y++) 15 for (y = 0, map_y = 0; y < h; y++, map_y++)
17 { 16 {
18 if (map_y >= map_h) map_y = 0; 17 if (map_y >= map_h) map_y = 0;
19 map = map_start + (map_y * map_stride); 18 map = (DATA8 *) (map_start + map_y * map_w);
20 19
21 for (x = 0, map_x = 0; x < w; 20 for (x = 0, map_x = 0; x < w;
22 x++, dst++, src++, map_x++, map += sizeof(DATA32)) 21 x++, dst++, src++, map_x++, map += sizeof(DATA32))
@@ -28,7 +27,7 @@ _filter_displace_cpu_alpha_do(int w, int h, int map_w, int map_h, int intensity,
28 if (map_x >= map_w) 27 if (map_x >= map_w)
29 { 28 {
30 map_x = 0; 29 map_x = 0;
31 map = map_start + (map_y * map_stride); 30 map = (DATA8 *) (map_start + map_y * map_w);
32 } 31 }
33 32
34 // x 33 // x
@@ -195,7 +194,8 @@ static Eina_Bool
195_filter_displace_cpu_alpha(Evas_Filter_Command *cmd) 194_filter_displace_cpu_alpha(Evas_Filter_Command *cmd)
196{ 195{
197 int w, h, map_w, map_h, intensity; 196 int w, h, map_w, map_h, intensity;
198 DATA8 *dst, *src, *map_start; 197 DATA8 *dst, *src;
198 DATA32 *map_start;
199 Eina_Bool stretch, smooth, blend; 199 Eina_Bool stretch, smooth, blend;
200 200
201 w = cmd->input->w; 201 w = cmd->input->w;
@@ -207,7 +207,7 @@ _filter_displace_cpu_alpha(Evas_Filter_Command *cmd)
207 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->output->backing, EINA_FALSE); 207 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->output->backing, EINA_FALSE);
208 208
209 src = ((RGBA_Image *) cmd->input->backing)->mask.data; 209 src = ((RGBA_Image *) cmd->input->backing)->mask.data;
210 map_start = ((RGBA_Image *) cmd->mask->backing)->mask.data; 210 map_start = ((RGBA_Image *) cmd->mask->backing)->image.data;
211 dst = ((RGBA_Image *) cmd->output->backing)->mask.data; 211 dst = ((RGBA_Image *) cmd->output->backing)->mask.data;
212 EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE); 212 EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE);
213 EINA_SAFETY_ON_NULL_RETURN_VAL(map_start, EINA_FALSE); 213 EINA_SAFETY_ON_NULL_RETURN_VAL(map_start, EINA_FALSE);
@@ -220,6 +220,25 @@ _filter_displace_cpu_alpha(Evas_Filter_Command *cmd)
220 intensity = cmd->displacement.intensity; 220 intensity = cmd->displacement.intensity;
221 blend = (cmd->draw.render_op == EVAS_RENDER_BLEND); 221 blend = (cmd->draw.render_op == EVAS_RENDER_BLEND);
222 222
223 // Stretch if necessary.
224 if ((map_w != w || map_h != h) && (cmd->draw.fillmode & EVAS_FILTER_FILL_MODE_STRETCH_XY))
225 {
226 Evas_Filter_Buffer *fb;
227
228 if (cmd->draw.fillmode & EVAS_FILTER_FILL_MODE_STRETCH_X)
229 map_w = w;
230 if (cmd->draw.fillmode & EVAS_FILTER_FILL_MODE_STRETCH_Y)
231 map_h = h;
232
233 BUFFERS_LOCK();
234 fb = evas_filter_buffer_scaled_get(cmd->ctx, cmd->mask, map_w, map_h);
235 BUFFERS_UNLOCK();
236
237 EINA_SAFETY_ON_NULL_RETURN_VAL(fb, EINA_FALSE);
238 fb->locked = EINA_FALSE;
239 map_start = ((RGBA_Image *) fb->backing)->image.data;
240 }
241
223 _filter_displace_cpu_alpha_do(w, h, map_w, map_h, intensity, 242 _filter_displace_cpu_alpha_do(w, h, map_w, map_h, intensity,
224 src, dst, map_start, stretch, smooth, blend); 243 src, dst, map_start, stretch, smooth, blend);
225 244
@@ -261,6 +280,25 @@ _filter_displace_cpu_rgba(Evas_Filter_Command *cmd)
261 intensity = cmd->displacement.intensity; 280 intensity = cmd->displacement.intensity;
262 blend = (cmd->draw.render_op == EVAS_RENDER_BLEND); 281 blend = (cmd->draw.render_op == EVAS_RENDER_BLEND);
263 282
283 // Stretch if necessary.
284 if ((map_w != w || map_h != h) && (cmd->draw.fillmode & EVAS_FILTER_FILL_MODE_STRETCH_XY))
285 {
286 Evas_Filter_Buffer *fb;
287
288 if (cmd->draw.fillmode & EVAS_FILTER_FILL_MODE_STRETCH_X)
289 map_w = w;
290 if (cmd->draw.fillmode & EVAS_FILTER_FILL_MODE_STRETCH_Y)
291 map_h = h;
292
293 BUFFERS_LOCK();
294 fb = evas_filter_buffer_scaled_get(cmd->ctx, cmd->mask, map_w, map_h);
295 BUFFERS_UNLOCK();
296
297 EINA_SAFETY_ON_NULL_RETURN_VAL(fb, EINA_FALSE);
298 fb->locked = EINA_FALSE;
299 map_start = ((RGBA_Image *) fb->backing)->image.data;
300 }
301
264 _filter_displace_cpu_rgba_do(w, h, map_w, map_h, intensity, 302 _filter_displace_cpu_rgba_do(w, h, map_w, map_h, intensity,
265 src, dst, map_start, stretch, smooth, blend); 303 src, dst, map_start, stretch, smooth, blend);
266 304