summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cairo-gl-composite.c6
-rw-r--r--src/cairo-gl-device.c22
-rw-r--r--src/cairo-gl-private.h4
-rw-r--r--src/cairo-gl-surface.c36
4 files changed, 60 insertions, 8 deletions
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index c576b67a..7691ef94 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -249,8 +249,6 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand,
assert (surface->base.backend == &_cairo_gl_surface_backend);
- cairo_surface_flush (&surface->base);
-
operand->type = CAIRO_GL_OPERAND_TEXTURE;
operand->texture.surface = surface;
operand->texture.tex = surface->tex;
@@ -717,10 +715,12 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
_cairo_gl_operand_setup_fixed (operand, tex_unit);
}
-static void
+void
_cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx,
cairo_gl_tex_t tex_unit)
{
+ assert (ctx->vb == NULL);
+
switch (ctx->operands[tex_unit].type) {
default:
case CAIRO_GL_OPERAND_COUNT:
diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c
index 0d520588..bf570386 100644
--- a/src/cairo-gl-device.c
+++ b/src/cairo-gl-device.c
@@ -60,6 +60,26 @@ _gl_unlock (void *device)
ctx->current_target = NULL;
}
+static cairo_status_t
+_gl_flush (void *device)
+{
+ cairo_gl_context_t *ctx;
+ cairo_status_t status;
+
+ status = _cairo_gl_context_acquire (device, &ctx);
+ if (unlikely (status))
+ return status;
+
+ _cairo_gl_composite_flush (ctx);
+
+ _cairo_gl_context_destroy_operand (ctx, CAIRO_GL_TEX_SOURCE);
+ _cairo_gl_context_destroy_operand (ctx, CAIRO_GL_TEX_MASK);
+
+ _cairo_gl_context_release (ctx);
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
static void
_gl_finish (void *device)
{
@@ -106,7 +126,7 @@ static const cairo_device_backend_t _cairo_gl_device_backend = {
_gl_lock,
_gl_unlock,
- NULL, /* flush */
+ _gl_flush, /* flush */
_gl_finish,
_gl_destroy,
};
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index 5e5d91f8..f82a45cc 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -350,6 +350,10 @@ cairo_private void
_cairo_gl_composite_end (cairo_gl_context_t *ctx,
cairo_gl_composite_t *setup);
+cairo_private void
+_cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx,
+ cairo_gl_tex_t tex_unit);
+
cairo_private cairo_bool_t
_cairo_gl_get_image_format_and_type (pixman_format_code_t pixman_format,
GLenum *internal_format, GLenum *format,
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index f7340ee8..e64a05ae 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -697,12 +697,18 @@ _cairo_gl_surface_finish (void *abstract_surface)
if (unlikely (status))
return status;
- glDeleteFramebuffersEXT (1, &surface->fb);
- glDeleteTextures (1, &surface->tex);
-
+ if (ctx->operands[CAIRO_GL_TEX_SOURCE].type == CAIRO_GL_OPERAND_TEXTURE &&
+ ctx->operands[CAIRO_GL_TEX_SOURCE].texture.surface == surface)
+ _cairo_gl_context_destroy_operand (ctx, CAIRO_GL_TEX_SOURCE);
+ if (ctx->operands[CAIRO_GL_TEX_MASK].type == CAIRO_GL_OPERAND_TEXTURE &&
+ ctx->operands[CAIRO_GL_TEX_MASK].texture.surface == surface)
+ _cairo_gl_context_destroy_operand (ctx, CAIRO_GL_TEX_MASK);
if (ctx->current_target == surface)
ctx->current_target = NULL;
+ glDeleteFramebuffersEXT (1, &surface->fb);
+ glDeleteTextures (1, &surface->tex);
+
_cairo_gl_context_release (ctx);
return CAIRO_STATUS_SUCCESS;
@@ -1276,6 +1282,28 @@ _cairo_gl_surface_get_font_options (void *abstract_surface,
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
}
+static cairo_status_t
+_cairo_gl_surface_flush (void *abstract_surface)
+{
+ cairo_gl_surface_t *surface = abstract_surface;
+ cairo_status_t status;
+ cairo_gl_context_t *ctx;
+
+ status = _cairo_gl_context_acquire (surface->base.device, &ctx);
+ if (unlikely (status))
+ return status;
+
+ if ((ctx->operands[CAIRO_GL_TEX_SOURCE].type == CAIRO_GL_OPERAND_TEXTURE &&
+ ctx->operands[CAIRO_GL_TEX_SOURCE].texture.surface == surface) ||
+ (ctx->operands[CAIRO_GL_TEX_MASK].type == CAIRO_GL_OPERAND_TEXTURE &&
+ ctx->operands[CAIRO_GL_TEX_MASK].texture.surface == surface) ||
+ (ctx->current_target == surface))
+ _cairo_gl_composite_flush (ctx);
+
+ _cairo_gl_context_release (ctx);
+
+ return CAIRO_STATUS_SUCCESS;
+}
static cairo_int_status_t
_cairo_gl_surface_paint (void *abstract_surface,
@@ -1320,7 +1348,7 @@ const cairo_surface_backend_t _cairo_gl_surface_backend = {
_cairo_gl_surface_get_extents,
NULL, /* old_show_glyphs */
_cairo_gl_surface_get_font_options,
- NULL, /* flush */
+ _cairo_gl_surface_flush,
NULL, /* mark_dirty_rectangle */
_cairo_gl_surface_scaled_font_fini,
_cairo_gl_surface_scaled_glyph_fini,