Re-enable colors with both gl and rhi glyph caches

Follow up to the 5.13->dev merge where the lack of the qt5 submodule
update made it impossible to use the new color argument.

Also implements the color argument for the rhi variant of the glyph
cache.

Change-Id: Ie6c6ba3d647335eb6173d0c9f7fbe3a4ed6b1f24
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2019-07-29 09:50:09 +02:00
parent 3cff8b2718
commit 1d9645576e
3 changed files with 9 additions and 7 deletions

View File

@ -764,13 +764,13 @@ void QSGTextMaskMaterial::updateCache(QFontEngine::GlyphFormat glyphFormat)
if (!fontEngine->supportsTransformation(glyphCacheTransform))
glyphCacheTransform = QTransform();
//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
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, color);
if (!m_glyphCache || int(m_glyphCache->glyphFormat()) != glyphFormat) {
if (m_rhi)
m_glyphCache = new QSGRhiTextureGlyphCache(m_rhi, glyphFormat, glyphCacheTransform); // ### color
m_glyphCache = new QSGRhiTextureGlyphCache(m_rhi, glyphFormat, glyphCacheTransform, color);
else
m_glyphCache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform); // ### restore color arg when merges are done
m_glyphCache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform, color);
fontEngine->setGlyphCache(cacheKey, m_glyphCache.data());
m_rc->registerFontengineForCleanup(fontEngine);

View File

@ -43,8 +43,9 @@
QT_BEGIN_NAMESPACE
QSGRhiTextureGlyphCache::QSGRhiTextureGlyphCache(QRhi *rhi, QFontEngine::GlyphFormat format, const QTransform &matrix)
: QImageTextureGlyphCache(format, matrix),
QSGRhiTextureGlyphCache::QSGRhiTextureGlyphCache(QRhi *rhi, QFontEngine::GlyphFormat format, const QTransform &matrix,
const QColor &color)
: QImageTextureGlyphCache(format, matrix, color),
m_rhi(rhi)
{
// Some OpenGL implementations, for instance macOS, have issues with

View File

@ -59,7 +59,8 @@ QT_BEGIN_NAMESPACE
class QSGRhiTextureGlyphCache : public QImageTextureGlyphCache
{
public:
QSGRhiTextureGlyphCache(QRhi *rhi, QFontEngine::GlyphFormat format, const QTransform &matrix);
QSGRhiTextureGlyphCache(QRhi *rhi, QFontEngine::GlyphFormat format, const QTransform &matrix,
const QColor &color = QColor());
~QSGRhiTextureGlyphCache();
void createTextureData(int width, int height) override;