diff options
author | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-09-05 15:31:08 +0200 |
---|---|---|
committer | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-09-06 10:11:04 +0200 |
commit | af44559780765c7121a49c2e0764cf24e740312d (patch) | |
tree | a4f2f50ddfe969f33a4d4accd392523c6809fd5a /src | |
parent | 8784a4a46ea1357bde546c9a1c88bd060e863f30 (diff) | |
parent | b30d7c9ee8fbc3a395c74b618f2ab176ae1e7f7e (diff) |
Merge branch 'stable' into dev
Conflicts:
src/qml/debugger/qv8debugservice.cpp
src/qml/qml/v8/qv8engine.cpp
tests/auto/quick/qquickitem/qquickitem.pro
Change-Id: Ic4a1dcdd8b8a84155d2f2abefdf1da5c3a56af31
Diffstat (limited to 'src')
19 files changed, 150 insertions, 110 deletions
diff --git a/src/imports/dialogs/plugin.cpp b/src/imports/dialogs/plugin.cpp index eab273ed1c..249152c48c 100644 --- a/src/imports/dialogs/plugin.cpp +++ b/src/imports/dialogs/plugin.cpp @@ -77,9 +77,8 @@ class QtQuick2DialogsPlugin : public QQmlExtensionPlugin public: QtQuick2DialogsPlugin() : QQmlExtensionPlugin() { } - virtual void initializeEngine(QQmlEngine *engine, const char *uri) { + virtual void initializeEngine(QQmlEngine *engine, const char * /*uri*/) { //qDebug() << Q_FUNC_INFO << uri << m_decorationComponentUrl; - Q_UNUSED(uri); QQuickAbstractDialog::m_decorationComponent = new QQmlComponent(engine, m_decorationComponentUrl, QQmlComponent::Asynchronous); } diff --git a/src/qml/debugger/qv8debugservice.cpp b/src/qml/debugger/qv8debugservice.cpp index eeab21d6ab..2195dad089 100644 --- a/src/qml/debugger/qv8debugservice.cpp +++ b/src/qml/debugger/qv8debugservice.cpp @@ -146,12 +146,18 @@ QV8DebugService *QV8DebugService::instance() return v8ServiceInstance(); } -void QV8DebugService::initialize(const QV8Engine *engine) +void QV8DebugService::addEngine(const QV8Engine *engine) { // just make sure that the service is properly registered v8ServiceInstance()->setEngine(engine); } +void QV8DebugService::removeEngine(const QV8Engine *engine) +{ + if (v8ServiceInstance()->d_func()->engine == engine) + v8ServiceInstance()->setEngine(0); +} + void QV8DebugService::setEngine(const QV8Engine *engine) { Q_D(QV8DebugService); diff --git a/src/qml/debugger/qv8debugservice_p.h b/src/qml/debugger/qv8debugservice_p.h index e6f05a2397..75fd69290c 100644 --- a/src/qml/debugger/qv8debugservice_p.h +++ b/src/qml/debugger/qv8debugservice_p.h @@ -75,7 +75,8 @@ public: ~QV8DebugService(); static QV8DebugService *instance(); - static void initialize(const QV8Engine *engine); + static void addEngine(const QV8Engine *engine); + static void removeEngine(const QV8Engine *engine); void debugMessageHandler(const QString &message); diff --git a/src/qml/jsapi/qjsvalueiterator.h b/src/qml/jsapi/qjsvalueiterator.h index e204558e90..9bbcc7bc3e 100644 --- a/src/qml/jsapi/qjsvalueiterator.h +++ b/src/qml/jsapi/qjsvalueiterator.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QSCRIPTVALUEITERATOR_H -#define QSCRIPTVALUEITERATOR_H +#ifndef QJSVALUEITERATOR_H +#define QJSVALUEITERATOR_H #include <QtQml/qjsvalue.h> #include <QtQml/qtqmlglobal.h> @@ -75,4 +75,4 @@ private: QT_END_NAMESPACE -#endif // QSCRIPTVALUEITERATOR_H +#endif // QJSVALUEITERATOR_H diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index ddefffe8e2..6bc9128730 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -1747,7 +1747,9 @@ bool QQmlCompiler::buildProperty(QQmlScript::Property *prop, if (d == 0 && notInRevision) { const QList<QQmlTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes(); - const QQmlTypeData::TypeReference &type = resolvedTypes.at(obj->type); + QQmlTypeData::TypeReference type; + if (obj->type != -1) + type = resolvedTypes.at(obj->type); if (type.type) { COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(elementName(obj)).arg(prop->name().toString()).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion)); } else { diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 5c59cc3383..39c3399917 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -757,7 +757,7 @@ void QQmlEnginePrivate::init() QQmlEngineDebugService::isDebuggingEnabled()) { isDebugging = true; QQmlEngineDebugService::instance()->addEngine(q); - QV8DebugService::initialize(v8engine()); + QV8DebugService::addEngine(v8engine()); QV8ProfilerService::initialize(); QQmlProfilerService::initialize(); QDebugMessageService::instance(); @@ -846,6 +846,7 @@ QQmlEngine::~QQmlEngine() Q_D(QQmlEngine); if (d->isDebugging) { QQmlEngineDebugService::instance()->remEngine(this); + QV8DebugService::removeEngine(handle()); } // Emit onDestruction signals for the root context before diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 816f9cec0f..85c6a4246a 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -161,13 +161,20 @@ QQmlType *getTypeForUrl(const QString &urlString, const QHashedStringRef& typeNa } -typedef QMap<QString, QString> StringStringMap; -Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri +struct RegisteredPlugin { + QString uri; + QPluginLoader* loader; +}; + +typedef QMap<QString, RegisteredPlugin> StringRegisteredPluginMap; +Q_GLOBAL_STATIC(StringRegisteredPluginMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri and the PluginLoaders void qmlClearEnginePlugins() { - foreach (const QString &s, qmlEnginePluginsWithRegisteredTypes()->values()) { - QPluginLoader loader(s); - loader.unload(); // ### Always returns false, worth doing? + foreach (RegisteredPlugin plugin, qmlEnginePluginsWithRegisteredTypes()->values()) { + QPluginLoader* loader = plugin.loader; + if (!loader->unload()) + qWarning("Unloading %s failed: %s", qPrintable(plugin.uri), qPrintable(loader->errorString())); + delete loader; } qmlEnginePluginsWithRegisteredTypes()->clear(); } @@ -1634,7 +1641,7 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur bool typesRegistered = qmlEnginePluginsWithRegisteredTypes()->contains(absoluteFilePath); if (typesRegistered) { - Q_ASSERT_X(qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath) == uri, + Q_ASSERT_X(qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath).uri == uri, "QQmlImportDatabase::importPlugin", "Internal error: Plugin imported previously with different uri"); } @@ -1648,25 +1655,37 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur } return false; } - QPluginLoader loader(absoluteFilePath); - if (!loader.load()) { - if (errors) { - QQmlError error; - error.setDescription(loader.errorString()); - errors->prepend(error); + QPluginLoader* loader = 0; + if (!typesRegistered) { + loader = new QPluginLoader(absoluteFilePath); + + if (!loader->load()) { + if (errors) { + QQmlError error; + error.setDescription(loader->errorString()); + errors->prepend(error); + + delete loader; + } + return false; } - return false; + } else { + loader = qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath).loader; } - QObject *instance = loader.instance(); + QObject *instance = loader->instance(); if (QQmlTypesExtensionInterface *iface = qobject_cast<QQmlExtensionInterface *>(instance)) { const QByteArray bytes = uri.toUtf8(); const char *moduleId = bytes.constData(); if (!typesRegistered) { - qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath, uri); + RegisteredPlugin plugin; + plugin.uri = uri; + plugin.loader = loader; + + qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath, plugin); QStringList registrationFailures; @@ -1734,8 +1753,11 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur } else { if (errors) { QQmlError error; - error.setDescription(loader.errorString()); + error.setDescription(loader->errorString()); errors->prepend(error); + + if (!typesRegistered) + delete loader; } return false; } diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index b6a3ae1ea5..01625756cd 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -4403,12 +4403,12 @@ void QQuickItemPrivate::deliverKeyEvent(QKeyEvent *e) extra->keyHandler->keyReleased(e, true); } - if (e->isAccepted()) + if (e->isAccepted() || !q->window()) return; //only care about KeyPress now - if ((q == q->window()->contentItem() || q->activeFocusOnTab()) - && e->type() == QEvent::KeyPress) { + if (e->type() == QEvent::KeyPress && + (q == q->window()->contentItem() || q->activeFocusOnTab())) { bool res = false; if (!(e->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier? if (e->key() == Qt::Key_Backtab diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index 6f1edc718a..04eb28343a 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -242,11 +242,6 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) void QQuickItemsModule::defineModule() { - static bool initialized = false; - if (initialized) - return; - initialized = true; - QByteArray name = "QtQuick"; int majorVersion = 2; int minorVersion = 0; diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index a8786585da..1970a03bee 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -547,6 +547,12 @@ QQuickMouseArea::QQuickMouseArea(QQuickItem *parent) { Q_D(QQuickMouseArea); d->init(); +#ifndef QT_NO_CURSOR + // Explcitly call setCursor on QQuickItem since + // it internally keeps a boolean hasCursor that doesn't + // get set to true unless you call setCursor + setCursor(Qt::ArrowCursor); +#endif } QQuickMouseArea::~QQuickMouseArea() diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp index 9debfe35b3..e48cedaf26 100644 --- a/src/quick/items/qquickshadereffectsource.cpp +++ b/src/quick/items/qquickshadereffectsource.cpp @@ -96,6 +96,10 @@ class QQuickShaderEffectSourceTextureProvider : public QSGTextureProvider public: QQuickShaderEffectSourceTextureProvider() : sourceTexture(0) + , mipmapFiltering(QSGTexture::None) + , filtering(QSGTexture::Nearest) + , horizontalWrap(QSGTexture::ClampToEdge) + , verticalWrap(QSGTexture::ClampToEdge) { } diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index 3536975e94..3c8772252c 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -168,13 +168,11 @@ void QSGDistanceFieldGlyphCache::update() qsg_render_timer.start(); #endif - QHash<glyph_t, QImage> distanceFields; - + QList<QDistanceField> distanceFields; for (int i = 0; i < m_pendingGlyphs.size(); ++i) { - glyph_t glyphIndex = m_pendingGlyphs.at(i); - - QImage distanceField = qt_renderDistanceFieldGlyph(m_referenceFont, glyphIndex, m_doubleGlyphResolution); - distanceFields.insert(glyphIndex, distanceField); + distanceFields.append(QDistanceField(m_referenceFont, + m_pendingGlyphs.at(i), + m_doubleGlyphResolution)); } #ifndef QSG_NO_RENDER_TIMING diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h index cc22bfa61f..9e173101ba 100644 --- a/src/quick/scenegraph/qsgadaptationlayer_p.h +++ b/src/quick/scenegraph/qsgadaptationlayer_p.h @@ -230,7 +230,7 @@ protected: }; virtual void requestGlyphs(const QSet<glyph_t> &glyphs) = 0; - virtual void storeGlyphs(const QHash<glyph_t, QImage> &glyphs) = 0; + virtual void storeGlyphs(const QList<QDistanceField> &glyphs) = 0; virtual void referenceGlyphs(const QSet<glyph_t> &glyphs) = 0; virtual void releaseGlyphs(const QSet<glyph_t> &glyphs) = 0; diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp index 4652a2241e..884abd3edc 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp @@ -142,13 +142,19 @@ void QSGDefaultDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyph markGlyphsToRender(glyphsToRender); } -void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage> &glyphs) +void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QList<QDistanceField> &glyphs) { QHash<TextureInfo *, QVector<glyph_t> > glyphTextures; - QHash<glyph_t, QImage>::const_iterator it; - for (it = glyphs.constBegin(); it != glyphs.constEnd(); ++it) { - glyph_t glyphIndex = it.key(); + GLint alignment = 4; // default value + glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); + + // Distance field data is always tightly packed + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + for (int i = 0; i < glyphs.size(); ++i) { + QDistanceField glyph = glyphs.at(i); + glyph_t glyphIndex = glyph.glyph(); TexCoord c = glyphTexCoord(glyphIndex); TextureInfo *texInfo = m_glyphsTexture.value(glyphIndex); @@ -157,7 +163,6 @@ void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage> glyphTextures[texInfo].append(glyphIndex); - QImage glyph = it.value(); int expectedWidth = qCeil(c.width + c.xMargin * 2); if (glyph.width() != expectedWidth) glyph = glyph.copy(0, 0, expectedWidth, glyph.height()); @@ -167,15 +172,17 @@ void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage> uchar *outBits = texInfo->image.scanLine(int(c.y)) + int(c.x); for (int y = 0; y < glyph.height(); ++y) { memcpy(outBits, inBits, glyph.width()); - inBits += glyph.bytesPerLine(); - outBits += texInfo->image.bytesPerLine(); + inBits += glyph.width(); + outBits += texInfo->image.width(); } } - for (int i = 0; i < glyph.height(); ++i) - glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, glyph.width(), 1, GL_ALPHA, GL_UNSIGNED_BYTE, glyph.scanLine(i)); + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, glyph.width(), glyph.height(), GL_ALPHA, GL_UNSIGNED_BYTE, glyph.constBits()); } + // restore to previous alignment + glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); + QHash<TextureInfo *, QVector<glyph_t> >::const_iterator i; for (i = glyphTextures.constBegin(); i != glyphTextures.constEnd(); ++i) { Texture t; @@ -198,7 +205,7 @@ void QSGDefaultDistanceFieldGlyphCache::releaseGlyphs(const QSet<glyph_t> &glyph void QSGDefaultDistanceFieldGlyphCache::createTexture(TextureInfo *texInfo, int width, int height) { if (useWorkaround() && texInfo->image.isNull()) - texInfo->image = QImage(width, height, QImage::Format_Indexed8); + texInfo->image = QDistanceField(width, height); while (glGetError() != GL_NO_ERROR) { } @@ -243,8 +250,14 @@ void QSGDefaultDistanceFieldGlyphCache::resizeTexture(TextureInfo *texInfo, int updateTexture(oldTexture, texInfo->texture, texInfo->size); if (useWorkaround()) { - for (int i = 0; i < oldHeight; ++i) - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, oldWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, texInfo->image.scanLine(i)); + GLint alignment = 4; // default value + glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, texInfo->image.constBits()); + + glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); // restore to previous value + texInfo->image = texInfo->image.copy(0, 0, width, height); glDeleteTextures(1, &oldTexture); return; diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h index ef722d85df..4ce3a50d1b 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h @@ -58,7 +58,7 @@ public: virtual ~QSGDefaultDistanceFieldGlyphCache(); void requestGlyphs(const QSet<glyph_t> &glyphs); - void storeGlyphs(const QHash<glyph_t, QImage> &glyphs); + void storeGlyphs(const QList<QDistanceField> &glyphs); void referenceGlyphs(const QSet<glyph_t> &glyphs); void releaseGlyphs(const QSet<glyph_t> &glyphs); @@ -73,7 +73,7 @@ private: GLuint texture; QSize size; QRect allocatedArea; - QImage image; + QDistanceField image; TextureInfo() : texture(0) { } diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index f5a461f19e..c62bee097b 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE class QSGTextMaskMaterialData : public QSGMaterialShader { public: - QSGTextMaskMaterialData(); + QSGTextMaskMaterialData(QFontEngineGlyphCache::Type cacheType); virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect); virtual char const *const *attributeNames() const; @@ -74,6 +74,8 @@ protected: int m_matrix_id; int m_color_id; int m_textureScale_id; + + QFontEngineGlyphCache::Type m_cacheType; }; const char *QSGTextMaskMaterialData::vertexShader() const { @@ -106,7 +108,8 @@ char const *const *QSGTextMaskMaterialData::attributeNames() const return attr; } -QSGTextMaskMaterialData::QSGTextMaskMaterialData() +QSGTextMaskMaterialData::QSGTextMaskMaterialData(QFontEngineGlyphCache::Type cacheType) + : m_cacheType(cacheType) { } @@ -126,24 +129,31 @@ static inline qreal fontSmoothingGamma() void QSGTextMaskMaterialData::activate() { QSGMaterialShader::activate(); - glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR); + + if (m_cacheType == QFontEngineGlyphCache::Raster_RGBMask) + glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR); #if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB) // 0.25 was found to be acceptable error margin by experimentation. On Mac, the gamma is 2.0, // but using sRGB looks okay. - if (qAbs(fontSmoothingGamma() - 2.2) < 0.25) + if (m_cacheType == QFontEngineGlyphCache::Raster_RGBMask + && qAbs(fontSmoothingGamma() - 2.2) < 0.25) { glEnable(GL_FRAMEBUFFER_SRGB); + } #endif } void QSGTextMaskMaterialData::deactivate() { QSGMaterialShader::deactivate(); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + if (m_cacheType == QFontEngineGlyphCache::Raster_RGBMask) + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); #if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB) - if (qAbs(fontSmoothingGamma() - 2.2) < 0.25) + if (m_cacheType == QFontEngineGlyphCache::Raster_RGBMask + && qAbs(fontSmoothingGamma() - 2.2) < 0.25) { glDisable(GL_FRAMEBUFFER_SRGB); + } #endif } @@ -213,11 +223,11 @@ void QSGTextMaskMaterialData::updateState(const RenderState &state, QSGMaterial class QSGStyledTextMaterialData : public QSGTextMaskMaterialData { public: - QSGStyledTextMaterialData() { } + QSGStyledTextMaterialData(QFontEngineGlyphCache::Type cacheType) + : QSGTextMaskMaterialData(cacheType) + { } virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect); - virtual void activate(); - virtual void deactivate(); private: virtual void initialize(); @@ -284,28 +294,6 @@ void QSGStyledTextMaterialData::updateState(const RenderState &state, program()->setUniformValue(m_matrix_id, state.combinedMatrix()); } -void QSGStyledTextMaterialData::activate() -{ - QSGMaterialShader::activate(); - -#if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB) - // 0.25 was found to be acceptable error margin by experimentation. On Mac, the gamma is 2.0, - // but using sRGB looks okay. - if (qAbs(fontSmoothingGamma() - 2.2) < 0.25) - glEnable(GL_FRAMEBUFFER_SRGB); -#endif -} - -void QSGStyledTextMaterialData::deactivate() -{ - QSGMaterialShader::deactivate(); - -#if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB) - if (qAbs(fontSmoothingGamma() - 2.2) < 0.25) - glDisable(GL_FRAMEBUFFER_SRGB); -#endif -} - const char *QSGStyledTextMaterialData::vertexShader() const { return @@ -343,7 +331,9 @@ const char *QSGStyledTextMaterialData::fragmentShader() const class QSGOutlinedTextMaterialData : public QSGStyledTextMaterialData { public: - QSGOutlinedTextMaterialData() { } + QSGOutlinedTextMaterialData(QFontEngineGlyphCache::Type cacheType) + : QSGStyledTextMaterialData(cacheType) + { } private: const char *vertexShader() const; @@ -396,20 +386,19 @@ const char *QSGOutlinedTextMaterialData::fragmentShader() const "}"; } -QSGTextMaskMaterial::QSGTextMaskMaterial(const QRawFont &font, QFontEngineGlyphCache::Type cacheType) +QSGTextMaskMaterial::QSGTextMaskMaterial(const QRawFont &font, int cacheType) : m_texture(0) - , m_cacheType(cacheType) , m_glyphCache(0) , m_font(font) { - init(); + init(cacheType); } QSGTextMaskMaterial::~QSGTextMaskMaterial() { } -void QSGTextMaskMaterial::init() +void QSGTextMaskMaterial::init(int cacheType) { Q_ASSERT(m_font.isValid()); @@ -420,9 +409,17 @@ void QSGTextMaskMaterial::init() QRawFontPrivate *fontD = QRawFontPrivate::get(m_font); if (fontD->fontEngine != 0) { - m_glyphCache = fontD->fontEngine->glyphCache(ctx, m_cacheType, QTransform()); - if (!m_glyphCache || m_glyphCache->cacheType() != m_cacheType) { - m_glyphCache = new QOpenGLTextureGlyphCache(m_cacheType, QTransform()); + if (cacheType < 0) { + cacheType = fontD->fontEngine->glyphFormat < 0 + ? QFontEngineGlyphCache::Raster_RGBMask + : fontD->fontEngine->glyphFormat; + } + m_glyphCache = fontD->fontEngine->glyphCache(ctx, + QFontEngineGlyphCache::Type(cacheType), + QTransform()); + if (!m_glyphCache || int(m_glyphCache->cacheType()) != cacheType) { + m_glyphCache = new QOpenGLTextureGlyphCache(QFontEngineGlyphCache::Type(cacheType), + QTransform()); fontD->fontEngine->setGlyphCache(ctx, m_glyphCache.data()); } } @@ -513,7 +510,7 @@ QOpenGLTextureGlyphCache *QSGTextMaskMaterial::glyphCache() const QSGMaterialShader *QSGTextMaskMaterial::createShader() const { - return new QSGTextMaskMaterialData; + return new QSGTextMaskMaterialData(glyphCache()->cacheType()); } int QSGTextMaskMaterial::compare(const QSGMaterial *o) const @@ -570,7 +567,7 @@ QSGMaterialType *QSGStyledTextMaterial::type() const QSGMaterialShader *QSGStyledTextMaterial::createShader() const { - return new QSGStyledTextMaterialData; + return new QSGStyledTextMaterialData(glyphCache()->cacheType()); } int QSGStyledTextMaterial::compare(const QSGMaterial *o) const @@ -602,7 +599,7 @@ QSGMaterialType *QSGOutlinedTextMaterial::type() const QSGMaterialShader *QSGOutlinedTextMaterial::createShader() const { - return new QSGOutlinedTextMaterialData; + return new QSGOutlinedTextMaterialData(glyphCache()->cacheType()); } QT_END_NAMESPACE diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h index d1a739de88..ddfc72a4e6 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h @@ -59,8 +59,7 @@ class Geometry; class QSGTextMaskMaterial: public QSGMaterial { public: - QSGTextMaskMaterial(const QRawFont &font, - QFontEngineGlyphCache::Type cacheType = QFontEngineGlyphCache::Raster_RGBMask); + QSGTextMaskMaterial(const QRawFont &font, int cacheType = -1); virtual ~QSGTextMaskMaterial(); virtual QSGMaterialType *type() const; @@ -84,10 +83,9 @@ public: const QMargins &margins = QMargins(0, 0, 0, 0)); private: - void init(); + void init(int cacheType); QSGPlainTexture *m_texture; - QFontEngineGlyphCache::Type m_cacheType; QExplicitlySharedDataPointer<QFontEngineGlyphCache> m_glyphCache; QRawFont m_font; QColor m_color; diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp index 97bb4295f7..c15263f53f 100644 --- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp @@ -300,7 +300,7 @@ void QSGSharedDistanceFieldGlyphCache::waitForGlyphs() } } -void QSGSharedDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage> &glyphs) +void QSGSharedDistanceFieldGlyphCache::storeGlyphs(const QList<QDistanceField> &glyphs) { { QMutexLocker locker(&m_pendingGlyphsMutex); @@ -312,14 +312,12 @@ void QSGSharedDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage> int glyphCount = glyphs.size(); QVector<quint32> glyphIds(glyphCount); QVector<QImage> images(glyphCount); - QHash<glyph_t, QImage>::const_iterator it = glyphs.constBegin(); - int i=0; - while (it != glyphs.constEnd()) { - m_requestedGlyphsThatHaveNotBeenReturned.insert(it.key()); - glyphIds[i] = it.key(); - images[i] = it.value(); - - ++it; ++i; + for (int i = 0; i < glyphs.size(); ++i) { + const QDistanceField &df = glyphs.at(i); + m_requestedGlyphsThatHaveNotBeenReturned.insert(df.glyph()); + glyphIds[i] = df.glyph(); + // ### TODO: Handle QDistanceField in QPlatformSharedGraphicsCache + images[i] = df.toImage(QImage::Format_Indexed8); } m_hasPostedEvents = true; diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h index 3ca5485be3..7587d948ad 100644 --- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h +++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h @@ -65,7 +65,7 @@ public: void requestGlyphs(const QSet<glyph_t> &glyphs); void referenceGlyphs(const QSet<glyph_t> &glyphs); - void storeGlyphs(const QHash<glyph_t, QImage> &glyphs); + void storeGlyphs(const QList<QDistanceField> &glyphs); void releaseGlyphs(const QSet<glyph_t> &glyphs); Q_SIGNALS: |