aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-10-30 14:32:54 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-01 12:00:18 +0100
commit5b05a78d0055757adb3b2703ea990e07dbcd145a (patch)
tree07860d9a612dcfcab15fd5d851f69538f08215b4 /src
parent2192e5005b3ba3cff22388a4907e01c7c514d812 (diff)
Added private API for enabling sharing between the QQuickwindow instances.
This API is primarily a hook which is needed by the Qt WebEngine to set up sharing with the scene graph's OpenGL contexts. Change-Id: I5bb03abd9ab99f502db8e413fe838a8b30365b8d Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp18
-rw-r--r--src/quick/scenegraph/qsgcontext_p.h3
-rw-r--r--src/quick/scenegraph/qsgrenderloop.cpp2
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp2
-rw-r--r--src/quick/scenegraph/qsgwindowsrenderloop.cpp2
5 files changed, 27 insertions, 0 deletions
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 4fbefb37d8..c6dbf350b6 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -117,8 +117,12 @@ public:
QSGContext::AntialiasingMethod antialiasingMethod;
bool distanceFieldDisabled;
QSGDistanceFieldGlyphNode::AntialiasingMode distanceFieldAntialiasing;
+
+ static QOpenGLContext *sharedOpenGLContext;
};
+QOpenGLContext *QSGContextPrivate::sharedOpenGLContext = 0;
+
class QSGTextureCleanupEvent : public QEvent
{
public:
@@ -170,6 +174,20 @@ QSGContext::~QSGContext()
{
}
+/*!
+ * This function is used by the Qt WebEngine to set up context sharing
+ * across multiple windows. Do not use it for any other purpose.
+ */
+void QSGContext::setSharedOpenGLContext(QOpenGLContext *context)
+{
+ QSGContextPrivate::sharedOpenGLContext = context;
+}
+
+QOpenGLContext *QSGContext::sharedOpenGLContext()
+{
+ return QSGContextPrivate::sharedOpenGLContext;
+}
+
void QSGContext::renderContextInitialized(QSGRenderContext *renderContext)
{
Q_D(QSGContext);
diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h
index 08fafb0713..270f108373 100644
--- a/src/quick/scenegraph/qsgcontext_p.h
+++ b/src/quick/scenegraph/qsgcontext_p.h
@@ -162,6 +162,9 @@ public:
virtual QSize minimumFBOSize() const;
virtual QSurfaceFormat defaultSurfaceFormat() const;
+ static void setSharedOpenGLContext(QOpenGLContext *context);
+ static QOpenGLContext *sharedOpenGLContext();
+
void setDistanceFieldEnabled(bool enabled);
bool isDistanceFieldEnabled() const;
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index fc1e98d87f..f294cb4a2d 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -264,6 +264,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
if (!gl) {
gl = new QOpenGLContext();
gl->setFormat(window->requestedFormat());
+ if (QSGContext::sharedOpenGLContext())
+ gl->setShareContext(QSGContext::sharedOpenGLContext());
if (!gl->create()) {
delete gl;
gl = 0;
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index bb0bd67d6b..42c7c9c0ba 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -889,6 +889,8 @@ void QSGThreadedRenderLoop::handleExposure(Window *w)
if (!w->thread->gl) {
w->thread->gl = new QOpenGLContext();
+ if (QSGContext::sharedOpenGLContext())
+ w->thread->gl->setShareContext(QSGContext::sharedOpenGLContext());
w->thread->gl->setFormat(w->window->requestedFormat());
if (!w->thread->gl->create()) {
delete w->thread->gl;
diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
index f1d09c3785..d5d12bd138 100644
--- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp
+++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
@@ -178,6 +178,8 @@ void QSGWindowsRenderLoop::show(QQuickWindow *window)
RLDEBUG(" - creating GL context");
m_gl = new QOpenGLContext();
m_gl->setFormat(window->requestedFormat());
+ if (QSGContext::sharedOpenGLContext())
+ m_gl->setShareContext(QSGContext::sharedOpenGLContext());
m_gl->create();
QSG_RENDER_TIMING_SAMPLE(time_created);
RLDEBUG(" - making current");