changeset 3785:c51b01afa79b

RT-30720 Filter out unneeded calls to glEnable(GL_SCISSOR_TEST)
author Daniel Blaukopf <daniel.blaukopf@oracle.com>
date Mon, 03 Jun 2013 12:48:25 +0300
parents 582edfecdb04
children 8af9dc9dae1c
files prism-es2-native/src/GLContext.c
diffstat 1 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/prism-es2-native/src/GLContext.c	Sat Jun 01 08:00:37 2013 -0700
+++ b/prism-es2-native/src/GLContext.c	Mon Jun 03 12:48:25 2013 +0300
@@ -136,8 +136,10 @@
     glDisable(GL_ALPHA_TEST);
 #endif
 
-    ctxInfo->state.scissorEnabled = JNI_FALSE;
-    glDisable(GL_SCISSOR_TEST);
+    if (ctxInfo->state.scissorEnabled) {
+        ctxInfo->state.scissorEnabled = JNI_FALSE;
+        glDisable(GL_SCISSOR_TEST);
+    }
 
     ctxInfo->state.clearColor[0] = 0.0;
     ctxInfo->state.clearColor[1] = 0.0;
@@ -955,10 +957,12 @@
     }
 
     if (enable) {
-        glEnable(GL_SCISSOR_TEST);
+        if (!ctxInfo->state.scissorEnabled) {
+            glEnable(GL_SCISSOR_TEST);
+            ctxInfo->state.scissorEnabled = JNI_TRUE;
+        }
         glScissor(x, y, w, h);
-        ctxInfo->state.scissorEnabled = JNI_TRUE;
-    } else {
+    } else if (ctxInfo->state.scissorEnabled) {
         glDisable(GL_SCISSOR_TEST);
         ctxInfo->state.scissorEnabled = JNI_FALSE;
     }
@@ -1588,8 +1592,10 @@
     glEnable(GL_BLEND);
     glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
-    ctxInfo->state.scissorEnabled = JNI_FALSE;
-    glDisable(GL_SCISSOR_TEST);
+    if (ctxInfo->state.scissorEnabled) {
+        ctxInfo->state.scissorEnabled = JNI_FALSE;
+        glDisable(GL_SCISSOR_TEST);
+    }
 
     glCullFace(GL_BACK);
     ctxInfo->state.cullMode = GL_BACK;
@@ -1618,8 +1624,10 @@
     glDisable(GL_BLEND);
     glBlendFunc(GL_ONE, GL_ZERO);
 
-    ctxInfo->state.scissorEnabled = JNI_FALSE;
-    glDisable(GL_SCISSOR_TEST);
+    if (ctxInfo->state.scissorEnabled) {
+        ctxInfo->state.scissorEnabled = JNI_FALSE;
+        glDisable(GL_SCISSOR_TEST);
+    }
 
     glEnable(GL_CULL_FACE);
     ctxInfo->state.cullEnable = GL_TRUE;