diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2011-11-24 13:48:19 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-24 13:03:03 +0100 |
commit | 47a5c708bf4e555cb8febef583f32c99f7d8ea1e (patch) | |
tree | 722842be890fe711a353759b100ac50bef9c2648 /src/quick/scenegraph/qsgcontext.cpp | |
parent | 635d0a7cf6601b2e46e0eed21a648934bc471c6d (diff) |
Add support for shared glyph cache
Use a shared graphics cache to back the distance fields if
it is available.
Change-Id: Id5e6e7a28e38e349d787e66016b2d0faebc791d7
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'src/quick/scenegraph/qsgcontext.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgcontext.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index cc879612ae..834f336394 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -47,6 +47,8 @@ #include <QtQuick/private/qsgdefaultimagenode_p.h> #include <QtQuick/private/qsgdefaultglyphnode_p.h> #include <QtQuick/private/qsgdistancefieldglyphnode_p.h> +#include <QtQuick/private/qsgshareddistancefieldglyphcache_p.h> + #include <QtQuick/private/qsgtexture_p.h> #include <QtQuick/private/qdeclarativepixmapcache_p.h> @@ -56,6 +58,11 @@ #include <QDeclarativeImageProvider> #include <private/qdeclarativeglobal_p.h> +#include <QtQuick/private/qsgtexture_p.h> +#include <QtGui/private/qguiapplication_p.h> + +#include <QtGui/qplatformsharedgraphicscache_qpa.h> + #include <private/qobject_p.h> #include <qmutex.h> @@ -247,6 +254,35 @@ QSGImageNode *QSGContext::createImageNode() QSGDistanceFieldGlyphCache *QSGContext::createDistanceFieldGlyphCache(const QRawFont &font) { Q_D(QSGContext); + + QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); + if (platformIntegration != 0 + && platformIntegration->hasCapability(QPlatformIntegration::SharedGraphicsCache)) { + QFontEngine *fe = QRawFontPrivate::get(font)->fontEngine; + if (!fe->faceId().filename.isEmpty()) { + QByteArray keyName = fe->faceId().filename; + if (font.style() != QFont::StyleNormal) + keyName += QByteArray(" I"); + if (font.weight() != QFont::Normal) + keyName += " " + QByteArray::number(font.weight()); + keyName += QByteArray(" DF"); + QPlatformSharedGraphicsCache *sharedGraphicsCache = + platformIntegration->createPlatformSharedGraphicsCache(keyName); + + if (sharedGraphicsCache != 0) { + sharedGraphicsCache->ensureCacheInitialized(keyName, + QPlatformSharedGraphicsCache::OpenGLTexture, + QPlatformSharedGraphicsCache::Alpha8); + + return new QSGSharedDistanceFieldGlyphCache(keyName, + sharedGraphicsCache, + d->distanceFieldCacheManager, + glContext(), + font); + } + } + } + return new QSGDefaultDistanceFieldGlyphCache(d->distanceFieldCacheManager, glContext(), font); } |