summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-11-13 10:31:41 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-12-22 22:33:10 +0900
commit53402ce54efe3948c557bc74d58a791dd2846b5a (patch)
treef87f62ea907d0a6cc1d24ce9a013aeeb5b159fca
parent676cd98a1f48527eafcd8fe150872b0334e6bcfd (diff)
Evas masking: Add clip_image_[un]set functions to draw context
This allows passing a mask image to the render functions. @feature
-rw-r--r--src/lib/evas/filters/evas_filter.c9
-rw-r--r--src/lib/evas/filters/evas_filter_private.h2
-rw-r--r--src/lib/evas/include/evas_private.h3
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c72
4 files changed, 83 insertions, 3 deletions
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index 3991f93585..f7eba26042 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -1537,6 +1537,9 @@ evas_filter_target_set(Evas_Filter_Context *ctx, void *draw_context,
1537 ctx->target.b == 255 && ctx->target.a == 255) 1537 ctx->target.b == 255 && ctx->target.a == 255)
1538 ctx->target.color_use = EINA_FALSE; 1538 ctx->target.color_use = EINA_FALSE;
1539 1539
1540 ENFN->context_clip_image_get
1541 (ENDT, draw_context, &ctx->target.mask, &ctx->target.mask_x, &ctx->target.mask_y);
1542
1540 if (ctx->gl_engine) 1543 if (ctx->gl_engine)
1541 { 1544 {
1542 // Since GL has sync rendering, draw_context is safe to keep around 1545 // Since GL has sync rendering, draw_context is safe to keep around
@@ -1621,6 +1624,12 @@ _filter_target_render(Evas_Filter_Context *ctx)
1621 ENFN->context_multiplier_unset(ENDT, drawctx); 1624 ENFN->context_multiplier_unset(ENDT, drawctx);
1622 } 1625 }
1623 1626
1627 if (ctx->target.mask)
1628 ENFN->context_clip_image_set(ENDT, drawctx,
1629 ctx->target.mask, ctx->target.mask_x, ctx->target.mask_y);
1630 else
1631 ENFN->context_clip_image_unset(ENDT, drawctx);
1632
1624 ENFN->image_draw(ENDT, drawctx, surface, image, 1633 ENFN->image_draw(ENDT, drawctx, surface, image,
1625 0, 0, src->w, src->h, 1634 0, 0, src->w, src->h,
1626 ctx->target.x, ctx->target.y, src->w, src->h, 1635 ctx->target.x, ctx->target.y, src->w, src->h,
diff --git a/src/lib/evas/filters/evas_filter_private.h b/src/lib/evas/filters/evas_filter_private.h
index 6e0a799162..c613be7980 100644
--- a/src/lib/evas/filters/evas_filter_private.h
+++ b/src/lib/evas/filters/evas_filter_private.h
@@ -101,6 +101,8 @@ struct _Evas_Filter_Context
101 int x, y; 101 int x, y;
102 int cx, cy, cw, ch; // clip 102 int cx, cy, cw, ch; // clip
103 int r, g, b, a; // clip color 103 int r, g, b, a; // clip color
104 void *mask; // mask
105 int mask_x, mask_y; // mask offset
104 Eina_Bool clip_use : 1; 106 Eina_Bool clip_use : 1;
105 Eina_Bool color_use : 1; 107 Eina_Bool color_use : 1;
106 } target; 108 } target;
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index c00cc50f1c..b07d72b551 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1155,6 +1155,9 @@ struct _Evas_Func
1155 Eina_Bool (*canvas_alpha_get) (void *data, void *context); 1155 Eina_Bool (*canvas_alpha_get) (void *data, void *context);
1156 void (*context_free) (void *data, void *context); 1156 void (*context_free) (void *data, void *context);
1157 void (*context_clip_set) (void *data, void *context, int x, int y, int w, int h); 1157 void (*context_clip_set) (void *data, void *context, int x, int y, int w, int h);
1158 void (*context_clip_image_set) (void *data, void *context, void *surface, int x, int y);
1159 void (*context_clip_image_unset) (void *data, void *context);
1160 void (*context_clip_image_get) (void *data, void *context, void **surface, int *x, int *y);
1158 void (*context_clip_clip) (void *data, void *context, int x, int y, int w, int h); 1161 void (*context_clip_clip) (void *data, void *context, int x, int y, int w, int h);
1159 void (*context_clip_unset) (void *data, void *context); 1162 void (*context_clip_unset) (void *data, void *context);
1160 int (*context_clip_get) (void *data, void *context, int *x, int *y, int *w, int *h); 1163 int (*context_clip_get) (void *data, void *context, int *x, int *y, int *w, int *h);
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index 673924c50e..92272cd990 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -417,6 +417,60 @@ eng_context_clip_set(void *data EINA_UNUSED, void *context, int x, int y, int w,
417} 417}
418 418
419static void 419static void
420eng_context_clip_image_unset(void *data EINA_UNUSED, void *context)
421{
422 RGBA_Draw_Context *ctx = context;
423
424 if (ctx->clip.mask)
425 {
426 Image_Entry *ie = ctx->clip.mask;
427#ifdef EVAS_CSERVE2
428 if (evas_cserve2_use_get())
429 evas_cache2_image_close(ie);
430 else
431#endif
432 evas_cache_image_drop(ie);
433 // Is the above code safe? Hmmm...
434 //evas_unref_queue_image_put(EVAS???, &ctx->clip.ie->cache_entry);
435 ctx->clip.mask = NULL;
436 }
437}
438
439static void
440eng_context_clip_image_set(void *data EINA_UNUSED, void *context, void *surface, int x, int y)
441{
442 RGBA_Draw_Context *ctx = context;
443
444 if (ctx->clip.mask && ctx->clip.mask != surface)
445 eng_context_clip_image_unset(data, context);
446
447 ctx->clip.mask = surface;
448 ctx->clip.mask_x = x;
449 ctx->clip.mask_y = y;
450
451 if (surface)
452 {
453 Image_Entry *ie = surface;
454#ifdef EVAS_CSERVE2
455 if (evas_cserve2_use_get())
456 evas_cache2_image_ref(ie);
457 else
458#endif
459 evas_cache_image_ref(ie);
460 }
461}
462
463static void
464eng_context_clip_image_get(void *data EINA_UNUSED, void *context, void **ie, int *x, int *y)
465{
466 RGBA_Draw_Context *ctx = context;
467
468 if (ie) *ie = ctx->clip.mask;
469 if (x) *x = ctx->clip.mask_x;
470 if (y) *y = ctx->clip.mask_y;
471}
472
473static void
420eng_context_clip_clip(void *data EINA_UNUSED, void *context, int x, int y, int w, int h) 474eng_context_clip_clip(void *data EINA_UNUSED, void *context, int x, int y, int w, int h)
421{ 475{
422 evas_common_draw_context_clip_clip(context, x, y, w, h); 476 evas_common_draw_context_clip_clip(context, x, y, w, h);
@@ -1296,14 +1350,23 @@ _image_draw_thread_cmd(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc,
1296 clip_h = dst->cache_entry.h; 1350 clip_h = dst->cache_entry.h;
1297 } 1351 }
1298 1352
1353 /* Set image mask, if any */
1354 cr->mask = dc->clip.mask;
1355 cr->mask_x = dc->clip.mask_x;
1356 cr->mask_y = dc->clip.mask_y;
1357 if (cr->mask)
1358 {
1359 Image_Entry *im = cr->mask;
1360 RECTS_CLIP_TO_RECT(clip_x, clip_y, clip_w, clip_h,
1361 cr->mask_x, cr->mask_y,
1362 im->w, im->h);
1363 }
1364
1299 EINA_RECTANGLE_SET(&cr->clip, clip_x, clip_y, clip_w, clip_h); 1365 EINA_RECTANGLE_SET(&cr->clip, clip_x, clip_y, clip_w, clip_h);
1300 1366
1301 cr->mul_col = dc->mul.use ? dc->mul.col : 0xffffffff; 1367 cr->mul_col = dc->mul.use ? dc->mul.col : 0xffffffff;
1302 cr->render_op = dc->render_op; 1368 cr->render_op = dc->render_op;
1303 cr->smooth = smooth; 1369 cr->smooth = smooth;
1304 cr->mask = dc->clip.mask;
1305 cr->mask_x = dc->clip.mask_x;
1306 cr->mask_y = dc->clip.mask_y;
1307 1370
1308 evas_thread_cmd_enqueue(_draw_thread_image_draw, cr); 1371 evas_thread_cmd_enqueue(_draw_thread_image_draw, cr);
1309 1372
@@ -3010,6 +3073,9 @@ static Evas_Func func =
3010 eng_canvas_alpha_get, 3073 eng_canvas_alpha_get,
3011 eng_context_free, 3074 eng_context_free,
3012 eng_context_clip_set, 3075 eng_context_clip_set,
3076 eng_context_clip_image_set,
3077 eng_context_clip_image_unset,
3078 eng_context_clip_image_get,
3013 eng_context_clip_clip, 3079 eng_context_clip_clip,
3014 eng_context_clip_unset, 3080 eng_context_clip_unset,
3015 eng_context_clip_get, 3081 eng_context_clip_get,