diff options
Diffstat (limited to 'src/opengl/gl2paintengineex')
4 files changed, 30 insertions, 35 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 2502069..b3458af 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -282,7 +282,8 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS // We have to bind the vertex attribute names before the program is linked: cached.program->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); - cached.program->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); + if (cached.useTextureCoords) + cached.program->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); cached.program->link(); if (!cached.program->isLinked()) { @@ -331,7 +332,6 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) srcPixelType(Qt::NoBrush), useGlobalOpacity(false), maskType(NoMask), - useTextureCoords(false), compositionMode(QPainter::CompositionMode_SourceOver), customSrcStage(0), currentShaderProg(0), @@ -406,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,13 +483,7 @@ bool QGLEngineShaderManager::useCorrectShaderProg() QGLEngineShaderProg requiredProgram; requiredProgram.program = 0; - // 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: @@ -521,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; @@ -596,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 { @@ -654,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); diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 423df99..3c5a5f5 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -245,6 +245,8 @@ struct QGLEngineShaderProg QVector<uint> uniformLocations; + bool useTextureCoords; + bool operator==(const QGLEngineShaderProg& other) { // We don't care about the program return ( mainVertexShader == other.mainVertexShader && @@ -408,7 +410,6 @@ public: void optimiseForBrushTransform(const QTransform &transform); void setSrcPixelType(Qt::BrushStyle); void setSrcPixelType(PixelSrcType); // For non-brush sources, like pixmaps & images - void setTextureCoordsEnabled(bool); // For images & text glyphs void setUseGlobalOpacity(bool); void setMaskType(MaskType); void setCompositionMode(QPainter::CompositionMode); @@ -450,7 +451,6 @@ private: int srcPixelType; bool useGlobalOpacity; MaskType maskType; - bool useTextureCoords; QPainter::CompositionMode compositionMode; QGLCustomShaderStage* customSrcStage; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index e41d0b4..837d055 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -668,7 +668,6 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s { // Setup for texture drawing shaderManager->setSrcPixelType(pattern ? QGLEngineShaderManager::PatternSrc : QGLEngineShaderManager::ImageSrc); - shaderManager->setTextureCoordsEnabled(true); if (prepareForDraw(opaque)) shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT); @@ -1241,7 +1240,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte else if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMask); //### TODO: Gamma correction - shaderManager->setTextureCoordsEnabled(true); int margin = cache->glyphMargin(); @@ -1769,14 +1767,6 @@ QOpenGL2PaintEngineState::~QOpenGL2PaintEngineState() { } -QPixmapFilter *QGL2PaintEngineEx::createPixmapFilter(int type) const -{ - const QGLContext *ctx = QGLContext::currentContext(); - if (ctx) - return ctx->d_func()->createPixmapFilter(type); - return 0; -} - QT_END_NAMESPACE #include "qpaintengineex_opengl2.moc" diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 34f4eb8..a44be90 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -59,6 +59,7 @@ #include <private/qglengineshadermanager_p.h> #include <private/qgl2pexvertexarray_p.h> #include <private/qglpaintdevice_p.h> +#include <private/qglpixmapfilter_p.h> enum EngineMode { ImageDrawingMode, @@ -140,7 +141,7 @@ public: const QGLContext* context(); - QPixmapFilter *createPixmapFilter(int type) const; + QPixmapFilter *pixmapFilter(int type, const QPixmapFilter *prototype); void setRenderTextActive(bool); @@ -264,6 +265,10 @@ public: bool inRenderText; float textureInvertedY; + + QScopedPointer<QPixmapFilter> convolutionFilter; + QScopedPointer<QPixmapFilter> colorizeFilter; + QScopedPointer<QPixmapFilter> blurFilter; }; QT_END_NAMESPACE |