GL: query current program before set it in gl context reset 01/45101/2
authorHenry Song <henry.song@samsung.com>
Thu, 9 Jul 2015 14:12:45 +0000 (07:12 -0700)
committernisanthmp <nisanth.mp@samsung.com>
Mon, 3 Aug 2015 13:17:35 +0000 (18:47 +0530)
Change-Id: I36c3de424036ff177a8b5791fc87da3c63d2ee1b
Signed-off-by: nisanthmp <nisanth.mp@samsung.com>
src/cairo-gl-device.c

index b98c769..827d50b 100644 (file)
@@ -1106,14 +1106,18 @@ 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;
+    GLint current_program;
+
     /* 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);
+    if (shader) {
+       ctx->dispatch.GetIntegerv (GL_CURRENT_PROGRAM, &current_program);
+       if ((GLint)(ctx->current_shader->program) != current_program)
+           _cairo_gl_set_shader (ctx, shader);
+    }
 
     ctx->states_cache.viewport_box.width = 0;
     ctx->states_cache.viewport_box.height = 0;