summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-12-05 15:28:10 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-12-05 17:17:26 +0000
commit31c0726f682159e6465719c389975ec8885fa38b (patch)
tree7fc5c582de78a7539aaa9f3a8a5ec027435f48d0
parent16038150b3691d4d4a320a727afc107cd0937ac6 (diff)
gl: Embed the operand rather than a pattern into the glyph cache
Use the native encoding for patterns. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/cairo-gl-glyphs.c48
-rw-r--r--src/cairo-gl-private.h2
2 files changed, 19 insertions, 31 deletions
diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c
index ae2d1812..90ff8a6a 100644
--- a/src/cairo-gl-glyphs.c
+++ b/src/cairo-gl-glyphs.c
@@ -82,7 +82,6 @@ _cairo_gl_glyph_cache_add_glyph (cairo_gl_context_t *ctx,
cairo_scaled_glyph_t *scaled_glyph)
{
cairo_image_surface_t *glyph_surface = scaled_glyph->surface;
- cairo_gl_surface_t *cache_surface;
cairo_gl_glyph_t *glyph_private;
cairo_rtree_node_t *node = NULL;
cairo_int_status_t status;
@@ -109,11 +108,9 @@ _cairo_gl_glyph_cache_add_glyph (cairo_gl_context_t *ctx,
if (status)
return status;
- cache_surface = (cairo_gl_surface_t *) cache->pattern.surface;
-
/* XXX: Make sure we use the mask texture. This should work automagically somehow */
glActiveTexture (GL_TEXTURE1);
- status = _cairo_gl_surface_draw_image (cache_surface,
+ status = _cairo_gl_surface_draw_image (cache->operand.texture.surface,
glyph_surface,
0, 0,
glyph_surface->width, glyph_surface->height,
@@ -137,10 +134,10 @@ _cairo_gl_glyph_cache_add_glyph (cairo_gl_context_t *ctx,
glyph_private->p2.x = node->x + glyph_surface->width;
glyph_private->p2.y = node->y + glyph_surface->height;
if (! _cairo_gl_device_requires_power_of_two_textures (&ctx->base)) {
- glyph_private->p1.x /= cache_surface->width;
- glyph_private->p1.y /= cache_surface->height;
- glyph_private->p2.x /= cache_surface->width;
- glyph_private->p2.y /= cache_surface->height;
+ glyph_private->p1.x /= cache->operand.texture.surface->width;
+ glyph_private->p2.x /= cache->operand.texture.surface->width;
+ glyph_private->p1.y /= cache->operand.texture.surface->height;
+ glyph_private->p1.y /= cache->operand.texture.surface->height;
}
return CAIRO_STATUS_SUCCESS;
@@ -180,21 +177,22 @@ cairo_gl_context_get_glyph_cache (cairo_gl_context_t *ctx,
return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
}
- if (unlikely (cache->pattern.surface == NULL)) {
+ if (unlikely (cache->operand.texture.surface == NULL)) {
cairo_surface_t *surface;
+
surface = cairo_gl_surface_create (&ctx->base,
content,
GLYPH_CACHE_WIDTH,
GLYPH_CACHE_HEIGHT);
- if (unlikely (surface->status)) {
- cairo_status_t status = surface->status;
- cairo_surface_destroy (surface);
- return status;
- }
+ if (unlikely (surface->status))
+ return surface->status;
+
_cairo_surface_release_device_reference (surface);
- _cairo_pattern_init_for_surface (&cache->pattern, surface);
- cairo_surface_destroy (surface);
- cache->pattern.base.has_component_alpha = (content == CAIRO_CONTENT_COLOR_ALPHA);
+
+ cache->operand = ((cairo_gl_surface_t *)surface)->operand;
+ cache->operand.texture.surface = (cairo_gl_surface_t *)surface;
+ cache->operand.texture.attributes.has_component_alpha =
+ content == CAIRO_CONTENT_COLOR_ALPHA;
}
*cache_out = cache;
@@ -272,14 +270,8 @@ render_glyphs (cairo_gl_surface_t *dst,
last_format = scaled_glyph->surface->format;
- status = _cairo_gl_composite_set_mask (&setup,
- &cache->pattern.base,
- &_cairo_unbounded_rectangle,
- &_cairo_unbounded_rectangle);
- if (unlikely (status))
- goto FINISH;
-
- *has_component_alpha |= cache->pattern.base.has_component_alpha;
+ _cairo_gl_composite_set_mask_operand (&setup, &cache->operand);
+ *has_component_alpha |= cache->operand.texture.attributes.has_component_alpha;
/* XXX: _cairo_gl_composite_begin() acquires the context a
* second time. Need to refactor this loop so this doesn't happen.
@@ -469,9 +461,5 @@ _cairo_gl_glyph_cache_fini (cairo_gl_context_t *ctx,
cairo_gl_glyph_cache_t *cache)
{
_cairo_rtree_fini (&cache->rtree);
-
- if (cache->pattern.surface) {
- _cairo_pattern_fini (&cache->pattern.base);
- cache->pattern.surface = NULL;
- }
+ cairo_surface_destroy (&cache->operand.texture.surface->base);
}
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index d8446768..be109fa9 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -168,7 +168,7 @@ struct _cairo_gl_surface {
typedef struct cairo_gl_glyph_cache {
cairo_rtree_t rtree;
- cairo_surface_pattern_t pattern;
+ cairo_gl_operand_t operand;
} cairo_gl_glyph_cache_t;
typedef enum cairo_gl_tex {