diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-07-01 19:19:56 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-01 13:49:46 +0200 |
commit | 78923902089d0a70c096e5f47f42e24fbcd4fa56 (patch) | |
tree | cdf04742cba0cf0ae956129e80996f9eef51c070 /src/quick/scenegraph/qsgcontext.cpp | |
parent | 6e70fa5ee8d0433dbb0d42378bce10db18b05fab (diff) |
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 <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/quick/scenegraph/qsgcontext.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgcontext.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
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); |