1 #include "evas_gl_private.h"
4 evas_gl_font_texture_new(void *context, RGBA_Font_Glyph *fg)
6 Evas_Engine_GL_Context *gc = context;
13 if (fg->ext_dat) return fg->ext_dat; // FIXME: one engine at a time can do this :(
15 w = fg->glyph_out->bitmap.width;
16 h = fg->glyph_out->bitmap.rows;
17 if ((w == 0) || (h == 0)) return NULL;
19 data = fg->glyph_out->bitmap.buffer;
20 j = fg->glyph_out->bitmap.pitch;
23 nw = ((w + 3) / 4) * 4;
24 ndata = alloca(nw *h);
25 if (!ndata) return NULL;
26 if (fg->glyph_out->bitmap.num_grays == 256)
31 for (y = 0; y < h; y++)
34 p2 = ndata + (nw * y);
35 for (x = 0; x < w; x++)
43 else if (fg->glyph_out->bitmap.num_grays == 0)
45 DATA8 *tmpbuf = NULL, *dp, *tp, bits;
47 const DATA8 bitrepl[2] = {0x0, 0xff};
55 for (y = 0; y < h; y++)
58 p2 = ndata + (nw * y);
60 dp = data + (y * fg->glyph_out->bitmap.pitch);
61 for (bi = 0; bi < w; bi += 8)
64 if ((w - bi) < 8) end = w - bi;
66 for (bj = 0; bj < end; bj++)
68 *tp = bitrepl[(bits >> (7 - bj)) & 0x1];
73 for (x = 0; x < w; x++)
84 tex = evas_gl_common_texture_alpha_new(gc, ndata, w, h, fh);
85 tex->sx1 = ((double)(tex->x)) / (double)tex->pt->w;
86 tex->sy1 = ((double)(tex->y)) / (double)tex->pt->h;
87 tex->sx2 = ((double)(tex->x + tex->w)) / (double)tex->pt->w;
88 tex->sy2 = ((double)(tex->y + tex->h)) / (double)tex->pt->h;
93 evas_gl_font_texture_free(void *tex)
96 evas_gl_common_texture_free(tex);
100 evas_gl_font_texture_draw(void *context, void *surface __UNUSED__, void *draw_context, RGBA_Font_Glyph *fg, int x, int y)
102 Evas_Engine_GL_Context *gc = context;
103 RGBA_Draw_Context *dc = draw_context;
104 Evas_GL_Texture *tex;
108 double ssx, ssy, ssw, ssh;
109 int c, cx, cy, cw, ch;
113 if (dc != gc->dc) return;
116 a = (dc->col.col >> 24) & 0xff;
118 r = (dc->col.col >> 16) & 0xff;
119 g = (dc->col.col >> 8 ) & 0xff;
120 b = (dc->col.col ) & 0xff;
121 sx = 0; sy = 0; sw = tex->w, sh = tex->h;
122 if ((!gc->dc->cutout.rects)
123 // || (gc->dc->cutout.active > 32)
126 if (gc->dc->clip.use)
130 nx = x; ny = y; nw = tex->w; nh = tex->h;
131 RECTS_CLIP_TO_RECT(nx, ny, nw, nh,
132 gc->dc->clip.x, gc->dc->clip.y,
133 gc->dc->clip.w, gc->dc->clip.h);
134 if ((nw < 1) || (nh < 1)) return;
135 if ((nx == x) && (ny == y) && (nw == tex->w) && (nh == tex->h))
137 evas_gl_common_context_font_push(gc, tex,
140 x, y, tex->w, tex->h,
144 ssx = (double)sx + ((double)(sw * (nx - x)) / (double)(tex->w));
145 ssy = (double)sy + ((double)(sh * (ny - y)) / (double)(tex->h));
146 ssw = ((double)sw * (double)(nw)) / (double)(tex->w);
147 ssh = ((double)sh * (double)(nh)) / (double)(tex->h);
148 evas_gl_common_context_font_push(gc, tex,
155 evas_gl_common_context_font_push(gc, tex,
158 x, y, tex->w, tex->h,
163 /* save out clip info */
164 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;
165 evas_common_draw_context_clip_clip(gc->dc, 0, 0, gc->w, gc->h);
166 evas_common_draw_context_clip_clip(gc->dc, x, y, tex->w, tex->h);
167 /* our clip is 0 size.. abort */
168 if ((gc->dc->clip.w <= 0) || (gc->dc->clip.h <= 0))
170 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;
173 rects = evas_common_draw_context_apply_cutouts(dc);
174 for (i = 0; i < rects->active; ++i)
178 rct = rects->rects + i;
179 nx = x; ny = y; nw = tex->w; nh = tex->h;
180 RECTS_CLIP_TO_RECT(nx, ny, nw, nh, rct->x, rct->y, rct->w, rct->h);
181 if ((nw < 1) || (nh < 1)) continue;
182 if ((nx == x) && (ny == y) && (nw == tex->w) && (nh == tex->h))
184 evas_gl_common_context_font_push(gc, tex,
187 x, y, tex->w, tex->h,
191 ssx = (double)sx + ((double)(sw * (nx - x)) / (double)(tex->w));
192 ssy = (double)sy + ((double)(sh * (ny - y)) / (double)(tex->h));
193 ssw = ((double)sw * (double)(nw)) / (double)(tex->w);
194 ssh = ((double)sh * (double)(nh)) / (double)(tex->h);
195 evas_gl_common_context_font_push(gc, tex,
200 evas_common_draw_context_apply_clear_cutouts(rects);
201 /* restore clip info */
202 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;