src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
branchRCL_3
changeset 5 d3bac044e0f0
parent 4 3b1da2848fc7
child 8 3f74d0d4af4c
equal deleted inserted replaced
4:3b1da2848fc7 5:d3bac044e0f0
   166 {
   166 {
   167     shaderManager->useSimpleProgram();
   167     shaderManager->useSimpleProgram();
   168 
   168 
   169     if (matrixDirty)
   169     if (matrixDirty)
   170         updateMatrix();
   170         updateMatrix();
   171 
       
   172     if (simpleShaderMatrixUniformDirty) {
       
   173         const GLuint location = shaderManager->simpleProgram()->uniformLocation("pmvMatrix");
       
   174         glUniformMatrix3fv(location, 1, GL_FALSE, (GLfloat*)pmvMatrix);
       
   175         simpleShaderMatrixUniformDirty = false;
       
   176     }
       
   177 }
   171 }
   178 
   172 
   179 void QGL2PaintEngineExPrivate::updateBrushTexture()
   173 void QGL2PaintEngineExPrivate::updateBrushTexture()
   180 {
   174 {
   181     Q_Q(QGL2PaintEngineEx);
   175     Q_Q(QGL2PaintEngineEx);
   390                                   qMax(qAbs(transform.m12()), qAbs(transform.m21())) ),
   384                                   qMax(qAbs(transform.m12()), qAbs(transform.m21())) ),
   391                         qreal(0.0001));
   385                         qreal(0.0001));
   392 
   386 
   393     matrixDirty = false;
   387     matrixDirty = false;
   394 
   388 
   395     // The actual data has been updated so both shader program's uniforms need updating
   389     // Set the PMV matrix attribute. As we use an attributes rather than uniforms, we only
   396     simpleShaderMatrixUniformDirty = true;
   390     // need to do this once for every matrix change and persists across all shader programs.
   397     shaderMatrixUniformDirty = true;
   391     glVertexAttrib3fv(QT_PMV_MATRIX_1_ATTR, pmvMatrix[0]);
       
   392     glVertexAttrib3fv(QT_PMV_MATRIX_2_ATTR, pmvMatrix[1]);
       
   393     glVertexAttrib3fv(QT_PMV_MATRIX_3_ATTR, pmvMatrix[2]);
   398 
   394 
   399     dasher.setInvScale(inverseScale);
   395     dasher.setInvScale(inverseScale);
   400     stroker.setInvScale(inverseScale);
   396     stroker.setInvScale(inverseScale);
   401 }
   397 }
   402 
   398 
   930     bool changed = shaderManager->useCorrectShaderProg();
   926     bool changed = shaderManager->useCorrectShaderProg();
   931     // If the shader program needs changing, we change it and mark all uniforms as dirty
   927     // If the shader program needs changing, we change it and mark all uniforms as dirty
   932     if (changed) {
   928     if (changed) {
   933         // The shader program has changed so mark all uniforms as dirty:
   929         // The shader program has changed so mark all uniforms as dirty:
   934         brushUniformsDirty = true;
   930         brushUniformsDirty = true;
   935         shaderMatrixUniformDirty = true;
       
   936         opacityUniformDirty = true;
   931         opacityUniformDirty = true;
   937     }
   932     }
   938 
   933 
   939     if (brushUniformsDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode)
   934     if (brushUniformsDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode)
   940         updateBrushUniforms();
   935         updateBrushUniforms();
   941 
       
   942     if (shaderMatrixUniformDirty) {
       
   943         glUniformMatrix3fv(location(QGLEngineShaderManager::PmvMatrix), 1, GL_FALSE, (GLfloat*)pmvMatrix);
       
   944         shaderMatrixUniformDirty = false;
       
   945     }
       
   946 
   936 
   947     if (opacityMode == QGLEngineShaderManager::UniformOpacity && opacityUniformDirty) {
   937     if (opacityMode == QGLEngineShaderManager::UniformOpacity && opacityUniformDirty) {
   948         shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::GlobalOpacity), (GLfloat)q->state()->opacity);
   938         shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::GlobalOpacity), (GLfloat)q->state()->opacity);
   949         opacityUniformDirty = false;
   939         opacityUniformDirty = false;
   950     }
   940     }
  1953     // Setting the state as part of a restore().
  1943     // Setting the state as part of a restore().
  1954 
  1944 
  1955     if (old_state == s || old_state->renderHintsChanged)
  1945     if (old_state == s || old_state->renderHintsChanged)
  1956         renderHintsChanged();
  1946         renderHintsChanged();
  1957 
  1947 
  1958     if (old_state == s || old_state->matrixChanged) {
  1948     if (old_state == s || old_state->matrixChanged)
  1959         d->matrixDirty = true;
  1949         d->matrixDirty = true;
  1960         d->simpleShaderMatrixUniformDirty = true;
       
  1961         d->shaderMatrixUniformDirty = true;
       
  1962     }
       
  1963 
  1950 
  1964     if (old_state == s || old_state->compositionModeChanged)
  1951     if (old_state == s || old_state->compositionModeChanged)
  1965         d->compositionModeDirty = true;
  1952         d->compositionModeDirty = true;
  1966 
  1953 
  1967     if (old_state == s || old_state->opacityChanged)
  1954     if (old_state == s || old_state->opacityChanged)