diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-11-25 12:21:18 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-11-25 12:21:18 +0000 |
commit | 03be2019cd12936cf86d304a9391b5be2bf6e39e (patch) | |
tree | e8e2fdc828bd9a09d0aae63862349d30124f04ff /src/cairo-gl-operand.c | |
parent | 5f6d3fe40b52785c80f210c6597328311c987eb3 (diff) |
gl: And enable subsurface caching of the clones
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-gl-operand.c')
-rw-r--r-- | src/cairo-gl-operand.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/src/cairo-gl-operand.c b/src/cairo-gl-operand.c index 76cc7108..d115c33c 100644 --- a/src/cairo-gl-operand.c +++ b/src/cairo-gl-operand.c @@ -86,31 +86,38 @@ _cairo_gl_subsurface_clone_operand_init (cairo_gl_operand_t *operand, sub = (cairo_surface_subsurface_t *) src->surface; - status = _cairo_gl_context_acquire (dst->base.device, &ctx); - if (unlikely (status)) - return status; - - surface = (cairo_gl_surface_t *) - _cairo_gl_surface_create_scratch (ctx, - sub->target->content, - extents->width, extents->height); - if (surface->base.status) - return _cairo_gl_context_release (ctx, surface->base.status); - - _cairo_pattern_init_for_surface (&local_pattern, sub->target); - cairo_matrix_init_translate (&local_pattern.base.matrix, - sub->extents.x, sub->extents.y); - local_pattern.base.filter = CAIRO_FILTER_NEAREST; - status = _cairo_surface_paint (&surface->base, - CAIRO_OPERATOR_SOURCE, - &local_pattern.base, - NULL); - _cairo_pattern_fini (&local_pattern.base); + if (sub->snapshot) { + surface = (cairo_gl_surface_t *) + cairo_surface_reference (sub->snapshot); + } else { + status = _cairo_gl_context_acquire (dst->base.device, &ctx); + if (unlikely (status)) + return status; + + surface = (cairo_gl_surface_t *) + _cairo_gl_surface_create_scratch (ctx, + sub->target->content, + extents->width, extents->height); + if (surface->base.status) + return _cairo_gl_context_release (ctx, surface->base.status); + + _cairo_pattern_init_for_surface (&local_pattern, sub->target); + cairo_matrix_init_translate (&local_pattern.base.matrix, + sub->extents.x, sub->extents.y); + local_pattern.base.filter = CAIRO_FILTER_NEAREST; + status = _cairo_surface_paint (&surface->base, + CAIRO_OPERATOR_SOURCE, + &local_pattern.base, + NULL); + _cairo_pattern_fini (&local_pattern.base); + + status = _cairo_gl_context_release (ctx, status); + if (unlikely (status)) { + cairo_surface_destroy (&surface->base); + return status; + } - status = _cairo_gl_context_release (ctx, status); - if (unlikely (status)) { - cairo_surface_destroy (&surface->base); - return status; + _cairo_surface_subsurface_set_snapshot (&sub->base, &surface->base); } attributes = &operand->texture.attributes; |