From 8927084d0acfea2bb3fc8a932069c1d5ceb001d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 10 Jan 2013 15:09:32 +0100 Subject: Refactor paint/font-engine shouldDrawCachedGlyphs and supportsTransformations Some cruft had built up over time, and this is an attempt at cleaning up the naming and use of these functions, and should not have any behavioral effects. The function supportsTransformations() has been renamed in QPaintEngineEx to reflect its use, which is to decide if QPainter needs to pre-transform the coordinates of the static text before asking the paint-engine to draw it. The new name is requiresPretransformedGlyphPositions(). The OpenGL and CoreGraphics (Mac) paint engines keep their behavior of not needing pre-transformed text, while the raster engine needs this when using cached glyphs. The base-class implementation assumes that all transforms that include a projection will need pre-transform, which is also the case for the raster engine. All decisions in the paint engines about whether or not to use the glyph cache when drawing text are now deferred to the function shouldDrawCachedGlyphs(), which has been refactored for the GL paint engine(s) to share more logic. All implementations call the base class implementation, which ensures that large font sizes will not be cached. The raster engine will in addition ask the font engine whether or not it can produce glyphs for the glyph-cache with the given transform. This is the only remaining instance of the supportsTransformations() function, and will for all font engines except the CoreText engine support affine transformations. The CoreText engine on the other hand only supports translations (for now). Change-Id: I8fb5e43e3de3ef62a526a79a6dfeda7f9546771d Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 22 ++++++++++++---------- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 3 ++- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'src/opengl/gl2paintengineex') diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 7284efa53b..ebff94da77 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -626,6 +626,16 @@ bool QGL2PaintEngineEx::isNativePaintingActive() const { return d->nativePaintingActive; } +bool QGL2PaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &t) const +{ + float det = t.determinant(); + + // Don't try to cache huge fonts or vastly transformed fonts + return t.type() < QTransform::TxProject + && QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t) + && det >= 0.25f && det <= 4.f; +} + void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) { if (newMode == mode) @@ -1439,11 +1449,10 @@ void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem) ensureActive(); QPainterState *s = state(); - float det = s->matrix.determinant(); // don't try to cache huge fonts or vastly transformed fonts QFontEngine *fontEngine = textItem->fontEngine(); - if (shouldDrawCachedGlyphs(fontEngine, s->matrix) && det >= 0.25f && det <= 4.f) { + if (shouldDrawCachedGlyphs(fontEngine, s->matrix)) { QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat) : d->glyphCacheType; @@ -1497,13 +1506,6 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem QTransform::TransformationType txtype = s->matrix.type(); - float det = s->matrix.determinant(); - bool drawCached = txtype < QTransform::TxProject; - - // don't try to cache huge fonts or vastly transformed fonts - if (!shouldDrawCachedGlyphs(ti.fontEngine, s->matrix) || det < 0.25f || det > 4.f) - drawCached = false; - QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : d->glyphCacheType; @@ -1519,7 +1521,7 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem } } - if (drawCached) { + if (shouldDrawCachedGlyphs(ti.fontEngine, s->matrix)) { QVarLengthArray positions; QVarLengthArray glyphs; QTransform matrix = QTransform::fromTranslate(p.x(), p.y()); diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index f2dc5af768..dd09046bc9 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -155,7 +155,8 @@ public: void setRenderTextActive(bool); bool isNativePaintingActive() const; - bool supportsTransformations(QFontEngine *, const QTransform &) const { return true; } + bool requiresPretransformedGlyphPositions(QFontEngine *, const QTransform &) const { return false; } + bool shouldDrawCachedGlyphs(QFontEngine *, const QTransform &) const; private: Q_DISABLE_COPY(QGL2PaintEngineEx) }; -- cgit v1.2.3 From b5922c89ba942f59d52ebbbf4986565ef410a14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 15 Jan 2013 15:32:41 +0100 Subject: Add support for retina glyph-based text drawing in the GL paint-engine Instead of always using a non-transformed glyph-cache we now allow a scaled glyph-cache so that retina-screens can take advantage of this. We take the cache's scale into account when positioning and drawing the glyphs so that the scale is not applied twice. Change-Id: Ia927656f0070df61e78da76e97d2c49de4d856d9 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 34 ++++++++++++++++------ .../gl2paintengineex/qpaintengineex_opengl2_p.h | 1 + 2 files changed, 26 insertions(+), 9 deletions(-) (limited to 'src/opengl/gl2paintengineex') diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index ebff94da77..22be2e08a0 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1086,6 +1086,18 @@ void QGL2PaintEngineExPrivate::resetClipIfNeeded() glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } +bool QGL2PaintEngineExPrivate::prepareForCachedGlyphDraw(const QFontEngineGlyphCache &cache) +{ + Q_Q(QGL2PaintEngineEx); + + QTransform &transform = q->state()->matrix; + transform.scale(1.0 / cache.transform().m11(), 1.0 / cache.transform().m22()); + bool ret = prepareForDraw(false); + transform.scale(cache.transform().m11(), cache.transform().m22()); + + return ret; +} + bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) { if (brushTextureDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode) @@ -1580,11 +1592,15 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp void *cacheKey = const_cast(QGLContextPrivate::contextGroup(ctx)->context()); bool recreateVertexArrays = false; + // We allow scaling, so that the glyph-cache will contain glyphs with the + // appropriate resolution in the case of displays with a device-pixel-ratio != 1. + QTransform transform = QTransform::fromScale(s->matrix.m11(), s->matrix.m22()); + QFontEngine *fe = staticTextItem->fontEngine(); QGLTextureGlyphCache *cache = - (QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, QTransform()); + (QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, transform); if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) { - cache = new QGLTextureGlyphCache(glyphType, QTransform()); + cache = new QGLTextureGlyphCache(glyphType, transform); fe->setGlyphCache(cacheKey, cache); recreateVertexArrays = true; } @@ -1676,8 +1692,8 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp if (c.isNull()) continue; - int x = qFloor(staticTextItem->glyphPositions[i].x) + c.baseLineX - margin; - int y = qRound(staticTextItem->glyphPositions[i].y) - c.baseLineY - margin; + int x = qFloor(staticTextItem->glyphPositions[i].x.toReal() * cache->transform().m11()) + c.baseLineX - margin; + int y = qRound(staticTextItem->glyphPositions[i].y.toReal() * cache->transform().m22()) - c.baseLineY - margin; vertexCoordinates->addQuad(QRectF(x, y, c.w, c.h)); textureCoordinates->addQuad(QRectF(c.x*dx, c.y*dy, c.w * dx, c.h * dy)); @@ -1750,9 +1766,9 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp } compositionModeDirty = false; // I can handle this myself, thank you very much - prepareForDraw(false); // Text always causes src pixels to be transparent + prepareForCachedGlyphDraw(*cache); - // prepareForDraw() have set the opacity on the current shader, so the opacity state can now be reset. + // prepareForCachedGlyphDraw() have set the opacity on the current shader, so the opacity state can now be reset. if (compMode == QPainter::CompositionMode_Source) { q->state()->opacity = oldOpacity; opacityUniformDirty = true; @@ -1773,7 +1789,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp } compositionModeDirty = false; // I can handle this myself, thank you very much - prepareForDraw(false); // Text always causes src pixels to be transparent + prepareForCachedGlyphDraw(*cache); glEnable(GL_BLEND); glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); @@ -1797,7 +1813,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp } compositionModeDirty = false; - prepareForDraw(false); // Text always causes src pixels to be transparent + prepareForCachedGlyphDraw(*cache); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); } @@ -1806,7 +1822,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp // Greyscale/mono glyphs shaderManager->setMaskType(QGLEngineShaderManager::PixelMask); - prepareForDraw(false); // Text always causes src pixels to be transparent + prepareForCachedGlyphDraw(*cache); } QGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QGLTextureGlyphCache::Linear:QGLTextureGlyphCache::Nearest; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index dd09046bc9..3004b5c9d0 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -227,6 +227,7 @@ public: void setBrush(const QBrush& brush); void transferMode(EngineMode newMode); bool prepareForDraw(bool srcPixelsAreOpaque); // returns true if the program has changed + bool prepareForCachedGlyphDraw(const QFontEngineGlyphCache &cache); inline void useSimpleShader(); inline GLuint location(const QGLEngineShaderManager::Uniform uniform) { return shaderManager->getUniformLocation(uniform); -- cgit v1.2.3 From a71c7fce8ac536212d78b525a8a76e5c130362ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 22 Jan 2013 17:05:09 +0100 Subject: Don't assume m11/m22 represents the scale of a QTransform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can still assume it when pulling out the scale of the glyph cache, since we limit it to scaling, but when computing the scale from the current matrix we have to decompose it. We always use a positive scale in the glyph-cache, and let the drawing code take care of any flipping of the coordinates. Change-Id: Ie3c4f2d91008a9be8f89bef29c15d80b23fb8a82 Reviewed-by: Tor Arne Vestbø --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/opengl/gl2paintengineex') diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 8489daf794..b6da578f26 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1090,6 +1090,8 @@ bool QGL2PaintEngineExPrivate::prepareForCachedGlyphDraw(const QFontEngineGlyphC { Q_Q(QGL2PaintEngineEx); + Q_ASSERT(cache.transform().type() <= QTransform::TxScale); + QTransform &transform = q->state()->matrix; transform.scale(1.0 / cache.transform().m11(), 1.0 / cache.transform().m22()); bool ret = prepareForDraw(false); @@ -1594,7 +1596,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp // We allow scaling, so that the glyph-cache will contain glyphs with the // appropriate resolution in the case of displays with a device-pixel-ratio != 1. - QTransform transform = QTransform::fromScale(s->matrix.m11(), s->matrix.m22()); + QTransform transform = s->matrix.type() < QTransform::TxRotate ? + QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) : + QTransform::fromScale( + QVector2D(s->matrix.m11(), s->matrix.m12()).length(), + QVector2D(s->matrix.m21(), s->matrix.m22()).length()); QFontEngine *fe = staticTextItem->fontEngine(); QGLTextureGlyphCache *cache = -- cgit v1.2.3 From 07e3bcdc106ac42703ae0fb88b6cac2d2bfdd072 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Sat, 26 Jan 2013 21:42:12 +0100 Subject: Remove QT_{BEGIN,END}_HEADER macro usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp Reviewed-by: Jędrzej Nowacki Reviewed-by: hjk --- src/opengl/gl2paintengineex/qglcustomshaderstage_p.h | 4 ---- src/opengl/gl2paintengineex/qglengineshadermanager_p.h | 4 ---- src/opengl/gl2paintengineex/qglengineshadersource_p.h | 4 ---- src/opengl/gl2paintengineex/qglshadercache_meego_p.h | 4 ---- src/opengl/gl2paintengineex/qglshadercache_p.h | 4 ---- 5 files changed, 20 deletions(-) (limited to 'src/opengl/gl2paintengineex') diff --git a/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h b/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h index 4dffeb6bc6..69a6ef2896 100644 --- a/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h +++ b/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h @@ -55,8 +55,6 @@ #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -86,7 +84,5 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 1c519231ef..eff33d6da0 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -228,8 +228,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -508,6 +506,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif //QGLENGINE_SHADER_MANAGER_H diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index 5e689804e4..65fbada48f 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -56,8 +56,6 @@ #include "qglengineshadermanager_p.h" -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -523,6 +521,4 @@ static const char* const qglslRgbMaskFragmentShaderPass2 = "\n\ QT_END_NAMESPACE -QT_END_HEADER - #endif // GLGC_SHADER_SOURCE_H diff --git a/src/opengl/gl2paintengineex/qglshadercache_meego_p.h b/src/opengl/gl2paintengineex/qglshadercache_meego_p.h index f104b9cc88..f3c345f9ac 100644 --- a/src/opengl/gl2paintengineex/qglshadercache_meego_p.h +++ b/src/opengl/gl2paintengineex/qglshadercache_meego_p.h @@ -68,8 +68,6 @@ # include #endif -QT_BEGIN_HEADER - /* This cache stores internal Qt shader programs in shared memory. @@ -450,7 +448,5 @@ QT_END_NAMESPACE #endif -QT_END_HEADER - #endif #endif diff --git a/src/opengl/gl2paintengineex/qglshadercache_p.h b/src/opengl/gl2paintengineex/qglshadercache_p.h index e05987c219..4fbddd4966 100644 --- a/src/opengl/gl2paintengineex/qglshadercache_p.h +++ b/src/opengl/gl2paintengineex/qglshadercache_p.h @@ -59,8 +59,6 @@ # include "qglshadercache_meego_p.h" #else -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -91,7 +89,5 @@ public: QT_END_NAMESPACE -QT_END_HEADER - #endif #endif -- cgit v1.2.3 From 02c3e955e375c803c524495b25e5054eebf18509 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 28 Jan 2013 20:20:01 -0800 Subject: Fix change-of-sign warning found by ICC qdbusintegrator_p.h(119): error #68: integer conversion resulted in a change of sign : QMetaCallEvent(0, -1, 0, sender, -1, 0, 0, 0, s), connection(c), node(n), ^ qpaintengineex_opengl2_p.h(193): error #68: integer conversion resulted in a change of sign void updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id = -1); ^ Change-Id: I7de381ea9ff348878ee99e5a18525352a779b31e Reviewed-by: Olivier Goffart --- src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/opengl/gl2paintengineex') diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 3605b300cc..401a3824c5 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -191,7 +191,7 @@ public: void updateBrushUniforms(); void updateMatrix(); void updateCompositionMode(); - void updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id = -1); + void updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id = GLuint(-1)); void resetGLState(); -- cgit v1.2.3 From 155a20628b91a7a2e24264feae12f4607574cb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 7 Feb 2013 14:27:41 +0100 Subject: Use QPaintEngineEx to decide if font is too big for using the glyph cache Instead of having separate logic in the OpenGL paint engine. Change-Id: I9854328f784864e52ba1bbaafe5e1c5dda976231 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/opengl/gl2paintengineex') diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index b6da578f26..fff1834499 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -628,12 +628,8 @@ bool QGL2PaintEngineEx::isNativePaintingActive() const { bool QGL2PaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &t) const { - float det = t.determinant(); - - // Don't try to cache huge fonts or vastly transformed fonts - return t.type() < QTransform::TxProject - && QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t) - && det >= 0.25f && det <= 4.f; + // Don't try to cache vastly transformed fonts + return t.type() < QTransform::TxProject && QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); } void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) -- cgit v1.2.3 From 159f42222d06acd9a7ea9b25167e52060d47ab4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 6 Feb 2013 22:36:27 +0100 Subject: Remove duplicated code for handling OpenGL extensions in QtOpenGL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We now re-use QOpenGLExtensions/Functions from QtGui in the same way as QtGui uses these classes. There is still some duplicated logic in qglfunctions.cpp, but this code now at least uses the shared QOpenGLExtensionMatcher class. Change-Id: Ie04008c43d430ae805e6ec1c45e7e363deeb3b8f Reviewed-by: Tor Arne Vestbø --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 69 +++++++++------------- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 7 ++- .../gl2paintengineex/qtextureglyphcache_gl.cpp | 21 ++++--- .../gl2paintengineex/qtextureglyphcache_gl_p.h | 7 ++- 4 files changed, 49 insertions(+), 55 deletions(-) (limited to 'src/opengl/gl2paintengineex') diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index fff1834499..27073e80be 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -112,7 +112,7 @@ QGL2PaintEngineExPrivate::~QGL2PaintEngineExPrivate() } if (elementIndicesVBOId != 0) { - glDeleteBuffers(1, &elementIndicesVBOId); + funcs.glDeleteBuffers(1, &elementIndicesVBOId); elementIndicesVBOId = 0; } } @@ -199,7 +199,7 @@ void QGL2PaintEngineExPrivate::updateBrushTexture() // Get the image data for the pattern QImage texImage = qt_imageForBrush(style, false); - glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); + funcs.glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); ctx->d_func()->bindTexture(texImage, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, q->state()->renderHints & QPainter::SmoothPixmapTransform); } @@ -212,7 +212,7 @@ void QGL2PaintEngineExPrivate::updateBrushTexture() // for opacity to the cache. GLuint texId = QGL2GradientCache::cacheForContext(ctx)->getBuffer(*g, 1.0); - glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); + funcs.glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); glBindTexture(GL_TEXTURE_2D, texId); if (g->spread() == QGradient::RepeatSpread || g->type() == QGradient::ConicalGradient) @@ -229,7 +229,7 @@ void QGL2PaintEngineExPrivate::updateBrushTexture() if (currentBrushPixmap.width() > max_texture_size || currentBrushPixmap.height() > max_texture_size) currentBrushPixmap = currentBrushPixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); - glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); + funcs.glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); QGLTexture *tex = ctx->d_func()->bindTexture(currentBrushPixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption | QGLContext::CanFlipNativePixmapBindOption); @@ -426,9 +426,9 @@ void QGL2PaintEngineExPrivate::updateMatrix() // Set the PMV matrix attribute. As we use an attributes rather than uniforms, we only // need to do this once for every matrix change and persists across all shader programs. - glVertexAttrib3fv(QT_PMV_MATRIX_1_ATTR, pmvMatrix[0]); - glVertexAttrib3fv(QT_PMV_MATRIX_2_ATTR, pmvMatrix[1]); - glVertexAttrib3fv(QT_PMV_MATRIX_3_ATTR, pmvMatrix[2]); + funcs.glVertexAttrib3fv(QT_PMV_MATRIX_1_ATTR, pmvMatrix[0]); + funcs.glVertexAttrib3fv(QT_PMV_MATRIX_2_ATTR, pmvMatrix[1]); + funcs.glVertexAttrib3fv(QT_PMV_MATRIX_3_ATTR, pmvMatrix[2]); dasher.setInvScale(inverseScale); stroker.setInvScale(inverseScale); @@ -538,12 +538,11 @@ void QGL2PaintEngineEx::beginNativePainting() d->nativePaintingActive = true; - QGLContext *ctx = d->ctx; - glUseProgram(0); + d->funcs.glUseProgram(0); // Disable all the vertex attribute arrays: for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) - glDisableVertexAttribArray(i); + d->funcs.glDisableVertexAttribArray(i); #ifndef QT_OPENGL_ES_2 const QGLFormat &fmt = d->device->format(); @@ -572,8 +571,6 @@ void QGL2PaintEngineEx::beginNativePainting() glMatrixMode(GL_MODELVIEW); glLoadMatrixf(&mv_matrix[0][0]); } -#else - Q_UNUSED(ctx); #endif d->lastTextureUsed = GLuint(-1); @@ -588,13 +585,13 @@ void QGL2PaintEngineEx::beginNativePainting() void QGL2PaintEngineExPrivate::resetGLState() { glDisable(GL_BLEND); - glActiveTexture(GL_TEXTURE0); + funcs.glActiveTexture(GL_TEXTURE0); glDisable(GL_STENCIL_TEST); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); glDepthMask(true); glDepthFunc(GL_LESS); - glClearDepth(1); + funcs.glClearDepthf(1); glStencilMask(0xff); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilFunc(GL_ALWAYS, 0, 0xff); @@ -604,7 +601,7 @@ void QGL2PaintEngineExPrivate::resetGLState() #ifndef QT_OPENGL_ES_2 // gl_Color, corresponding to vertex attribute 3, may have been changed float color[] = { 1.0f, 1.0f, 1.0f, 1.0f }; - glVertexAttrib4fv(3, color); + funcs.glVertexAttrib4fv(3, color); #endif } @@ -733,7 +730,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) qreal scaleFactor = cache->iscale / inverseScale; if (scaleFactor < 0.5 || scaleFactor > 2.0) { #ifdef QT_OPENGL_CACHE_AS_VBOS - glDeleteBuffers(1, &cache->vbo); + funcs.glDeleteBuffers(1, &cache->vbo); cache->vbo = 0; Q_ASSERT(cache->ibo == 0); #else @@ -760,9 +757,9 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) cache->primitiveType = GL_TRIANGLE_FAN; cache->iscale = inverseScale; #ifdef QT_OPENGL_CACHE_AS_VBOS - glGenBuffers(1, &cache->vbo); - glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); - glBufferData(GL_ARRAY_BUFFER, floatSizeInBytes, vertexCoordinateArray.data(), GL_STATIC_DRAW); + funcs.glGenBuffers(1, &cache->vbo); + funcs.glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); + funcs.glBufferData(GL_ARRAY_BUFFER, floatSizeInBytes, vertexCoordinateArray.data(), GL_STATIC_DRAW); cache->ibo = 0; #else cache->vertices = (float *) malloc(floatSizeInBytes); @@ -773,7 +770,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) prepareForDraw(currentBrush.isOpaque()); #ifdef QT_OPENGL_CACHE_AS_VBOS - glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); + funcs.glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, 0); #else setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices); @@ -999,9 +996,9 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, } // Inc. for front-facing triangle - glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_INCR_WRAP, GL_INCR_WRAP); + funcs.glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_INCR_WRAP, GL_INCR_WRAP); // Dec. for back-facing "holes" - glStencilOpSeparate(GL_BACK, GL_KEEP, GL_DECR_WRAP, GL_DECR_WRAP); + funcs.glStencilOpSeparate(GL_BACK, GL_KEEP, GL_DECR_WRAP, GL_DECR_WRAP); glStencilMask(~GL_STENCIL_HIGH_BIT); drawVertexArrays(data, stops, stopCount, GL_TRIANGLE_FAN); @@ -1389,7 +1386,7 @@ void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, c bindOptions |= QGLContext::TemporarilyCachedBindOption; #endif - glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); + d->funcs.glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); QGLTexture *texture = ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, bindOptions); @@ -1431,7 +1428,7 @@ void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const ensureActive(); d->transferMode(ImageDrawingMode); - glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); + d->funcs.glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); QGLContext::BindOptions bindOptions = QGLContext::InternalBindOption; #ifdef QGL_USE_TEXTURE_POOL @@ -1491,10 +1488,7 @@ bool QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const ensureActive(); d->transferMode(ImageDrawingMode); -#ifndef QT_OPENGL_ES_2 - QGLContext *ctx = d->ctx; -#endif - glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); + d->funcs.glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); glBindTexture(GL_TEXTURE_2D, textureId); QGLRect srcRect(src.left(), src.bottom(), src.right(), src.top()); @@ -1778,7 +1772,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp glEnable(GL_BLEND); glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR); - glBlendColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); + funcs.glBlendColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); } else { // Other brush styles need two passes. @@ -1795,7 +1789,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp glEnable(GL_BLEND); glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); - glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT); + funcs.glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT); glBindTexture(GL_TEXTURE_2D, cache->texture()); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); @@ -1830,7 +1824,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp QGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QGLTextureGlyphCache::Linear:QGLTextureGlyphCache::Nearest; if (lastMaskTextureUsed != cache->texture() || cache->filterMode() != filterMode) { - glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT); + funcs.glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT); if (lastMaskTextureUsed != cache->texture()) { glBindTexture(GL_TEXTURE_2D, cache->texture()); lastMaskTextureUsed = cache->texture(); @@ -1937,7 +1931,7 @@ void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragmen allOpaque &= (opacity >= 0.99f); } - glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); + funcs.glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); QGLTexture *texture = ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption | QGLContext::CanFlipNativePixmapBindOption); @@ -2010,14 +2004,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) // go after beginPaint: d->device->beginPaint(); -#if !defined(QT_OPENGL_ES_2) - bool success = qt_resolve_version_2_0_functions(d->ctx) - && qt_resolve_buffer_extensions(d->ctx) - && (!QGLFramebufferObject::hasOpenGLFramebufferObjects() - || qt_resolve_framebufferobject_extensions(d->ctx)); - Q_ASSERT(success); - Q_UNUSED(success); -#endif + d->funcs.initializeOpenGLFunctions(); d->shaderManager = new QGLEngineShaderManager(d->ctx); @@ -2051,7 +2038,7 @@ bool QGL2PaintEngineEx::end() Q_D(QGL2PaintEngineEx); QGLContext *ctx = d->ctx; - glUseProgram(0); + d->funcs.glUseProgram(0); d->transferMode(BrushDrawingMode); d->device->endPaint(); diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 401a3824c5..b0517fd083 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -62,6 +62,7 @@ #include #include #include +#include enum EngineMode { ImageDrawingMode, @@ -256,6 +257,8 @@ public: EngineMode mode; QFontEngineGlyphCache::Type glyphCacheType; + QOpenGLExtensions funcs; + // Dirty flags bool matrixDirty; // Implies matrix uniforms are also dirty bool compositionModeDirty; @@ -317,9 +320,9 @@ void QGL2PaintEngineExPrivate::setVertexAttributePointer(unsigned int arrayIndex vertexAttribPointers[arrayIndex] = pointer; if (arrayIndex == QT_OPACITY_ATTR) - glVertexAttribPointer(arrayIndex, 1, GL_FLOAT, GL_FALSE, 0, pointer); + funcs.glVertexAttribPointer(arrayIndex, 1, GL_FLOAT, GL_FALSE, 0, pointer); else - glVertexAttribPointer(arrayIndex, 2, GL_FLOAT, GL_FALSE, 0, pointer); + funcs.glVertexAttribPointer(arrayIndex, 2, GL_FLOAT, GL_FALSE, 0, pointer); } QT_END_NAMESPACE diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 045979e7ce..59401fe1e9 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -41,6 +41,7 @@ #include "qtextureglyphcache_gl_p.h" #include "qpaintengineex_opengl2_p.h" +#include "qglfunctions.h" #include "private/qglengineshadersource_p.h" QT_BEGIN_NAMESPACE @@ -167,10 +168,12 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) return; } + QOpenGLFunctions *funcs = ctx->contextHandle()->functions(); + // ### the QTextureGlyphCache API needs to be reworked to allow // ### resizeTextureData to fail - glBindFramebuffer(GL_FRAMEBUFFER, m_textureResource->m_fbo); + funcs->glBindFramebuffer(GL_FRAMEBUFFER, m_textureResource->m_fbo); GLuint tmp_texture; glGenTextures(1, &tmp_texture); @@ -183,10 +186,10 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); m_filterMode = Nearest; glBindTexture(GL_TEXTURE_2D, 0); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, tmp_texture, 0); + funcs->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, tmp_texture, 0); - glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); + funcs->glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); glBindTexture(GL_TEXTURE_2D, oldTexture); if (pex != 0) @@ -232,8 +235,8 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) m_blitProgram->link(); } - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_vertexCoordinateArray); - glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_textureCoordinateArray); + funcs->glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_vertexCoordinateArray); + funcs->glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_textureCoordinateArray); m_blitProgram->bind(); m_blitProgram->enableAttributeArray(int(QT_VERTEX_COORDS_ATTR)); @@ -258,12 +261,12 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_RENDERBUFFER, 0); + funcs->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_RENDERBUFFER, 0); glDeleteTextures(1, &tmp_texture); glDeleteTextures(1, &oldTexture); - glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_ptr->current_fbo); + funcs->glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_ptr->current_fbo); if (pex != 0) { glViewport(0, 0, pex->width, pex->height); diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index 16a7aacf20..8f43a906c0 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -57,6 +57,7 @@ #include #include #include +#include // #define QT_GL_TEXTURE_GLYPH_CACHE_DEBUG @@ -73,7 +74,7 @@ struct QGLGlyphTexture : public QOpenGLSharedResource , m_height(0) { if (ctx && QGLFramebufferObject::hasOpenGLFramebufferObjects() && !ctx->d_ptr->workaround_brokenFBOReadBack) - glGenFramebuffers(1, &m_fbo); + ctx->contextHandle()->functions()->glGenFramebuffers(1, &m_fbo); #ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG qDebug(" -> QGLGlyphTexture() %p for context %p.", this, ctx); @@ -88,8 +89,8 @@ struct QGLGlyphTexture : public QOpenGLSharedResource #else Q_UNUSED(ctx); #endif - if (m_fbo) - glDeleteFramebuffers(1, &m_fbo); + if (ctx && m_fbo) + ctx->contextHandle()->functions()->glDeleteFramebuffers(1, &m_fbo); if (m_width || m_height) glDeleteTextures(1, &m_texture); } -- cgit v1.2.3 From b11317a64339f5a4bcffc8234ecaf15c7fb416f2 Mon Sep 17 00:00:00 2001 From: Axel Waggershauser Date: Fri, 15 Mar 2013 00:42:15 +0100 Subject: Whitespace cleanup: remove trailing whitespace Remove all trailing whitespace from the following list of files: *.cpp *.h *.conf *.qdoc *.pro *.pri *.mm *.rc *.pl *.qps *.xpm *.txt *README excluding 3rdparty, test-data and auto generated code. Note A): the only non 3rdparty c++-files that still have trailing whitespace after this change are: * src/corelib/codecs/cp949codetbl_p.h * src/corelib/codecs/qjpunicode.cpp * src/corelib/codecs/qbig5codec.cpp * src/corelib/xml/qxmlstream_p.h * src/tools/qdoc/qmlparser/qqmljsgrammar.cpp * src/tools/uic/ui4.cpp * tests/auto/other/qtokenautomaton/tokenizers/* * tests/benchmarks/corelib/tools/qstring/data.cpp * util/lexgen/tokenizer.cpp Note B): in about 30 files some overlapping 'leading tab' and 'TAB character in non-leading whitespace' issues have been fixed to make the sanity bot happy. Plus some general ws-fixes here and there as asked for during review. Change-Id: Ia713113c34d82442d6ce4d93d8b1cf545075d11d Reviewed-by: Oswald Buddenhagen --- src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/opengl/gl2paintengineex') diff --git a/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h b/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h index 44a0274da4..f1a664c93d 100644 --- a/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h +++ b/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h @@ -104,20 +104,20 @@ public: maxX(-2e10), maxY(-2e10), minX(2e10), minY(2e10), boundingRectDirty(true) { } - + inline void addRect(const QRectF &rect) { qreal top = rect.top(); qreal left = rect.left(); qreal bottom = rect.bottom(); qreal right = rect.right(); - + vertexArray << QGLPoint(left, top) << QGLPoint(right, top) << QGLPoint(right, bottom) << QGLPoint(right, bottom) << QGLPoint(left, bottom) - << QGLPoint(left, top); + << QGLPoint(left, top); } inline void addQuad(const QRectF &rect) -- cgit v1.2.3