GL: reset GL context's current program to cairo's shader 00/45100/1
authorHenry Song <henry.song@samsung.com>
Wed, 8 Jul 2015 15:07:08 +0000 (08:07 -0700)
committernisanthmp <nisanth.mp@samsung.com>
Fri, 31 Jul 2015 12:05:37 +0000 (17:35 +0530)
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 <nisanth.mp@samsung.com>
src/cairo-gl-device.c

index dbb6f16..b98c769 100644 (file)
@@ -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;