summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qopenglwindow.cpp29
-rw-r--r--src/gui/kernel/qopenglwindow.h2
2 files changed, 28 insertions, 3 deletions
diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp
index c37974c429..c58e296b5a 100644
--- a/src/gui/kernel/qopenglwindow.cpp
+++ b/src/gui/kernel/qopenglwindow.cpp
@@ -166,10 +166,13 @@ class QOpenGLWindowPrivate : public QPaintDeviceWindowPrivate
{
Q_DECLARE_PUBLIC(QOpenGLWindow)
public:
- QOpenGLWindowPrivate(QOpenGLWindow::UpdateBehavior updateBehavior)
+ QOpenGLWindowPrivate(QOpenGLContext *shareContext, QOpenGLWindow::UpdateBehavior updateBehavior)
: updateBehavior(updateBehavior)
, hasFboBlit(false)
+ , shareContext(shareContext)
{
+ if (!shareContext)
+ this->shareContext = qt_gl_global_share_context();
}
~QOpenGLWindowPrivate()
@@ -201,7 +204,7 @@ public:
if (!context) {
context.reset(new QOpenGLContext);
- context->setShareContext(qt_gl_global_share_context());
+ context->setShareContext(shareContext);
context->setFormat(q->requestedFormat());
if (!context->create())
qWarning("QOpenGLWindow::beginPaint: Failed to create context");
@@ -299,6 +302,7 @@ public:
QOpenGLWindow::UpdateBehavior updateBehavior;
bool hasFboBlit;
QScopedPointer<QOpenGLContext> context;
+ QOpenGLContext *shareContext;
QScopedPointer<QOpenGLFramebufferObject> fbo;
QScopedPointer<QOpenGLWindowPaintDevice> paintDevice;
QOpenGLTextureBlitter blitter;
@@ -317,12 +321,22 @@ void QOpenGLWindowPaintDevice::ensureActiveTarget()
\sa QOpenGLWindow::UpdateBehavior
*/
QOpenGLWindow::QOpenGLWindow(QOpenGLWindow::UpdateBehavior updateBehavior, QWindow *parent)
- : QPaintDeviceWindow(*(new QOpenGLWindowPrivate(updateBehavior)), parent)
+ : QPaintDeviceWindow(*(new QOpenGLWindowPrivate(Q_NULLPTR, updateBehavior)), parent)
{
setSurfaceType(QSurface::OpenGLSurface);
}
/*!
+ Constructs a new QOpenGLWindow with the given \a parent and \a updateBehavior. The QOpenGLWindow's context will share with \a shareContext.
+
+ \sa QOpenGLWindow::UpdateBehavior shareContext
+*/
+QOpenGLWindow::QOpenGLWindow(QOpenGLContext *shareContext, UpdateBehavior updateBehavior, QWindow *parent)
+ : QPaintDeviceWindow(*(new QOpenGLWindowPrivate(shareContext, updateBehavior)), parent)
+{
+ setSurfaceType(QSurface::OpenGLSurface);
+}
+/*!
\return the update behavior for this QOpenGLWindow.
*/
QOpenGLWindow::UpdateBehavior QOpenGLWindow::updateBehavior() const
@@ -414,6 +428,15 @@ QOpenGLContext *QOpenGLWindow::context() const
}
/*!
+ \return The QOpenGLContext requested to be shared with this window's QOpenGLContext.
+*/
+QOpenGLContext *QOpenGLWindow::shareContext() const
+{
+ Q_D(const QOpenGLWindow);
+ return d->shareContext;
+}
+
+/*!
The framebuffer object handle used by this window.
When the update behavior is set to \c NoPartialUpdate, there is no separate
diff --git a/src/gui/kernel/qopenglwindow.h b/src/gui/kernel/qopenglwindow.h
index 3b0b399b0a..6b64271b7b 100644
--- a/src/gui/kernel/qopenglwindow.h
+++ b/src/gui/kernel/qopenglwindow.h
@@ -59,6 +59,7 @@ public:
};
explicit QOpenGLWindow(UpdateBehavior updateBehavior = NoPartialUpdate, QWindow *parent = 0);
+ explicit QOpenGLWindow(QOpenGLContext *shareContext, UpdateBehavior updateBehavior = NoPartialUpdate, QWindow *parent = 0);
UpdateBehavior updateBehavior() const;
bool isValid() const;
@@ -67,6 +68,7 @@ public:
void doneCurrent();
QOpenGLContext *context() const;
+ QOpenGLContext *shareContext() const;
GLuint defaultFramebufferObject() const;