From 7a9a971d386015c2c4da1565942ba1d34657b0e7 Mon Sep 17 00:00:00 2001 From: Henry Song Date: Wed, 8 Jul 2015 08:07:08 -0700 Subject: [PATCH] GL: reset GL context's current program to cairo's shader When cairo's GL context is used by external libraries or applications, it is possible that GL context's current program is changed. When we detect such changes, we must reset GL context's current program to cairo current shader Change-Id: Ifeadbff488200b5a8bcc5014bda9bf5c0f8df3a8 Signed-off-by: nisanthmp --- src/cairo-gl-device.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index dbb6f16..b98c769 100644 --- a/src/cairo-gl-device.c +++ b/src/cairo-gl-device.c @@ -1105,6 +1105,16 @@ cairo_gl_device_set_thread_aware (cairo_device_t *device, void _cairo_gl_context_reset (cairo_gl_context_t *ctx) { + cairo_gl_shader_t *shader = ctx->current_shader; + /* reset current shader, this is because if cairo shares a same + * context other extern libraries or applications, the current + * program may well be changed, in this case, we must set cairo + * to use cairo program + */ + ctx->current_shader = NULL; + if (shader) + _cairo_gl_set_shader (ctx, shader); + ctx->states_cache.viewport_box.width = 0; ctx->states_cache.viewport_box.height = 0; @@ -1127,8 +1137,6 @@ void _cairo_gl_context_reset (cairo_gl_context_t *ctx) /* FIXME: this is hack to fix mali driver */ ctx->dispatch.Disable (GL_DITHER); - ctx->current_shader = NULL; - ctx->states_cache.bound_vbo = 0; ctx->states_cache.bound_vao = 0; ctx->states_cache.bound_ibo = 0; -- 2.7.4