move depth logic out of QSGRenderer
authorGunnar Sletta <gunnar.sletta@nokia.com>
Thu, 29 Sep 2011 19:00:19 +0000 (21:00 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 4 Oct 2011 13:10:57 +0000 (15:10 +0200)
Change-Id: I1fc3baf858664ea9648922204fa0e4d5ca64d740
Reviewed-on: http://codereview.qt-project.org/5848
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Kim M. Kalland <kim.kalland@nokia.com>
src/declarative/scenegraph/coreapi/qsgdefaultrenderer.cpp
src/declarative/scenegraph/coreapi/qsgrenderer.cpp

index ffecfc4..56a6e0e 100644 (file)
@@ -468,7 +468,10 @@ void QSGDefaultRenderer::renderNodes(const QDataBuffer<QSGGeometryNode *> &list)
         bool changeClip = geomNode->clipList() != m_currentClip;
         QSGRenderer::ClipType clipType = QSGRenderer::NoClip;
         if (changeClip) {
+            // The clip function relies on there not being any depth testing..
+            glDisable(GL_DEPTH_TEST);
             clipType = updateStencilClip(geomNode->clipList());
+            glEnable(GL_DEPTH_TEST);
             m_currentClip = geomNode->clipList();
 #ifdef FORCE_NO_REORDER
             glDepthMask(false);
index af118e0..45aef34 100644 (file)
@@ -486,7 +486,6 @@ QSGRenderer::ClipType QSGRenderer::updateStencilClip(const QSGClipNode *clip)
                 glClearStencil(0);
                 glClear(GL_STENCIL_BUFFER_BIT);
                 glEnable(GL_STENCIL_TEST);
-                glDisable(GL_DEPTH_TEST);
                 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
                 glDepthMask(GL_FALSE);
 
@@ -519,12 +518,10 @@ QSGRenderer::ClipType QSGRenderer::updateStencilClip(const QSGClipNode *clip)
 
     if (stencilEnabled) {
         m_clip_program.disableAttributeArray(0);
-        glEnable(GL_DEPTH_TEST);
         glStencilFunc(GL_EQUAL, clipDepth, 0xff); // stencil test, ref, test mask
         glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // stencil fail, z fail, z pass
         glStencilMask(0); // write mask
         bindable()->reactivate();
-        //glDepthMask(GL_TRUE); // must be reset correctly by caller.
     } else {
         glDisable(GL_STENCIL_TEST);
     }