diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2020-06-08 17:14:01 +0200 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2020-06-10 05:16:33 +0000 |
commit | a9124d0a0e25e06352df1339461e41cb4ae7b8db (patch) | |
tree | 848fb3c6423202cf62077b802aa64479f4bf4dc2 | |
parent | 86b6187438dc7894a9d8dd55bdd412cfb4cc079d (diff) |
Remove OpenGL dependency from QSGTextMaskMaterial & friends
Task-number: QTBUG-84623
Change-Id: Ia665b789bbc875c26672abd7e0f8b0d9fe45d22b
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r-- | src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 49 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgdefaultglyphnode_p_p.h | 1 |
2 files changed, 7 insertions, 43 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index 8c66dc348f..71830cce7b 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -40,13 +40,9 @@ #include "qsgdefaultglyphnode_p_p.h" #include <private/qsgmaterialshader_p.h> -#include <qopenglshaderprogram.h> -#include <qopenglframebufferobject.h> - #include <QtGui/private/qguiapplication_p.h> #include <qpa/qplatformintegration.h> #include <private/qfontengine_p.h> -#include <private/qopenglextensions_p.h> #include <QtQuick/qquickwindow.h> #include <QtQuick/private/qsgtexture_p.h> @@ -90,21 +86,6 @@ static inline qreal fontSmoothingGamma() return fontSmoothingGamma; } -static inline qreal qsg_device_pixel_ratio(QOpenGLContext *ctx) -{ - qreal devicePixelRatio = 1; - if (ctx->surface()->surfaceClass() == QSurface::Window) { - QWindow *w = static_cast<QWindow *>(ctx->surface()); - if (QQuickWindow *qw = qobject_cast<QQuickWindow *>(w)) - devicePixelRatio = qw->effectiveDevicePixelRatio(); - else - devicePixelRatio = w->devicePixelRatio(); - } else { - devicePixelRatio = ctx->screen() ? ctx->screen()->devicePixelRatio() : qGuiApp->devicePixelRatio(); - } - return devicePixelRatio; -} - class QSGTextMaskRhiShader : public QSGMaterialShader { public: @@ -445,21 +426,14 @@ void QSGTextMaskMaterial::updateCache(QFontEngine::GlyphFormat glyphFormat) : QFontEngine::Format_A32; } - QOpenGLContext *ctx = nullptr; qreal devicePixelRatio; void *cacheKey; - if (m_rhi) { - cacheKey = m_rhi; - // Get the dpr the modern way. This value retrieved via the - // rendercontext matches what RenderState::devicePixelRatio() - // exposes to the material shaders later on. - devicePixelRatio = m_rc->currentDevicePixelRatio(); - } else { - ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); - Q_ASSERT(ctx != nullptr); - cacheKey = ctx; - devicePixelRatio = qsg_device_pixel_ratio(ctx); // this is technically incorrect, see other branch above - } + Q_ASSERT(m_rhi); + cacheKey = m_rhi; + // Get the dpr the modern way. This value retrieved via the + // rendercontext matches what RenderState::devicePixelRatio() + // exposes to the material shaders later on. + devicePixelRatio = m_rc->currentDevicePixelRatio(); QTransform glyphCacheTransform = QTransform::fromScale(devicePixelRatio, devicePixelRatio); if (!fontEngine->supportsTransformation(glyphCacheTransform)) @@ -468,11 +442,7 @@ void QSGTextMaskMaterial::updateCache(QFontEngine::GlyphFormat glyphFormat) 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); - else - m_glyphCache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform, color); - + m_glyphCache = new QSGRhiTextureGlyphCache(m_rhi, glyphFormat, glyphCacheTransform, color); fontEngine->setGlyphCache(cacheKey, m_glyphCache.data()); m_rc->registerFontengineForCleanup(fontEngine); } @@ -589,11 +559,6 @@ QTextureGlyphCache *QSGTextMaskMaterial::glyphCache() const return static_cast<QTextureGlyphCache *>(m_glyphCache.data()); } -QOpenGLTextureGlyphCache *QSGTextMaskMaterial::openglGlyphCache() const -{ - return static_cast<QOpenGLTextureGlyphCache *>(glyphCache()); -} - QSGRhiTextureGlyphCache *QSGTextMaskMaterial::rhiGlyphCache() const { return static_cast<QSGRhiTextureGlyphCache *>(glyphCache()); diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h index 4ddef9af24..697ccd6baa 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h @@ -88,7 +88,6 @@ public: bool ensureUpToDate(); QTextureGlyphCache *glyphCache() const; - QOpenGLTextureGlyphCache *openglGlyphCache() const; QSGRhiTextureGlyphCache *rhiGlyphCache() const; void populate(const QPointF &position, |