From 1864362aaf97ac2fd5118a842c1df694054c0cdb Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 1 Apr 2015 11:01:48 +0900 Subject: [PATCH] Evas masking: Implement polygon masking (GL) --- .../evas/engines/gl_common/evas_gl_polygon.c | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/modules/evas/engines/gl_common/evas_gl_polygon.c b/src/modules/evas/engines/gl_common/evas_gl_polygon.c index df87cb7..4552d66 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_polygon.c +++ b/src/modules/evas/engines/gl_common/evas_gl_polygon.c @@ -131,6 +131,10 @@ evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int Cutout_Rect *r; int c, cx, cy, cw, ch, cr, cg, cb, ca, i; int x = 0, y = 0, w = 0, h = 0; + Evas_GL_Texture *mtex = NULL; + Eina_Bool mask_smooth = EINA_FALSE; + int mx = 0, my = 0, mw = 0, mh = 0; + Evas_GL_Image *mask; Eina_List *l; int n, k, num_active_edges, yy0, yy1, *sorted_index, j; @@ -139,8 +143,6 @@ evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int Evas_GL_Polygon_Point *pt; Eina_Inlist *spans; - // TODO: Implement masking support (not very important right now) - /* save out clip info */ c = gc->dc->clip.use; cx = gc->dc->clip.x; cy = gc->dc->clip.y; cw = gc->dc->clip.w; ch = gc->dc->clip.h; @@ -150,6 +152,23 @@ evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int cg = (gc->dc->col.col >> 8 ) & 0xff; cb = (gc->dc->col.col ) & 0xff; + mask = gc->dc->clip.mask; + if (mask) + { + evas_gl_common_image_update(gc, mask); + mtex = mask->tex; + if (mtex && mtex->pt && mtex->pt->w && mtex->pt->h) + { + // canvas coords + mx = gc->dc->clip.mask_x; + my = gc->dc->clip.mask_y; + mw = mask->w; + mh = mask->h; + mask_smooth = mask->scaled.smooth; + } + else mtex = NULL; + } + n = eina_list_count(poly->points); if (n < 3) return; edges = malloc(sizeof(RGBA_Edge) * n); @@ -272,7 +291,7 @@ evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int h = 1; evas_gl_common_context_rectangle_push(gc, x, y, w, h, cr, cg, cb, ca, - NULL, 0, 0, 0, 0, EINA_FALSE); + mtex, mx, my, mw, mh, mask_smooth); } } else @@ -296,7 +315,7 @@ evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int if ((w > 0) && (h > 0)) evas_gl_common_context_rectangle_push(gc, x, y, w, h, cr, cg, cb, ca, - NULL, 0, 0, 0, 0, EINA_FALSE); + mtex, mx, my, mw, mh, mask_smooth); } } } -- 2.7.4