diff options
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 44 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadermanager_p.h | 4 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 2 | ||||
-rw-r--r-- | src/opengl/qgl.cpp | 4 | ||||
-rw-r--r-- | src/opengl/qgl_x11egl.cpp | 11 |
5 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 2ee92c3..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(); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 1a0957c..fe676ea 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2560,8 +2560,6 @@ static void qDrawTextureRect(const QRectF &target, GLint textureWidth, GLint tex Draws the given texture, \a textureId, to the given target rectangle, \a target, in OpenGL model space. The \a textureTarget should be a 2D texture target. - - Equivalent to the corresponding QGLContext::drawTexture(). */ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) { @@ -2603,8 +2601,6 @@ void QGLContext::drawTexture(const QRectF &target, QMacCompatGLuint textureId, Q Draws the given texture at the given \a point in OpenGL model space. The \a textureTarget should be a 2D texture target. - - Equivalent to the corresponding QGLContext::drawTexture(). */ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) { diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 7dfd642..32d8cc2 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -298,7 +298,7 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, XRenderPictFormat *format; format = XRenderFindVisualFormat(x11Info().display(), chosenVisualInfo->visual); if (format->type == PictTypeDirect && format->direct.alphaMask) { - qDebug("Using opaque X Visual ID (%d) provided by EGL", (int)vi.visualid); +// qDebug("Using opaque X Visual ID (%d) provided by EGL", (int)vi.visualid); vi = *chosenVisualInfo; } else { @@ -309,7 +309,7 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, } else #endif { - qDebug("Using opaque X Visual ID (%d) provided by EGL", (int)vi.visualid); +// qDebug("Using opaque X Visual ID (%d) provided by EGL", (int)vi.visualid); vi = *chosenVisualInfo; } XFree(chosenVisualInfo); @@ -342,7 +342,7 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, format = XRenderFindVisualFormat(x11Info().display(), matchingVisuals[i].visual); if (format->type == PictTypeDirect && format->direct.alphaMask) { vi = matchingVisuals[i]; - qDebug("Using X Visual ID (%d) for ARGB visual as provided by XRender", (int)vi.visualid); +// qDebug("Using X Visual ID (%d) for ARGB visual as provided by XRender", (int)vi.visualid); break; } } @@ -365,8 +365,9 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, return; } else qWarning(" - Falling back to X11 suggested depth (%d)", depth); - } else - qDebug("Using X Visual ID (%d) for EGL provided depth (%d)", (int)vi.visualid, depth); + } +// else +// qDebug("Using X Visual ID (%d) for EGL provided depth (%d)", (int)vi.visualid, depth); // Don't try to use ARGB now unless the visual is 32-bit - even then it might stil fail :-( if (useArgb) |