src/opengl/gl2paintengineex/qglengineshadermanager.cpp
changeset 30 5dc02b23752f
parent 25 e24348a560a6
--- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -96,6 +96,7 @@
 
         code[UntransformedPositionVertexShader] = qglslUntransformedPositionVertexShader;
         code[PositionOnlyVertexShader] = qglslPositionOnlyVertexShader;
+        code[ComplexGeometryPositionOnlyVertexShader] = qglslComplexGeometryPositionOnlyVertexShader;
         code[PositionWithPatternBrushVertexShader] = qglslPositionWithPatternBrushVertexShader;
         code[PositionWithLinearGradientBrushVertexShader] = qglslPositionWithLinearGradientBrushVertexShader;
         code[PositionWithConicalGradientBrushVertexShader] = qglslPositionWithConicalGradientBrushVertexShader;
@@ -329,7 +330,7 @@
             newProg->program->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
         if (newProg->useOpacityAttribute)
             newProg->program->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR);
-        if (newProg->usePmvMatrix) {
+        if (newProg->usePmvMatrixAttribute) {
             newProg->program->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR);
             newProg->program->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR);
             newProg->program->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR);
@@ -403,6 +404,7 @@
 QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context)
     : ctx(context),
       shaderProgNeedsChanging(true),
+      complexGeometry(false),
       srcPixelType(Qt::NoBrush),
       opacityMode(NoOpacity),
       maskType(NoMask),
@@ -444,7 +446,8 @@
         "inverse_2_fmp2_m_radius2",
         "invertedTextureSize",
         "brushTransform",
-        "brushTexture"
+        "brushTexture",
+        "matrix"
     };
 
     if (uniformLocations.at(id) == GLuint(-1))
@@ -752,7 +755,16 @@
     }
     requiredProgram.useTextureCoords = texCoords;
     requiredProgram.useOpacityAttribute = (opacityMode == AttributeOpacity);
-    requiredProgram.usePmvMatrix = true;
+    if (complexGeometry && srcPixelType == Qt::SolidPattern) {
+        requiredProgram.positionVertexShader = QGLEngineSharedShaders::ComplexGeometryPositionOnlyVertexShader;
+        requiredProgram.usePmvMatrixAttribute = false;
+    } else {
+        requiredProgram.usePmvMatrixAttribute = true;
+
+        // Force complexGeometry off, since we currently don't support that mode for
+        // non-solid brushes
+        complexGeometry = false;
+    }
 
     // At this point, requiredProgram is fully populated so try to find the program in the cache
     currentShaderProg = sharedShaders->findProgramInCache(requiredProgram);