summaryrefslogtreecommitdiff
path: root/src/lib/evas/common/evas_scale_sample.c
diff options
context:
space:
mode:
authorJaeun Choi <jaeun12.choi@samsung.com>2014-11-13 10:04:00 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-01-07 15:06:02 +0900
commit9af60b1b04a877c70f78ced137a6886b403b25f6 (patch)
treed8144f050622330aa65b7b7f0e4cf597a90b20eb /src/lib/evas/common/evas_scale_sample.c
parenta86f799542b8663a5a5e2f02ebc6b77efecdb29f (diff)
Evas masking: Use alpha mask in SW engine draw functions
Work done by Jaeun Choi, rebased & squashed by jpeg. This commit introduces changes to the low-level draw functions of the SW engine considering the existence of an alpha mask image. Features: - Font masking (TEXT, TEXTBLOCK), - Rectangle masking, - Image masking (all image scaling functions should be handled). The mask image itself is not yet set in the draw context (see following commits). @feature Signed-off-by: Jean-Philippe Andre <jp.andre@samsung.com>
Diffstat (limited to '')
-rw-r--r--src/lib/evas/common/evas_scale_sample.c220
1 files changed, 180 insertions, 40 deletions
diff --git a/src/lib/evas/common/evas_scale_sample.c b/src/lib/evas/common/evas_scale_sample.c
index f462da5f23..86b02d8e68 100644
--- a/src/lib/evas/common/evas_scale_sample.c
+++ b/src/lib/evas/common/evas_scale_sample.c
@@ -59,15 +59,16 @@ evas_common_scale_rgba_in_to_out_clip_sample_do(const Cutout_Rects *reuse,
59} 59}
60 60
61EAPI void 61EAPI void
62evas_common_scale_rgba_sample_draw(RGBA_Image *src, RGBA_Image *dst, int dst_clip_x, int dst_clip_y, int dst_clip_w, int dst_clip_h, DATA32 mul_col, int render_op, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h) 62evas_common_scale_rgba_sample_draw(RGBA_Image *src, RGBA_Image *dst, int dst_clip_x, int dst_clip_y, int dst_clip_w, int dst_clip_h, DATA32 mul_col, int render_op, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h, RGBA_Image *mask_ie, int mask_x, int mask_y)
63{ 63{
64 int x, y; 64 int x, y;
65 int *lin_ptr; 65 int *lin_ptr;
66 DATA32 *buf, *dptr; 66 DATA32 *buf, *dptr;
67 DATA32 **row_ptr; 67 DATA32 **row_ptr;
68 DATA32 *ptr, *dst_ptr, *src_data, *dst_data; 68 DATA32 *ptr, *dst_ptr, *src_data, *dst_data;
69 DATA8 *mask;
69 int src_w, src_h, dst_w, dst_h; 70 int src_w, src_h, dst_w, dst_h;
70 RGBA_Gfx_Func func; 71 RGBA_Gfx_Func func, func2 = NULL;
71 72
72 if ((!src->image.data) || (!dst->image.data)) return; 73 if ((!src->image.data) || (!dst->image.data)) return;
73 if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 74 if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h,
@@ -198,21 +199,59 @@ evas_common_scale_rgba_sample_draw(RGBA_Image *src, RGBA_Image *dst, int dst_cli
198 /* figure out dest start ptr */ 199 /* figure out dest start ptr */
199 dst_ptr = dst_data + dst_clip_x + (dst_clip_y * dst_w); 200 dst_ptr = dst_data + dst_clip_x + (dst_clip_y * dst_w);
200 201
201 if (mul_col != 0xffffffff) 202 if (!mask_ie)
202 func = evas_common_gfx_func_composite_pixel_color_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, mul_col, dst->cache_entry.flags.alpha, dst_clip_w, render_op); 203 {
204 if (mul_col != 0xffffffff)
205 func = evas_common_gfx_func_composite_pixel_color_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, mul_col, dst->cache_entry.flags.alpha, dst_clip_w, render_op);
206 else
207 func = evas_common_gfx_func_composite_pixel_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, dst->cache_entry.flags.alpha, dst_clip_w, render_op);
208 }
203 else 209 else
204 func = evas_common_gfx_func_composite_pixel_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, dst->cache_entry.flags.alpha, dst_clip_w, render_op); 210 {
211 func = evas_common_gfx_func_composite_pixel_mask_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, dst->cache_entry.flags.alpha, dst_clip_w, render_op);
212 if (mul_col != 0xffffffff)
213 func2 = evas_common_gfx_func_composite_pixel_color_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, mul_col, dst->cache_entry.flags.alpha, dst_clip_w, render_op);
214 }
205 215
206 if ((dst_region_w == src_region_w) && (dst_region_h == src_region_h)) 216 if ((dst_region_w == src_region_w) && (dst_region_h == src_region_h))
207 { 217 {
208 ptr = src_data + (((dst_clip_y - dst_region_y) + src_region_y) * src_w) + ((dst_clip_x - dst_region_x) + src_region_x); 218 ptr = src_data + (((dst_clip_y - dst_region_y) + src_region_y) * src_w) + ((dst_clip_x - dst_region_x) + src_region_x);
209 for (y = 0; y < dst_clip_h; y++) 219
220 /* image masking */
221 if (mask_ie)
210 { 222 {
211 /* * blend here [clip_w *] ptr -> dst_ptr * */ 223 if (mul_col != 0xffffffff)
212 func(ptr, NULL, mul_col, dst_ptr, dst_clip_w); 224 buf = alloca(dst_clip_w * sizeof(DATA32));
225
226 for (y = 0; y < dst_clip_h; y++)
227 {
228 mask = mask_ie->image.data8
229 + ((dst_clip_y - mask_y + y) * mask_ie->cache_entry.w)
230 + (dst_clip_x - mask_x);
231
232 /* * blend here [clip_w *] ptr -> dst_ptr * */
233 if (mul_col != 0xffffffff)
234 {
235 func2(ptr, NULL, mul_col, buf, dst_clip_w);
236 func(buf, mask, 0, dst_ptr, dst_clip_w);
237 }
238 else
239 func(ptr, mask, 0, dst_ptr, dst_clip_w);
240
241 ptr += src_w;
242 dst_ptr += dst_w;
243 }
244 }
245 else
246 {
247 for (y = 0; y < dst_clip_h; y++)
248 {
249 /* * blend here [clip_w *] ptr -> dst_ptr * */
250 func(ptr, NULL, mul_col, dst_ptr, dst_clip_w);
213 251
214 ptr += src_w; 252 ptr += src_w;
215 dst_ptr += dst_w; 253 dst_ptr += dst_w;
254 }
216 } 255 }
217 } 256 }
218 else 257 else
@@ -234,20 +273,48 @@ evas_common_scale_rgba_sample_draw(RGBA_Image *src, RGBA_Image *dst, int dst_cli
234 /* a scanline buffer */ 273 /* a scanline buffer */
235 buf = alloca(dst_clip_w * sizeof(DATA32)); 274 buf = alloca(dst_clip_w * sizeof(DATA32));
236 275
237 for (y = 0; y < dst_clip_h; y++) 276 /* image masking */
277 if (mask_ie)
238 { 278 {
239 dst_ptr = buf; 279 for (y = 0; y < dst_clip_h; y++)
240
241 for (x = 0; x < dst_clip_w; x++)
242 { 280 {
243 ptr = row_ptr[y] + lin_ptr[x]; 281 dst_ptr = buf;
244 *dst_ptr = *ptr; 282 mask = mask_ie->image.data8
245 dst_ptr++; 283 + ((dst_clip_y - mask_y + y) * mask_ie->cache_entry.w)
284 + (dst_clip_x - mask_x);
285
286 for (x = 0; x < dst_clip_w; x++)
287 {
288 ptr = row_ptr[y] + lin_ptr[x];
289 *dst_ptr = *ptr;
290 dst_ptr++;
291 }
292
293 /* * blend here [clip_w *] buf -> dptr * */
294 if (mul_col != 0xffffffff) func2(buf, NULL, mul_col, buf, dst_clip_w);
295 func(buf, mask, 0, dptr, dst_clip_w);
296
297 dptr += dst_w;
246 } 298 }
247 /* * blend here [clip_w *] buf -> dptr * */ 299 }
248 func(buf, NULL, mul_col, dptr, dst_clip_w); 300 else
301 {
302 for (y = 0; y < dst_clip_h; y++)
303 {
304 dst_ptr = buf;
305
306 for (x = 0; x < dst_clip_w; x++)
307 {
308 ptr = row_ptr[y] + lin_ptr[x];
309 *dst_ptr = *ptr;
310 dst_ptr++;
311 }
312
313 /* * blend here [clip_w *] buf -> dptr * */
314 func(buf, NULL, mul_col, dptr, dst_clip_w);
249 315
250 dptr += dst_w; 316 dptr += dst_w;
317 }
251 } 318 }
252 } 319 }
253} 320}
@@ -265,9 +332,10 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
265 DATA32 *buf, *dptr; 332 DATA32 *buf, *dptr;
266 DATA32 **row_ptr; 333 DATA32 **row_ptr;
267 DATA32 *ptr, *dst_ptr, *src_data, *dst_data; 334 DATA32 *ptr, *dst_ptr, *src_data, *dst_data;
335 DATA8 *mask;
268 int dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h; 336 int dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h;
269 int src_w, src_h, dst_w, dst_h; 337 int src_w, src_h, dst_w, dst_h;
270 RGBA_Gfx_Func func; 338 RGBA_Gfx_Func func, func2 = NULL;
271 339
272 if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h))) 340 if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
273 return EINA_FALSE; 341 return EINA_FALSE;
@@ -395,10 +463,19 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
395 /* figure out dest start ptr */ 463 /* figure out dest start ptr */
396 dst_ptr = dst_data + dst_clip_x + (dst_clip_y * dst_w); 464 dst_ptr = dst_data + dst_clip_x + (dst_clip_y * dst_w);
397 465
398 if (dc->mul.use) 466 if (!dc->clip.mask)
399 func = evas_common_gfx_func_composite_pixel_color_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, dc->mul.col, dst->cache_entry.flags.alpha, dst_clip_w, dc->render_op); 467 {
468 if (dc->mul.use)
469 func = evas_common_gfx_func_composite_pixel_color_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, dc->mul.col, dst->cache_entry.flags.alpha, dst_clip_w, dc->render_op);
470 else
471 func = evas_common_gfx_func_composite_pixel_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, dst->cache_entry.flags.alpha, dst_clip_w, dc->render_op);
472 }
400 else 473 else
401 func = evas_common_gfx_func_composite_pixel_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, dst->cache_entry.flags.alpha, dst_clip_w, dc->render_op); 474 {
475 func = evas_common_gfx_func_composite_pixel_mask_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, dst->cache_entry.flags.alpha, dst_clip_w, dc->render_op);
476 if (dc->mul.use)
477 func2 = evas_common_gfx_func_composite_pixel_color_span_get(src->cache_entry.flags.alpha, src->cache_entry.flags.alpha_sparse, dc->mul.col, dst->cache_entry.flags.alpha, dst_clip_w, dc->render_op);
478 }
402 479
403 if ((dst_region_w == src_region_w) && (dst_region_h == src_region_h)) 480 if ((dst_region_w == src_region_w) && (dst_region_h == src_region_h))
404 { 481 {
@@ -427,13 +504,44 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
427#endif 504#endif
428 { 505 {
429 ptr = src_data + ((dst_clip_y - dst_region_y + src_region_y) * src_w) + (dst_clip_x - dst_region_x) + src_region_x; 506 ptr = src_data + ((dst_clip_y - dst_region_y + src_region_y) * src_w) + (dst_clip_x - dst_region_x) + src_region_x;
430 for (y = 0; y < dst_clip_h; y++) 507
508 /* image masking */
509 if (dc->clip.mask)
431 { 510 {
432 /* * blend here [clip_w *] ptr -> dst_ptr * */ 511 RGBA_Image *im = dc->clip.mask;
433 func(ptr, NULL, dc->mul.col, dst_ptr, dst_clip_w);
434 512
435 ptr += src_w; 513 if (dc->mul.use)
436 dst_ptr += dst_w; 514 buf = alloca(dst_clip_w * sizeof(DATA32));
515
516 for (y = 0; y < dst_clip_h; y++)
517 {
518 mask = im->image.data8
519 + ((dst_clip_y - dc->clip.mask_y + y) * im->cache_entry.w)
520 + (dst_clip_x - dc->clip.mask_x);
521
522 /* * blend here [clip_w *] ptr -> dst_ptr * */
523 if (dc->mul.use)
524 {
525 func2(ptr, NULL, dc->mul.col, buf, dst_clip_w);
526 func(buf, mask, 0, dst_ptr, dst_clip_w);
527 }
528 else
529 func(ptr, mask, 0, dst_ptr, dst_clip_w);
530
531 ptr += src_w;
532 dst_ptr += dst_w;
533 }
534 }
535 else
536 {
537 for (y = 0; y < dst_clip_h; y++)
538 {
539 /* * blend here [clip_w *] ptr -> dst_ptr * */
540 func(ptr, NULL, dc->mul.col, dst_ptr, dst_clip_w);
541
542 ptr += src_w;
543 dst_ptr += dst_w;
544 }
437 } 545 }
438 } 546 }
439 } 547 }
@@ -454,7 +562,8 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
454#ifdef DIRECT_SCALE 562#ifdef DIRECT_SCALE
455 if ((!src->cache_entry.flags.alpha) && 563 if ((!src->cache_entry.flags.alpha) &&
456 (!dst->cache_entry.flags.alpha) && 564 (!dst->cache_entry.flags.alpha) &&
457 (!dc->mul.use)) 565 (!dc->mul.use) &&
566 (!dc->clip.mask))
458 { 567 {
459 for (y = 0; y < dst_clip_h; y++) 568 for (y = 0; y < dst_clip_h; y++)
460 { 569 {
@@ -475,19 +584,50 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
475 { 584 {
476 /* a scanline buffer */ 585 /* a scanline buffer */
477 buf = alloca(dst_clip_w * sizeof(DATA32)); 586 buf = alloca(dst_clip_w * sizeof(DATA32));
478 for (y = 0; y < dst_clip_h; y++) 587
588 /* image masking */
589 if (dc->clip.mask)
479 { 590 {
480 dst_ptr = buf; 591 RGBA_Image *im = dc->clip.mask;
481 for (x = 0; x < dst_clip_w; x++) 592
593 for (y = 0; y < dst_clip_h; y++)
482 { 594 {
483 ptr = row_ptr[y] + lin_ptr[x]; 595 dst_ptr = buf;
484 *dst_ptr = *ptr; 596 mask = im->image.data8
485 dst_ptr++; 597 + ((dst_clip_y - dc->clip.mask_y + y) * im->cache_entry.w)
598 + (dst_clip_x - dc->clip.mask_x);
599
600 for (x = 0; x < dst_clip_w; x++)
601 {
602 ptr = row_ptr[y] + lin_ptr[x];
603 *dst_ptr = *ptr;
604 dst_ptr++;
605 }
606
607 /* * blend here [clip_w *] buf -> dptr * */
608 if (dc->mul.use) func2(buf, NULL, dc->mul.col, buf, dst_clip_w);
609 func(buf, mask, 0, dptr, dst_clip_w);
610
611 dptr += dst_w;
612 }
613 }
614 else
615 {
616 for (y = 0; y < dst_clip_h; y++)
617 {
618 dst_ptr = buf;
619 for (x = 0; x < dst_clip_w; x++)
620 {
621 ptr = row_ptr[y] + lin_ptr[x];
622 *dst_ptr = *ptr;
623 dst_ptr++;
624 }
625
626 /* * blend here [clip_w *] buf -> dptr * */
627 func(buf, NULL, dc->mul.col, dptr, dst_clip_w);
628
629 dptr += dst_w;
486 } 630 }
487 /* * blend here [clip_w *] buf -> dptr * */
488 func(buf, NULL, dc->mul.col, dptr, dst_clip_w);
489
490 dptr += dst_w;
491 } 631 }
492 } 632 }
493 } 633 }