… | |
… | |
35 | |
35 | |
36 | struct _PangoOpenGLRenderer |
36 | struct _PangoOpenGLRenderer |
37 | { |
37 | { |
38 | PangoRenderer parent_instance; |
38 | PangoRenderer parent_instance; |
39 | float r, g, b, a; // modulate |
39 | float r, g, b, a; // modulate |
|
|
40 | int flags; |
40 | GLuint curtex; // current texture |
41 | GLuint curtex; // current texture |
41 | }; |
42 | }; |
42 | |
43 | |
43 | G_DEFINE_TYPE (PangoOpenGLRenderer, pango_opengl_renderer, PANGO_TYPE_RENDERER) |
44 | G_DEFINE_TYPE (PangoOpenGLRenderer, pango_opengl_renderer, PANGO_TYPE_RENDERER) |
44 | |
45 | |
… | |
… | |
265 | } |
266 | } |
266 | |
267 | |
267 | void |
268 | void |
268 | pango_opengl_render_layout_subpixel (PangoLayout *layout, |
269 | pango_opengl_render_layout_subpixel (PangoLayout *layout, |
269 | int x, int y, |
270 | int x, int y, |
270 | float r, float g, float b, float a) |
271 | float r, float g, float b, float a, |
|
|
272 | int flags) |
271 | { |
273 | { |
272 | PangoContext *context; |
274 | PangoContext *context; |
273 | PangoFontMap *fontmap; |
275 | PangoFontMap *fontmap; |
274 | PangoRenderer *renderer; |
276 | PangoRenderer *renderer; |
275 | |
277 | |
… | |
… | |
279 | |
281 | |
280 | PANGO_OPENGL_RENDERER (renderer)->r = r; |
282 | PANGO_OPENGL_RENDERER (renderer)->r = r; |
281 | PANGO_OPENGL_RENDERER (renderer)->g = g; |
283 | PANGO_OPENGL_RENDERER (renderer)->g = g; |
282 | PANGO_OPENGL_RENDERER (renderer)->b = b; |
284 | PANGO_OPENGL_RENDERER (renderer)->b = b; |
283 | PANGO_OPENGL_RENDERER (renderer)->a = a; |
285 | PANGO_OPENGL_RENDERER (renderer)->a = a; |
|
|
286 | PANGO_OPENGL_RENDERER (renderer)->flags = flags; |
284 | |
287 | |
285 | pango_renderer_draw_layout (renderer, layout, x, y); |
288 | pango_renderer_draw_layout (renderer, layout, x, y); |
286 | } |
289 | } |
287 | |
290 | |
288 | void |
291 | void |
289 | pango_opengl_render_layout (PangoLayout *layout, |
292 | pango_opengl_render_layout (PangoLayout *layout, |
290 | int x, int y, |
293 | int x, int y, |
291 | float r, float g, float b, float a) |
294 | float r, float g, float b, float a, |
|
|
295 | int flags) |
292 | { |
296 | { |
293 | pango_opengl_render_layout_subpixel (layout, x * PANGO_SCALE, y * PANGO_SCALE, r, g, b, a); |
297 | pango_opengl_render_layout_subpixel (layout, x * PANGO_SCALE, y * PANGO_SCALE, r, g, b, a, flags); |
294 | } |
298 | } |
295 | |
299 | |
296 | static void |
300 | static void |
297 | pango_opengl_renderer_init (PangoOpenGLRenderer *renderer) |
301 | pango_opengl_renderer_init (PangoOpenGLRenderer *renderer) |
298 | { |
302 | { |
… | |
… | |
306 | prepare_run (PangoRenderer *renderer, PangoLayoutRun *run) |
310 | prepare_run (PangoRenderer *renderer, PangoLayoutRun *run) |
307 | { |
311 | { |
308 | PangoOpenGLRenderer *glrenderer = (PangoOpenGLRenderer *)renderer; |
312 | PangoOpenGLRenderer *glrenderer = (PangoOpenGLRenderer *)renderer; |
309 | PangoColor *fg = 0; |
313 | PangoColor *fg = 0; |
310 | GSList *l; |
314 | GSList *l; |
|
|
315 | unsigned char r, g, b, a; |
311 | |
316 | |
312 | renderer->underline = PANGO_UNDERLINE_NONE; |
317 | renderer->underline = PANGO_UNDERLINE_NONE; |
313 | renderer->strikethrough = FALSE; |
318 | renderer->strikethrough = FALSE; |
314 | |
319 | |
315 | for (l = run->item->analysis.extra_attrs; l; l = l->next) |
320 | for (l = run->item->analysis.extra_attrs; l; l = l->next) |
… | |
… | |
334 | break; |
339 | break; |
335 | } |
340 | } |
336 | } |
341 | } |
337 | |
342 | |
338 | if (fg) |
343 | if (fg) |
339 | glColor4f (fg->red / 65535., fg->green / 65535., fg->blue / 65535., glrenderer->a); |
344 | { |
|
|
345 | r = fg->red * (255.f / 65535.f); |
|
|
346 | g = fg->green * (255.f / 65535.f); |
|
|
347 | b = fg->blue * (255.f / 65535.f); |
|
|
348 | } |
340 | else |
349 | else |
341 | glColor4f (glrenderer->r, glrenderer->g, glrenderer->b, glrenderer->a); |
350 | { |
|
|
351 | r = glrenderer->r * 255.f; |
|
|
352 | g = glrenderer->g * 255.f; |
|
|
353 | b = glrenderer->b * 255.f; |
|
|
354 | } |
|
|
355 | |
|
|
356 | a = glrenderer->a * 255.f; |
|
|
357 | |
|
|
358 | if (glrenderer->flags & FLAG_INVERSE) |
|
|
359 | { |
|
|
360 | r ^= 0xffU; |
|
|
361 | g ^= 0xffU; |
|
|
362 | b ^= 0xffU; |
|
|
363 | } |
|
|
364 | |
|
|
365 | glColor4ub (r, g, b, a); |
342 | } |
366 | } |
343 | |
367 | |
344 | static void |
368 | static void |
345 | draw_begin (PangoRenderer *renderer_) |
369 | draw_begin (PangoRenderer *renderer_) |
346 | { |
370 | { |