aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/evas/engines/gl_common/evas_gl_font.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-02-25 19:05:12 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-02-27 13:06:09 +0900
commitfddaf62fcc4ea94914bfd8a608eceb2eb4610473 (patch)
treeeb4facee25f1696264badb69689b906b85c05b1b /src/modules/evas/engines/gl_common/evas_gl_font.c
parentecore-wl fullscreen state is based on either window type or attribute (diff)
downloadefl-fddaf62fcc4ea94914bfd8a608eceb2eb4610473.tar.gz
Evas masking: Add fast path for image-only masks in GL.
This will currently optimize most of the masks when using the GL engine[1]. This is a very special case that adds a highly optimized path for masking in GL. It works by creating a virtual image, containing a pointer to the original image and a new geometry[2]. Instead of creating a new FBO-based surface (image_map_surface), we refer to the original image and adjust the mask geometry on the fly. KNOWN BUGS: - masking a map with such a scaled image is now broken. [1] Right now all masks are simple Evas Object Image, so that means all cases of masking, except masks of masks, or masks of maps, will be optimized with this new method. [2] This virtual image mechanism is still quite hackish and may be improved (for memory usage, refcounting, etc...)
Diffstat (limited to 'src/modules/evas/engines/gl_common/evas_gl_font.c')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_font.c79
1 files changed, 44 insertions, 35 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_font.c b/src/modules/evas/engines/gl_common/evas_gl_font.c
index 248634bb07..ca6eae9a13 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_font.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_font.c
@@ -61,14 +61,16 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
{
Evas_Engine_GL_Context *gc = context;
RGBA_Draw_Context *dc = draw_context;
- Evas_GL_Texture *tex, *mtex = NULL;
+ Evas_GL_Image *mask = gc->dc->clip.mask;
+ Evas_GL_Texture *tex, *mtex = mask ? mask->tex : NULL;
Cutout_Rect *rct;
int r, g, b, a;
double ssx, ssy, ssw, ssh;
int c, cx, cy, cw, ch;
int i;
int sx, sy, sw, sh;
- double mmx = 0.0, mmy = 0.0, mmw = 0.0, mmh = 0.0;
+ double mx = 0.0, my = 0.0, mw = 0.0, mh = 0.0;
+ Eina_Bool mask_smooth = EINA_FALSE;
if (dc != gc->dc) return;
tex = fg->ext_dat;
@@ -82,36 +84,43 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
if (gc->dc->clip.mask && (sw > 0) && (sh > 0))
{
- // FIXME: This code path does not handle half the stuff the other path does...
- Evas_GL_Image *mask = gc->dc->clip.mask;
- int nx, ny, nw, nh, dx, dy, dw, dh;
- double mx, my, mw, mh;
-
- if (mask->tex)
+ double nx, ny, nw, nh, dx, dy, dw, dh;
+ const double mask_x = gc->dc->clip.mask_x;
+ const double mask_y = gc->dc->clip.mask_y;
+ const double tmw = mtex->pt->w;
+ const double tmh = mtex->pt->h;
+ double scalex = 1.0;
+ double scaley = 1.0;
+
+ // canvas coords
+ nx = x; ny = y; nw = tex->w; nh = tex->h;
+ RECTS_CLIP_TO_RECT(nx, ny, nw, nh,
+ gc->dc->clip.x, gc->dc->clip.y,
+ gc->dc->clip.w, gc->dc->clip.h);
+ if ((nw < 1) || (nh < 1)) return;
+ dx = x; dy = y; dw = sw; dh = sh;
+ mx = mask_x; my = mask_y;
+ if (mask->scaled.origin && mask->scaled.w && mask->scaled.h)
{
- nx = x; ny = y; nw = tex->w; nh = tex->h;
- RECTS_CLIP_TO_RECT(nx, ny, nw, nh,
- gc->dc->clip.x, gc->dc->clip.y,
- gc->dc->clip.w, gc->dc->clip.h);
- if ((nw < 1) || (nh < 1)) return;
-
- //ssx = (double)sx + ((double)(sw * (nx - x)) / (double)(tex->w));
- //ssy = (double)sy + ((double)(sh * (ny - y)) / (double)(tex->h));
- //ssw = ((double)sw * (double)(nw)) / (double)(tex->w);
- //ssh = ((double)sh * (double)(nh)) / (double)(tex->h);
-
- dx = x; dy = y; dw = sw; dh = sh;
- mx = gc->dc->clip.mask_x; my = gc->dc->clip.mask_y; mw = mask->w; mh = mask->h;
- //RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch);
- RECTS_CLIP_TO_RECT(mx, my, mw, mh, dx, dy, dw, dh);
-
- mmx = (double)(mx - gc->dc->clip.mask_x) + ((double)(mw * (nx - dx)) / (double)(dw));
- mmy = (double)(my - gc->dc->clip.mask_y) + ((double)(mh * (ny - dy)) / (double)(dh));
- mmw = ((double)mw * (double)(nw)) / (double)(dw);
- mmh = ((double)mh * (double)(nh)) / (double)(dh);
-
- mtex = mask->tex;
+ mw = mask->scaled.w;
+ mh = mask->scaled.h;
+ scalex = mask->w / (double)mask->scaled.w;
+ scaley = mask->h / (double)mask->scaled.h;
+ mask_smooth = mask->scaled.smooth;
+ }
+ else
+ {
+ mw = mask->w;
+ mh = mask->h;
}
+ //RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch);
+ RECTS_CLIP_TO_RECT(mx, my, mw, mh, dx, dy, dw, dh);
+
+ // convert to tex coords
+ mx = (mtex->x / tmw) + ((mx - mask_x + (mw * (nx - dx)) / dw) * scalex / tmw);
+ my = (mtex->y / tmh) + ((my - mask_y + (mh * (ny - dy)) / dy) * scaley / tmh);
+ mw = (mw * nw * scalex / dw) / tmw;
+ mh = (mh * nh * scaley / dh) / tmh;
}
if ((!gc->dc->cutout.rects) ||
@@ -133,7 +142,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
0.0, 0.0, 0.0, 0.0,
// sx, sy, sw, sh,
x, y, tex->w, tex->h,
- mtex, mmx, mmy, mmw, mmh,
+ mtex, mx, my, mw, mh, mask_smooth,
r, g, b, a);
return;
}
@@ -144,7 +153,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
evas_gl_common_context_font_push(gc, tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
- mtex, mmx, mmy, mmw, mmh,
+ mtex, mx, my, mw, mh, mask_smooth,
r, g, b, a);
}
else
@@ -153,7 +162,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
0.0, 0.0, 0.0, 0.0,
// sx, sy, sw, sh,
x, y, tex->w, tex->h,
- mtex, mmx, mmy, mmw, mmh,
+ mtex, mx, my, mw, mh, mask_smooth,
r, g, b, a);
}
return;
@@ -183,7 +192,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
0.0, 0.0, 0.0, 0.0,
// sx, sy, sw, sh,
x, y, tex->w, tex->h,
- mtex, mmx, mmy, mmw, mmh,
+ mtex, mx, my, mw, mh, mask_smooth,
r, g, b, a);
continue;
}
@@ -194,7 +203,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
evas_gl_common_context_font_push(gc, tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
- mtex, mmx, mmy, mmw, mmh,
+ mtex, mx, my, mw, mh, mask_smooth,
r, g, b, a);
}
evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects);