Support QSGGeometry::lineWidth also in the batched code path.
authorGunnar Sletta <gunnar.sletta@jollamobile.com>
Tue, 11 Aug 2015 16:33:01 +0000 (18:33 +0200)
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>
Mon, 17 Aug 2015 09:54:22 +0000 (09:54 +0000)
Change-Id: Ifc664b9c718744b9549953e42ac3450a88403dea
Task-number: QTBUG-47090
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h

index 63938d50a94479eeac970699d0406778c9076d49..42b9f526d072d0857f8ae52c77ca21d2dc4f80ad 100644 (file)
@@ -1518,6 +1518,7 @@ void Renderer::prepareOpaqueBatches()
 
             if (gni->clipList() == gnj->clipList()
                     && gni->geometry()->drawingMode() == gnj->geometry()->drawingMode()
+                    && (gni->geometry()->drawingMode() != GL_LINES || gni->geometry()->lineWidth() == gnj->geometry()->lineWidth())
                     && gni->geometry()->attributes() == gnj->geometry()->attributes()
                     && gni->inheritedOpacity() == gnj->inheritedOpacity()
                     && gni->activeMaterial()->type() == gnj->activeMaterial()->type()
@@ -1616,6 +1617,7 @@ void Renderer::prepareAlphaBatches()
 
             if (gni->clipList() == gnj->clipList()
                     && gni->geometry()->drawingMode() == gnj->geometry()->drawingMode()
+                    && (gni->geometry()->drawingMode() != GL_LINES || gni->geometry()->lineWidth() == gnj->geometry()->lineWidth())
                     && gni->geometry()->attributes() == gnj->geometry()->attributes()
                     && gni->inheritedOpacity() == gnj->inheritedOpacity()
                     && gni->activeMaterial()->type() == gnj->activeMaterial()->type()
@@ -2278,6 +2280,7 @@ void Renderer::renderMergedBatch(const Batch *batch)
     m_currentMaterial = material;
 
     QSGGeometry* g = gn->geometry();
+    updateLineWidth(g);
     char const *const *attrNames = program->attributeNames();
     for (int i=0; i<batch->drawSets.size(); ++i) {
         const DrawSet &draw = batch->drawSets.at(i);
@@ -2408,24 +2411,7 @@ void Renderer::renderUnmergedBatch(const Batch *batch)
             offset += a.tupleSize * size_of_type(a.type);
         }
 
-        if (g->drawingMode() == GL_LINE_STRIP || g->drawingMode() == GL_LINE_LOOP || g->drawingMode() == GL_LINES)
-            glLineWidth(g->lineWidth());
-#if !defined(QT_OPENGL_ES_2)
-        else if (!QOpenGLContext::currentContext()->isOpenGLES() && g->drawingMode() == GL_POINTS) {
-            QOpenGLFunctions_1_0 *gl1funcs = 0;
-            QOpenGLFunctions_3_2_Core *gl3funcs = 0;
-            if (QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile)
-                gl3funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_3_2_Core>();
-            else
-                gl1funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_1_0>();
-            Q_ASSERT(gl1funcs || gl3funcs);
-            if (gl1funcs)
-                gl1funcs->glPointSize(g->lineWidth());
-            else
-                gl3funcs->glPointSize(g->lineWidth());
-        }
-#endif
-
+        updateLineWidth(g);
         if (g->indexCount())
             glDrawElements(g->drawingMode(), g->indexCount(), g->indexType(), iOffset);
         else
@@ -2441,6 +2427,27 @@ void Renderer::renderUnmergedBatch(const Batch *batch)
     }
 }
 
+void Renderer::updateLineWidth(QSGGeometry *g)
+{
+    if (g->drawingMode() == GL_LINE_STRIP || g->drawingMode() == GL_LINE_LOOP || g->drawingMode() == GL_LINES)
+        glLineWidth(g->lineWidth());
+#if !defined(QT_OPENGL_ES_2)
+    else if (!QOpenGLContext::currentContext()->isOpenGLES() && g->drawingMode() == GL_POINTS) {
+        QOpenGLFunctions_1_0 *gl1funcs = 0;
+        QOpenGLFunctions_3_2_Core *gl3funcs = 0;
+        if (QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile)
+            gl3funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_3_2_Core>();
+        else
+            gl1funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_1_0>();
+        Q_ASSERT(gl1funcs || gl3funcs);
+        if (gl1funcs)
+            gl1funcs->glPointSize(g->lineWidth());
+        else
+            gl3funcs->glPointSize(g->lineWidth());
+    }
+#endif
+}
+
 void Renderer::renderBatches()
 {
     if (Q_UNLIKELY(debug_render())) {
index f87dd75c8c422d82b955d8ae8572a94290a192ac..6b494dbaebfe9d94d0dd597d7d46f3f1a21e25ad 100644 (file)
@@ -591,6 +591,7 @@ private:
     void nodeWasRemoved(Node *node);
     void nodeWasAdded(QSGNode *node, Node *shadowParent);
     BatchRootInfo *batchRootInfo(Node *node);
+    void updateLineWidth(QSGGeometry *g);
 
     inline Batch *newBatch();
     void invalidateAndRecycleBatch(Batch *b);