From 9e3c46961a5f48c3a704b0147e1f073f7516da9c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 3 Jan 2019 08:09:55 +0100 Subject: Remove reference to OpenGL from distance field cache superclass QSGDefaultDistanceFieldGlyphCache is the OpenGL-specific implementation, but for some reason the core profile flag was stored in the superclass. It is ever only used from QSGDefaultDistanceFieldGlyphCache and the rest of the superclass has no OpenGL-dependency, so we just move it. This is needed to be able to share the generic QSGDistanceFieldGlyphCache with Qt 3D Runtime, where there is no current OpenGL context when the scene graph is built and resources have to be allocated through an abstraction layer in Qt 3D. Task-number: QT3DS-1419 Change-Id: I7f4e26eecc21635ff81030b32ecc89c6dc4fcfbe Reviewed-by: Laszlo Agocs --- src/particles/qquickcustomparticle.cpp | 1 + src/quick/scenegraph/qsgadaptationlayer.cpp | 7 +------ src/quick/scenegraph/qsgadaptationlayer_p.h | 9 +-------- src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp | 4 +++- src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h | 2 ++ 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/particles/qquickcustomparticle.cpp b/src/particles/qquickcustomparticle.cpp index 8528a6f750..85056dffa9 100644 --- a/src/particles/qquickcustomparticle.cpp +++ b/src/particles/qquickcustomparticle.cpp @@ -39,6 +39,7 @@ #include "qquickcustomparticle_p.h" #include +#include #include #include #include diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index c99e149aa5..252e5a9c55 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -56,7 +56,7 @@ static QElapsedTimer qsg_render_timer; QSGDistanceFieldGlyphCache::Texture QSGDistanceFieldGlyphCache::s_emptyTexture; -QSGDistanceFieldGlyphCache::QSGDistanceFieldGlyphCache(QOpenGLContext *c, const QRawFont &font) +QSGDistanceFieldGlyphCache::QSGDistanceFieldGlyphCache(const QRawFont &font) : m_pendingGlyphs(64) { Q_ASSERT(font.isValid()); @@ -71,11 +71,6 @@ QSGDistanceFieldGlyphCache::QSGDistanceFieldGlyphCache(QOpenGLContext *c, const // this allows us to call pathForGlyph once and reuse the result. m_referenceFont.setPixelSize(QT_DISTANCEFIELD_BASEFONTSIZE(m_doubleGlyphResolution) * QT_DISTANCEFIELD_SCALE(m_doubleGlyphResolution)); Q_ASSERT(m_referenceFont.isValid()); -#if QT_CONFIG(opengl) - m_coreProfile = (c->format().profile() == QSurfaceFormat::CoreProfile); -#else - Q_UNUSED(c) -#endif } QSGDistanceFieldGlyphCache::~QSGDistanceFieldGlyphCache() diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h index ba5c4353b2..58ecae94e7 100644 --- a/src/quick/scenegraph/qsgadaptationlayer_p.h +++ b/src/quick/scenegraph/qsgadaptationlayer_p.h @@ -62,7 +62,6 @@ #include #include #include -#include #include #include @@ -75,7 +74,6 @@ class QSGNode; class QImage; class TextureReference; class QSGDistanceFieldGlyphNode; -class QOpenGLContext; class QSGInternalImageNode; class QSGPainterNode; class QSGInternalRectangleNode; @@ -413,7 +411,7 @@ typedef QIntrusiveList m_textures; QHash m_glyphsData; QDataBuffer m_pendingGlyphs; diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp index ccc57b0b86..8121b4559e 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp @@ -67,7 +67,7 @@ DEFINE_BOOL_CONFIG_OPTION(qsgPreferFullSizeGlyphCacheTextures, QSG_PREFER_FULLSI QSGDefaultDistanceFieldGlyphCache::QSGDefaultDistanceFieldGlyphCache(QOpenGLContext *c, const QRawFont &font) - : QSGDistanceFieldGlyphCache(c, font) + : QSGDistanceFieldGlyphCache(font) , m_maxTextureSize(0) , m_maxTextureCount(3) , m_areaAllocator(nullptr) @@ -89,6 +89,8 @@ QSGDefaultDistanceFieldGlyphCache::QSGDefaultDistanceFieldGlyphCache(QOpenGLCont qWarning("Buffer creation failed"); } + m_coreProfile = (c->format().profile() == QSurfaceFormat::CoreProfile); + // Load a pregenerated cache if the font contains one loadPregeneratedCache(font); } diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h index a0e4387af9..c64adddd91 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h @@ -88,6 +88,7 @@ public: private: bool loadPregeneratedCache(const QRawFont &font); + inline bool isCoreProfile() const { return m_coreProfile; } struct TextureInfo { GLuint texture; @@ -137,6 +138,7 @@ private: mutable int m_maxTextureSize; int m_maxTextureCount; + bool m_coreProfile; QList m_textures; QHash m_glyphsTexture; -- cgit v1.2.3