diff options
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 4 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadersource_p.h | 12 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 45 | ||||
-rw-r--r-- | src/opengl/qglpixelbuffer.cpp | 2 |
4 files changed, 31 insertions, 32 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 2d1885c..2502069 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -216,6 +216,8 @@ void QGLEngineSharedShaders::shaderDestroyed(QObject *shader) QGLShader *QGLEngineSharedShaders::compileNamedShader(ShaderName name, QGLShader::ShaderType type) { Q_ASSERT(name != CustomImageSrcFragmentShader); + Q_ASSERT(name < InvalidShaderName); + if (compiledShaders[name]) return compiledShaders[name]; @@ -514,7 +516,7 @@ bool QGLEngineShaderManager::useCorrectShaderProg() else switch (srcPixelType) { default: case Qt::NoBrush: - qCritical("QGLEngineShaderManager::useCorrectShaderProg() - I'm scared, Qt::NoBrush style is set"); + qFatal("QGLEngineShaderManager::useCorrectShaderProg() - Qt::NoBrush style is set"); break; case QGLEngineShaderManager::ImageSrc: srcPixelFragShaderName = QGLEngineSharedShaders::ImageSrcFragmentShader; diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index acd4461..6bcf010 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -260,12 +260,24 @@ static const char* const qglslPositionWithTextureBrushVertexShader = "\ static const char* const qglslAffinePositionWithTextureBrushVertexShader = qglslPositionWithTextureBrushVertexShader; +#if defined(QT_OPENGL_ES_2) +// OpenGL ES does not support GL_REPEAT wrap modes for NPOT textures. So instead, +// we emulate GL_REPEAT by only taking the fractional part of the texture coords. +// TODO: Special case POT textures which don't need this emulation +static const char* const qglslTextureBrushSrcFragmentShader = "\ + varying highp vec2 brushTextureCoords; \ + uniform lowp sampler2D brushTexture; \ + lowp vec4 srcPixel() { \ + return texture2D(brushTexture, fract(brushTextureCoords)); \ + }"; +#else static const char* const qglslTextureBrushSrcFragmentShader = "\ varying highp vec2 brushTextureCoords; \ uniform lowp sampler2D brushTexture; \ lowp vec4 srcPixel() { \ return texture2D(brushTexture, brushTextureCoords); \ }"; +#endif static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\ varying highp vec2 brushTextureCoords; \ diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index e32bbbd..5e790cf 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1039,60 +1039,45 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush) { Q_D(QGL2PaintEngineEx); - if (brush.style() == Qt::NoBrush) + if (qbrush_style(brush) == Qt::NoBrush) return; if (!d->inRenderText) ensureActive(); d->setBrush(&brush); d->fill(path); - d->setBrush(&(state()->brush)); // reset back to the state's brush } void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) { Q_D(QGL2PaintEngineEx); - if (pen.style() == Qt::NoPen) + Qt::PenStyle penStyle = qpen_style(pen); + const QBrush &penBrush = qpen_brush(pen); + if (penStyle == Qt::NoPen || qbrush_style(penBrush) == Qt::NoBrush) return; ensureActive(); - if ( (pen.isCosmetic() && (pen.style() == Qt::SolidLine)) && (pen.widthF() < 2.5f) ) + qreal penWidth = qpen_widthf(pen); + if ( (pen.isCosmetic() && (penStyle == Qt::SolidLine)) && (penWidth < 2.5f) ) { // We only handle solid, cosmetic pens with a width of 1 pixel const QBrush& brush = pen.brush(); d->setBrush(&brush); - if (pen.widthF() < 0.01f) + if (penWidth < 0.01f) glLineWidth(1.0); else - glLineWidth(pen.widthF()); + glLineWidth(penWidth); d->drawOutline(path); - d->setBrush(&(state()->brush)); } else return QPaintEngineEx::stroke(path, pen); } -void QGL2PaintEngineEx::penChanged() -{ -// qDebug("QGL2PaintEngineEx::penChanged() not implemented!"); -} - - -void QGL2PaintEngineEx::brushChanged() -{ -// qDebug("QGL2PaintEngineEx::brushChanged()"); - Q_D(QGL2PaintEngineEx); - d->setBrush(&(state()->brush)); -} - -void QGL2PaintEngineEx::brushOriginChanged() -{ -// qDebug("QGL2PaintEngineEx::brushOriginChanged()"); - Q_D(QGL2PaintEngineEx); - d->brushUniformsDirty = true; -} +void QGL2PaintEngineEx::penChanged() { } +void QGL2PaintEngineEx::brushChanged() { } +void QGL2PaintEngineEx::brushOriginChanged() { } void QGL2PaintEngineEx::opacityChanged() { @@ -1300,8 +1285,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data()); glDrawArrays(GL_TRIANGLES, 0, 6 * glyphs.size()); - - setBrush(&(q->state()->brush)); //### } bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) @@ -1555,6 +1538,7 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) if (state()->rectangleClip.isValid() && op != Qt::NoClip && op != Qt::ReplaceClip) { QPainterPath path; path.addRect(state()->rectangleClip); + path = state()->matrix.inverted().map(path); state()->rectangleClip = QRect(); d->updateDepthScissorTest(); @@ -1715,8 +1699,6 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state) d->matrixDirty = true; d->compositionModeDirty = true; - d->brushTextureDirty = true; - d->brushUniformsDirty = true; d->simpleShaderDepthUniformDirty = true; d->depthUniformDirty = true; d->simpleShaderMatrixUniformDirty = true; @@ -1739,6 +1721,9 @@ QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const { Q_D(const QGL2PaintEngineEx); + if (orig) + const_cast<QGL2PaintEngineEx *>(this)->ensureActive(); + QOpenGL2PaintEngineState *s; if (!orig) s = new QOpenGL2PaintEngineState(); diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index 6cd8968..07bc711 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -402,7 +402,7 @@ QPaintEngine *QGLPixelBuffer::paintEngine() const #elif defined(QT_OPENGL_ES_2) return qt_buffer_2_engine(); #else - if (d_ptr->qctx->d_func()->internal_context || qt_gl_preferGL2Engine()) + if (qt_gl_preferGL2Engine()) return qt_buffer_2_engine(); else return qt_buffer_engine(); |