diff options
author | Liang Qi <liang.qi@qt.io> | 2019-07-26 14:35:05 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-07-26 17:05:34 +0200 |
commit | d526a72c44cf3ed8d53c8d2b1c08dc5e7f1afe61 (patch) | |
tree | 63095d57f307bb9b90ab90e5dde98ae23e539c46 /src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | |
parent | cbe445dd915760d81a467b5285bacd208e44e365 (diff) | |
parent | aeec2f94c376c9a0e84bbbb3be4652384c7da113 (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
src/quick/handlers/qquickpointerdevicehandler.cpp
src/quick/scenegraph/qsgdefaultglyphnode.cpp
src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
tests/auto/qml/qjsengine/tst_qjsengine.cpp
Done-With: Jan Arve Sæther <jan-arve.saether@qt.io>
Done-With: Laszlo Agocs <laszlo.agocs@qt.io>
Change-Id: I35749152f8dce44b9af8d52b1283629879010f11
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultglyphnode_p.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index 8ce469b39b..5a66f1dfef 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -687,11 +687,12 @@ public: // ***** common material stuff -QSGTextMaskMaterial::QSGTextMaskMaterial(QSGRenderContext *rc, const QRawFont &font, QFontEngine::GlyphFormat glyphFormat) +QSGTextMaskMaterial::QSGTextMaskMaterial(QSGRenderContext *rc, const QVector4D &color, const QRawFont &font, QFontEngine::GlyphFormat glyphFormat) : m_rc(qobject_cast<QSGDefaultRenderContext *>(rc)) , m_texture(nullptr) , m_glyphCache(nullptr) , m_font(font) + , m_color(color) { init(glyphFormat); } @@ -701,6 +702,19 @@ QSGTextMaskMaterial::~QSGTextMaskMaterial() delete m_texture; } +void QSGTextMaskMaterial::setColor(const QVector4D &color) +{ + if (m_color == color) + return; + + m_color = color; + + // If it is an RGB cache, then the pen color is actually part of the cache key + // so it has to be updated + if (m_glyphCache != nullptr && m_glyphCache->glyphFormat() == QFontEngine::Format_ARGB) + updateCache(QFontEngine::Format_ARGB); +} + void QSGTextMaskMaterial::init(QFontEngine::GlyphFormat glyphFormat) { Q_ASSERT(m_font.isValid()); @@ -711,6 +725,11 @@ void QSGTextMaskMaterial::init(QFontEngine::GlyphFormat glyphFormat) Q_ASSERT(m_rc); m_rhi = m_rc->rhi(); + updateCache(glyphFormat); +} + +void QSGTextMaskMaterial::updateCache(QFontEngine::GlyphFormat glyphFormat) +{ // The following piece of code will read/write to the font engine's caches, // potentially from different threads. However, this is safe because this // code is only called from QQuickItem::updatePaintNode() which is called @@ -745,13 +764,13 @@ void QSGTextMaskMaterial::init(QFontEngine::GlyphFormat glyphFormat) if (!fontEngine->supportsTransformation(glyphCacheTransform)) glyphCacheTransform = QTransform(); - m_glyphCache = fontEngine->glyphCache(cacheKey, glyphFormat, glyphCacheTransform); - + //QColor color = glyphFormat == QFontEngine::Format_ARGB ? QColor::fromRgbF(m_color.x(), m_color.y(), m_color.z(), m_color.w()) : QColor(); + m_glyphCache = fontEngine->glyphCache(cacheKey, glyphFormat, glyphCacheTransform); // ### restore color arg when merges are done if (!m_glyphCache || int(m_glyphCache->glyphFormat()) != glyphFormat) { if (m_rhi) - m_glyphCache = new QSGRhiTextureGlyphCache(m_rhi, glyphFormat, glyphCacheTransform); + m_glyphCache = new QSGRhiTextureGlyphCache(m_rhi, glyphFormat, glyphCacheTransform); // ### color else - m_glyphCache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform); + m_glyphCache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform); // ### restore color arg when merges are done fontEngine->setGlyphCache(cacheKey, m_glyphCache.data()); m_rc->registerFontengineForCleanup(fontEngine); @@ -963,7 +982,7 @@ bool QSGTextMaskMaterial::ensureUpToDate() QSGStyledTextMaterial::QSGStyledTextMaterial(QSGRenderContext *rc, const QRawFont &font) - : QSGTextMaskMaterial(rc, font, QFontEngine::Format_A8) + : QSGTextMaskMaterial(rc, QVector4D(), font, QFontEngine::Format_A8) { } |