From 78923902089d0a70c096e5f47f42e24fbcd4fa56 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 1 Jul 2014 19:19:56 +0200 Subject: Expose the scene graph publically through a QSGEngine class This change wraps QSGRenderContext and QSGContext in a new QSGEngine class, and expose a public interface of QSGRenderer through a QSGAbstractRenderer to make it usable on a standalone window or FBO. Change-Id: I2d41187472424f5ea64650a006bcd61f2711f6b9 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/qsgcontext.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/quick/scenegraph/qsgcontext.cpp') diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index 1a3565b630..5bc91992e9 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -363,6 +363,7 @@ QSGRenderContext::QSGRenderContext(QSGContext *context) , m_distanceFieldCacheManager(0) , m_brokenIBOs(false) , m_serializedRender(false) + , m_attachToGLContext(true) { } @@ -384,12 +385,7 @@ void QSGRenderContext::renderNextFrame(QSGRenderer *renderer, GLuint fboId) if (m_serializedRender) qsg_framerender_mutex.lock(); - if (fboId) { - QSGBindableFboId bindable(fboId); - renderer->renderScene(bindable); - } else { - renderer->renderScene(); - } + renderer->renderScene(fboId); if (m_serializedRender) qsg_framerender_mutex.unlock(); @@ -441,6 +437,12 @@ QSGDistanceFieldGlyphCache *QSGRenderContext::distanceFieldGlyphCache(const QRaw return cache; } +void QSGRenderContext::setAttachToGLContext(bool attach) +{ + Q_ASSERT(!isValid()); + m_attachToGLContext = attach; +} + #define QSG_RENDERCONTEXT_PROPERTY "_q_sgrendercontext" QSGRenderContext *QSGRenderContext::from(QOpenGLContext *context) @@ -473,7 +475,10 @@ void QSGRenderContext::initialize(QOpenGLContext *context) Q_ASSERT_X(!m_gl, "QSGRenderContext::initialize", "already initialized!"); m_gl = context; - m_gl->setProperty(QSG_RENDERCONTEXT_PROPERTY, QVariant::fromValue(this)); + if (m_attachToGLContext) { + Q_ASSERT(!context->property(QSG_RENDERCONTEXT_PROPERTY).isValid()); + context->setProperty(QSG_RENDERCONTEXT_PROPERTY, QVariant::fromValue(this)); + } m_sg->renderContextInitialized(this); #ifdef Q_OS_LINUX @@ -541,7 +546,8 @@ void QSGRenderContext::invalidate() delete m_distanceFieldCacheManager; m_distanceFieldCacheManager = 0; - m_gl->setProperty(QSG_RENDERCONTEXT_PROPERTY, QVariant()); + if (m_gl->property(QSG_RENDERCONTEXT_PROPERTY) == QVariant::fromValue(this)) + m_gl->setProperty(QSG_RENDERCONTEXT_PROPERTY, QVariant()); m_gl = 0; m_sg->renderContextInvalidated(this); -- cgit v1.2.3