summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-09-09 10:06:45 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-09-10 13:36:27 +0200
commit2f96fb1beec5251e27381c09d0ad810c6e829c37 (patch)
tree4e7cd85d7e1175657a0d91c1e0076ef156b71c68 /src/gui/kernel
parent162010441f876788428aaacf9a00312d3175d150 (diff)
Add an option to share between TLWs
Task-number: QTBUG-41191 Change-Id: I510d1631926ed0d9e371703d22229aed92432aa6 Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qguiapplication.cpp22
-rw-r--r--src/gui/kernel/qguiapplication_p.h2
-rw-r--r--src/gui/kernel/qopenglcontext.cpp5
3 files changed, 26 insertions, 3 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 2d7900b5d9..75311616a4 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -82,6 +82,7 @@
#include <qpa/qwindowsysteminterface_p.h>
#include "private/qwindow_p.h"
#include "private/qcursor_p.h"
+#include "private/qopenglcontext_p.h"
#include "private/qdnd_p.h"
#include <qpa/qplatformthemefactory_p.h>
@@ -604,7 +605,8 @@ QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags
: QCoreApplicationPrivate(argc, argv, flags),
styleHints(0),
inputMethod(0),
- lastTouchType(QEvent::TouchEnd)
+ lastTouchType(QEvent::TouchEnd),
+ ownGlobalShareContext(false)
{
self = this;
application_type = QCoreApplicationPrivate::Gui;
@@ -1313,6 +1315,17 @@ void QGuiApplicationPrivate::init()
// trigger registering of animation interpolators
qRegisterGuiGetInterpolator();
+ // set a global share context when enabled unless there is already one
+#ifndef QT_NO_OPENGL
+ if (qApp->testAttribute(Qt::AA_ShareOpenGLContexts) && !qt_gl_global_share_context()) {
+ QOpenGLContext *ctx = new QOpenGLContext;
+ ctx->setFormat(QSurfaceFormat::defaultFormat());
+ ctx->create();
+ qt_gl_set_global_share_context(ctx);
+ ownGlobalShareContext = true;
+ }
+#endif
+
QWindowSystemInterfacePrivate::eventTime.start();
is_app_running = true;
@@ -1374,6 +1387,13 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate()
QPixmapCache::clear();
+#ifndef QT_NO_OPENGL
+ if (ownGlobalShareContext) {
+ delete qt_gl_global_share_context();
+ qt_gl_set_global_share_context(0);
+ }
+#endif
+
delete platform_theme;
platform_theme = 0;
delete platform_integration;
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 5f9f6ad9f2..0fd4458083 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -307,6 +307,8 @@ private:
static QTouchDevice *m_fakeTouchDevice;
static int m_fakeMouseSourcePointId;
QAtomicPointer<QDrawHelperGammaTables> m_gammaTables;
+
+ bool ownGlobalShareContext;
};
Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k);
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 6b2bb092b1..be8fa2415d 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -245,8 +245,9 @@ QMutex QOpenGLContextPrivate::makeCurrentTrackerMutex;
/*!
\internal
- This function is used by the Qt WebEngine to set up context sharing
- across multiple windows. Do not use it for any other purpose.
+ This function is used by Qt::AA_ShareOpenGLContexts and the Qt
+ WebEngine to set up context sharing across multiple windows. Do
+ not use it for any other purpose.
Please maintain the binary compatibility of these functions.
*/