From f7971d37cbc7e2f25d0fac382f33f3c270c10598 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Fri, 28 Mar 2014 15:38:34 +0100 Subject: Add a way to share context between QtQuick and QtWidgets This will replace QSGContext::setSharedOpenGLContext. To be able to allow sharing the Chromium GL context with both QWebEngineView and QQuickWebEngineView, we need some way of setting the sharing within QtWidgets and QtQuick. Since they don't depend on one another this patch allows the sharing context to be set through QtGui. Change-Id: I91b365dd06ec925b4c5a99ac82c222778781fe8e Reviewed-by: Laszlo Agocs --- src/gui/kernel/qopenglcontext.cpp | 20 ++++++++++++++++++++ src/gui/kernel/qopenglcontext_p.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index e258218e85..55fe036fe0 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -230,6 +230,7 @@ public: }; static QThreadStorage qwindow_context_storage; +static QOpenGLContext *global_share_context = 0; #ifndef QT_NO_DEBUG QHash QOpenGLContextPrivate::makeCurrentTracker; @@ -330,6 +331,25 @@ QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context return previous; } +/*! + \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. +*/ +void QOpenGLContextPrivate::setGlobalShareContext(QOpenGLContext *context) +{ + global_share_context = context; +} + +/*! + \internal +*/ +QOpenGLContext *QOpenGLContextPrivate::globalShareContext() +{ + return global_share_context; +} + int QOpenGLContextPrivate::maxTextureSize() { if (max_texture_size != -1) diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 23c13b2e24..b21ff67068 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -244,6 +244,9 @@ public: static QOpenGLContext *setCurrentContext(QOpenGLContext *context); + static void setGlobalShareContext(QOpenGLContext *context); + static QOpenGLContext *globalShareContext(); + int maxTextureSize(); static QOpenGLContextPrivate *get(QOpenGLContext *context) -- cgit v1.2.3