summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/gl2paintengineex/qglengineshadermanager.cpp')
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
index fec1973..b3458af 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
@@ -332,7 +332,6 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context)
srcPixelType(Qt::NoBrush),
useGlobalOpacity(false),
maskType(NoMask),
- useTextureCoords(false),
compositionMode(QPainter::CompositionMode_SourceOver),
customSrcStage(0),
currentShaderProg(0),
@@ -407,15 +406,6 @@ void QGLEngineShaderManager::setSrcPixelType(PixelSrcType type)
shaderProgNeedsChanging = true; //###
}
-void QGLEngineShaderManager::setTextureCoordsEnabled(bool enabled)
-{
- if (useTextureCoords == enabled)
- return;
-
- useTextureCoords = enabled;
- shaderProgNeedsChanging = true; //###
-}
-
void QGLEngineShaderManager::setUseGlobalOpacity(bool useOpacity)
{
if (useGlobalOpacity == useOpacity)
@@ -492,15 +482,8 @@ bool QGLEngineShaderManager::useCorrectShaderProg()
QGLEngineShaderProg requiredProgram;
requiredProgram.program = 0;
- requiredProgram.useTextureCoords = useTextureCoords;
- // Choose vertex shader main function
- QGLEngineSharedShaders::ShaderName mainVertexShaderName = QGLEngineSharedShaders::InvalidShaderName;
- if (useTextureCoords)
- mainVertexShaderName = QGLEngineSharedShaders::MainWithTexCoordsVertexShader;
- else
- mainVertexShaderName = QGLEngineSharedShaders::MainVertexShader;
- requiredProgram.mainVertexShader = sharedShaders->compileNamedShader(mainVertexShaderName, QGLShader::PartialVertexShader);
+ bool texCoords = false;
// Choose vertex shader shader position function (which typically also sets
// varyings) and the source pixel (srcPixel) fragment shader function:
@@ -523,14 +506,17 @@ bool QGLEngineShaderManager::useCorrectShaderProg()
case QGLEngineShaderManager::ImageSrc:
srcPixelFragShaderName = QGLEngineSharedShaders::ImageSrcFragmentShader;
positionVertexShaderName = QGLEngineSharedShaders::PositionOnlyVertexShader;
+ texCoords = true;
break;
case QGLEngineShaderManager::NonPremultipliedImageSrc:
srcPixelFragShaderName = QGLEngineSharedShaders::NonPremultipliedImageSrcFragmentShader;
positionVertexShaderName = QGLEngineSharedShaders::PositionOnlyVertexShader;
+ texCoords = true;
break;
case QGLEngineShaderManager::PatternSrc:
srcPixelFragShaderName = QGLEngineSharedShaders::ImageSrcWithPatternFragmentShader;
positionVertexShaderName = QGLEngineSharedShaders::PositionOnlyVertexShader;
+ texCoords = true;
break;
case QGLEngineShaderManager::TextureSrcWithPattern:
srcPixelFragShaderName = QGLEngineSharedShaders::TextureBrushSrcWithPatternFragmentShader;
@@ -598,14 +584,16 @@ bool QGLEngineShaderManager::useCorrectShaderProg()
if (hasMask) {
QGLEngineSharedShaders::ShaderName maskShaderName = QGLEngineSharedShaders::InvalidShaderName;
- if (maskType == PixelMask)
+ if (maskType == PixelMask) {
maskShaderName = QGLEngineSharedShaders::MaskFragmentShader;
- else if (maskType == SubPixelMask)
+ texCoords = true;
+ } else if (maskType == SubPixelMask) {
maskShaderName = QGLEngineSharedShaders::RgbMaskFragmentShader;
- else if (maskType == SubPixelWithGammaMask)
+ } else if (maskType == SubPixelWithGammaMask) {
maskShaderName = QGLEngineSharedShaders::RgbMaskWithGammaFragmentShader;
- else
+ } else {
qCritical("QGLEngineShaderManager::useCorrectShaderProg() - Unknown mask type");
+ }
requiredProgram.maskFragShader = sharedShaders->compileNamedShader(maskShaderName, QGLShader::PartialFragmentShader);
} else {
@@ -656,6 +644,16 @@ bool QGLEngineShaderManager::useCorrectShaderProg()
requiredProgram.compositionFragShader = 0;
}
+ // Choose vertex shader main function
+ QGLEngineSharedShaders::ShaderName mainVertexShaderName = QGLEngineSharedShaders::InvalidShaderName;
+ if (texCoords)
+ mainVertexShaderName = QGLEngineSharedShaders::MainWithTexCoordsVertexShader;
+ else
+ mainVertexShaderName = QGLEngineSharedShaders::MainVertexShader;
+ requiredProgram.mainVertexShader = sharedShaders->compileNamedShader(mainVertexShaderName, QGLShader::PartialVertexShader);
+ requiredProgram.useTextureCoords = texCoords;
+
+
// At this point, requiredProgram is fully populated so try to find the program in the cache
currentShaderProg = sharedShaders->findProgramInCache(requiredProgram);