2003-09-07 04:24:48 -07:00
|
|
|
#include "evas_gl_private.h"
|
2003-09-08 22:51:03 -07:00
|
|
|
|
2009-12-21 07:52:12 -08:00
|
|
|
void *
|
|
|
|
evas_gl_font_texture_new(void *context, RGBA_Font_Glyph *fg)
|
2003-09-10 01:52:18 -07:00
|
|
|
{
|
2011-03-16 10:32:49 -07:00
|
|
|
Evas_Engine_GL_Context *gc = context;
|
2009-10-09 05:10:27 -07:00
|
|
|
Evas_GL_Texture *tex;
|
2014-01-12 12:13:00 -08:00
|
|
|
int w, h, j, nw, fh, x, y;
|
|
|
|
DATA8 *ndata, *data, *p1, *p2;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2009-10-09 05:10:27 -07:00
|
|
|
if (fg->ext_dat) return fg->ext_dat; // FIXME: one engine at a time can do this :(
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2008-01-21 21:31:25 -08:00
|
|
|
w = fg->glyph_out->bitmap.width;
|
|
|
|
h = fg->glyph_out->bitmap.rows;
|
|
|
|
if ((w == 0) || (h == 0)) return NULL;
|
2003-09-10 01:52:18 -07:00
|
|
|
|
2014-01-12 12:13:00 -08:00
|
|
|
if (!fg->glyph_out->rle) return NULL;
|
|
|
|
data = evas_common_font_glyph_uncompress(fg, &w, &h);
|
|
|
|
if (!data) return NULL;
|
|
|
|
j = w;
|
2003-09-10 01:52:18 -07:00
|
|
|
if (j < w) j = w;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2014-01-12 12:13:00 -08:00
|
|
|
// expand to 32bit (4 byte) aligned rows for texture upload
|
2009-10-13 03:42:03 -07:00
|
|
|
nw = ((w + 3) / 4) * 4;
|
2009-10-09 05:10:27 -07:00
|
|
|
ndata = alloca(nw *h);
|
|
|
|
if (!ndata) return NULL;
|
2014-01-12 12:13:00 -08:00
|
|
|
for (y = 0; y < h; y++)
|
2003-09-10 01:52:18 -07:00
|
|
|
{
|
2014-01-12 12:13:00 -08:00
|
|
|
p1 = data + (j * y);
|
|
|
|
p2 = ndata + (nw * y);
|
|
|
|
for (x = 0; x < w; x++)
|
|
|
|
{
|
|
|
|
*p2 = *p1;
|
|
|
|
p1++;
|
|
|
|
p2++;
|
|
|
|
}
|
2005-09-05 01:01:15 -07:00
|
|
|
}
|
2009-10-09 05:10:27 -07:00
|
|
|
fh = fg->fi->max_h;
|
|
|
|
tex = evas_gl_common_texture_alpha_new(gc, ndata, w, h, fh);
|
2014-01-12 12:13:00 -08:00
|
|
|
if (!tex) goto done;
|
2009-10-13 02:40:39 -07:00
|
|
|
tex->sx1 = ((double)(tex->x)) / (double)tex->pt->w;
|
|
|
|
tex->sy1 = ((double)(tex->y)) / (double)tex->pt->h;
|
|
|
|
tex->sx2 = ((double)(tex->x + tex->w)) / (double)tex->pt->w;
|
|
|
|
tex->sy2 = ((double)(tex->y + tex->h)) / (double)tex->pt->h;
|
2012-08-14 01:31:59 -07:00
|
|
|
tex->fglyph = fg;
|
|
|
|
gc->font_glyph_textures = eina_list_append(gc->font_glyph_textures, tex);
|
2014-01-12 12:13:00 -08:00
|
|
|
done:
|
|
|
|
free(data);
|
2009-10-09 05:10:27 -07:00
|
|
|
return tex;
|
2003-09-10 01:52:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-21 07:52:12 -08:00
|
|
|
evas_gl_font_texture_free(void *tex)
|
2003-09-10 01:52:18 -07:00
|
|
|
{
|
2009-10-09 05:10:27 -07:00
|
|
|
if (!tex) return;
|
2013-06-13 23:51:18 -07:00
|
|
|
evas_gl_common_texture_free(tex, EINA_TRUE);
|
2003-09-10 01:52:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-11-04 03:51:42 -08:00
|
|
|
evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_context, RGBA_Font_Glyph *fg, int x, int y)
|
2003-09-10 01:52:18 -07:00
|
|
|
{
|
2011-03-16 10:32:49 -07:00
|
|
|
Evas_Engine_GL_Context *gc = context;
|
2009-12-21 07:52:12 -08:00
|
|
|
RGBA_Draw_Context *dc = draw_context;
|
2015-02-25 02:05:12 -08:00
|
|
|
Evas_GL_Image *mask = gc->dc->clip.mask;
|
2015-03-31 18:54:45 -07:00
|
|
|
Evas_GL_Texture *tex, *mtex = NULL;
|
2009-10-09 05:10:27 -07:00
|
|
|
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;
|
2015-02-25 02:05:12 -08:00
|
|
|
double mx = 0.0, my = 0.0, mw = 0.0, mh = 0.0;
|
|
|
|
Eina_Bool mask_smooth = EINA_FALSE;
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2009-10-09 05:10:27 -07:00
|
|
|
if (dc != gc->dc) return;
|
|
|
|
tex = fg->ext_dat;
|
|
|
|
if (!tex) return;
|
|
|
|
a = (dc->col.col >> 24) & 0xff;
|
|
|
|
if (a == 0) return;
|
|
|
|
r = (dc->col.col >> 16) & 0xff;
|
|
|
|
g = (dc->col.col >> 8 ) & 0xff;
|
|
|
|
b = (dc->col.col ) & 0xff;
|
|
|
|
sx = 0; sy = 0; sw = tex->w, sh = tex->h;
|
2014-11-24 21:34:42 -08:00
|
|
|
|
2015-03-31 18:54:45 -07:00
|
|
|
if (mask)
|
2014-11-24 21:34:42 -08:00
|
|
|
{
|
2015-03-31 18:54:45 -07:00
|
|
|
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;
|
2014-11-24 21:34:42 -08:00
|
|
|
}
|
|
|
|
|
2011-09-19 03:48:33 -07:00
|
|
|
if ((!gc->dc->cutout.rects) ||
|
|
|
|
((gc->shared->info.tune.cutout.max > 0) &&
|
|
|
|
(gc->dc->cutout.active > gc->shared->info.tune.cutout.max)))
|
2009-10-09 05:10:27 -07:00
|
|
|
{
|
|
|
|
if (gc->dc->clip.use)
|
|
|
|
{
|
|
|
|
int nx, ny, nw, nh;
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2009-10-09 05:10:27 -07:00
|
|
|
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;
|
|
|
|
if ((nx == x) && (ny == y) && (nw == tex->w) && (nh == tex->h))
|
|
|
|
{
|
|
|
|
evas_gl_common_context_font_push(gc, tex,
|
2009-10-13 02:40:39 -07:00
|
|
|
0.0, 0.0, 0.0, 0.0,
|
|
|
|
// sx, sy, sw, sh,
|
2009-10-09 05:10:27 -07:00
|
|
|
x, y, tex->w, tex->h,
|
2015-02-25 02:05:12 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth,
|
2009-10-09 05:10:27 -07:00
|
|
|
r, g, b, a);
|
|
|
|
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);
|
2011-06-17 00:47:28 -07:00
|
|
|
evas_gl_common_context_font_push(gc, tex,
|
2009-10-09 05:10:27 -07:00
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
2015-02-25 02:05:12 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth,
|
2009-10-09 05:10:27 -07:00
|
|
|
r, g, b, a);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-06-17 00:47:28 -07:00
|
|
|
evas_gl_common_context_font_push(gc, tex,
|
2009-10-13 02:40:39 -07:00
|
|
|
0.0, 0.0, 0.0, 0.0,
|
|
|
|
// sx, sy, sw, sh,
|
2009-10-09 05:10:27 -07:00
|
|
|
x, y, tex->w, tex->h,
|
2015-02-25 02:05:12 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth,
|
2009-10-09 05:10:27 -07:00
|
|
|
r, g, b, a);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* 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;
|
2012-04-12 01:01:13 -07:00
|
|
|
evas_common_draw_context_clip_clip(gc->dc, 0, 0, gc->shared->w, gc->shared->h);
|
2009-10-09 05:10:27 -07:00
|
|
|
evas_common_draw_context_clip_clip(gc->dc, x, y, tex->w, tex->h);
|
|
|
|
/* our clip is 0 size.. abort */
|
|
|
|
if ((gc->dc->clip.w <= 0) || (gc->dc->clip.h <= 0))
|
|
|
|
{
|
|
|
|
gc->dc->clip.use = c; gc->dc->clip.x = cx; gc->dc->clip.y = cy; gc->dc->clip.w = cw; gc->dc->clip.h = ch;
|
|
|
|
return;
|
|
|
|
}
|
2014-08-07 02:13:07 -07:00
|
|
|
_evas_gl_common_cutout_rects = evas_common_draw_context_apply_cutouts(dc, _evas_gl_common_cutout_rects);
|
|
|
|
for (i = 0; i < _evas_gl_common_cutout_rects->active; ++i)
|
2009-10-09 05:10:27 -07:00
|
|
|
{
|
|
|
|
int nx, ny, nw, nh;
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2014-08-07 02:13:07 -07:00
|
|
|
rct = _evas_gl_common_cutout_rects->rects + i;
|
2009-10-09 05:10:27 -07:00
|
|
|
nx = x; ny = y; nw = tex->w; nh = tex->h;
|
|
|
|
RECTS_CLIP_TO_RECT(nx, ny, nw, nh, rct->x, rct->y, rct->w, rct->h);
|
|
|
|
if ((nw < 1) || (nh < 1)) continue;
|
|
|
|
if ((nx == x) && (ny == y) && (nw == tex->w) && (nh == tex->h))
|
|
|
|
{
|
|
|
|
evas_gl_common_context_font_push(gc, tex,
|
2009-10-13 02:40:39 -07:00
|
|
|
0.0, 0.0, 0.0, 0.0,
|
|
|
|
// sx, sy, sw, sh,
|
2009-10-09 05:10:27 -07:00
|
|
|
x, y, tex->w, tex->h,
|
2015-02-25 02:05:12 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth,
|
2009-10-09 05:10:27 -07:00
|
|
|
r, g, b, a);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
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);
|
2011-06-17 00:47:28 -07:00
|
|
|
evas_gl_common_context_font_push(gc, tex,
|
2009-10-09 05:10:27 -07:00
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
2015-02-25 02:05:12 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth,
|
2009-10-09 05:10:27 -07:00
|
|
|
r, g, b, a);
|
|
|
|
}
|
2014-08-07 02:13:07 -07:00
|
|
|
evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects);
|
2009-10-09 05:10:27 -07:00
|
|
|
/* restore clip info */
|
|
|
|
gc->dc->clip.use = c; gc->dc->clip.x = cx; gc->dc->clip.y = cy; gc->dc->clip.w = cw; gc->dc->clip.h = ch;
|
2003-09-08 22:51:03 -07:00
|
|
|
}
|