summaryrefslogtreecommitdiff
path: root/src/modules
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>2015-01-07 15:06:02 +0900
commita9630a77b656ebf7e246296530de70852abf52d5 (patch)
tree0bb6d08a93bbf517754788aab798d3625a65b06f /src/modules
parent9af60b1b04a877c70f78ced137a6886b403b25f6 (diff)
Evas masking: Add clip_image_[un]set functions to draw context
This allows passing a mask image to the render functions. @feature
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c72
1 files changed, 69 insertions, 3 deletions
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,