diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-06-08 20:00:36 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-02 10:27:50 +0200 |
commit | 6ff79478a44fce12ca18832a56db4a370a9ff417 (patch) | |
tree | 2bcd7ab7bac46fe28e0828e0a704649bbc025e8f /src/plugins/platforms/offscreen | |
parent | 037dce81fc27ec241edb6829f6df41927b80666e (diff) |
Introduce platform API abstraction for QOpenGLContext
The API is available by including qopenglcontext.h as usual,
but scoped in the QPlatformInterface namespace. The namespace
exposes platform specific type-safe interfaces that provide:
a) Factory functions for adopting native contexts, e.g.
QCocoaGLContext::fromNative(nsContext, shareContext);
b) Access to underlying native handles, e.g.
openGLContext->platformInterface<QCocoaGLContext>->nativeContext()
c) Platform specific functionality, e.g.
static QWGLContext::openGLModuleHandle()
openGLContext->platformInterface<QEGLContext>->doSomething();
The platform interfaces live close to the classes they extend,
removing the need for complex indirection and plumbing, and
avoids kitchen-sink modules and APIs such as the extras modules,
QPlatformFunctions, or QPlatformNativeInterface.
In the case of QOpenGLContext these platform APIs are backed
by the platform plugin, so dynamic_cast is used to ensure the
platform plugin supports the requested interface, but this is
and implementation detail. The interface APIs are agnostic
to where the implementation lives, while still being available
to the user as part of the APIs they extend/augment.
The documentation will be restored when the dust settles.
Task-number: QTBUG-80233
Change-Id: Iac612403383991c4b24064332542a6e4bcbb3293
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/plugins/platforms/offscreen')
-rw-r--r-- | src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp | 6 | ||||
-rw-r--r-- | src/plugins/platforms/offscreen/qoffscreenintegration_x11.h | 5 |
2 files changed, 5 insertions, 6 deletions
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp index 84991d751f..53ec3e80c2 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp @@ -41,7 +41,6 @@ #include <QByteArray> #include <QOpenGLContext> -#include <QtPlatformHeaders/QGLXNativeContext> #include <X11/Xlib.h> #include <GL/glx.h> @@ -241,9 +240,6 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL d->window = createDummyWindow(x11, visualInfo); XFree(visualInfo); } - if (d->context) - context->setNativeHandle(QVariant::fromValue<QGLXNativeContext>(QGLXNativeContext(d->context))); - } QOffscreenX11GLXContext::~QOffscreenX11GLXContext() @@ -296,7 +292,7 @@ bool QOffscreenX11GLXContext::isValid() const return d->context && d->window; } -void *QOffscreenX11GLXContext::glxContext() const +GLXContext QOffscreenX11GLXContext::glxContext() const { return d->context; } diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h index 5ef51a15a8..005ac26151 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h +++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h @@ -90,6 +90,7 @@ private: class QOffscreenX11GLXContextData; class QOffscreenX11GLXContext : public QPlatformOpenGLContext + , public QPlatformInterface::QGLXContext { public: QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGLContext *context); @@ -104,8 +105,10 @@ public: bool isSharing() const override; bool isValid() const override; + GLXContext nativeContext() const override { return glxContext(); } + void *glxConfig() const; - void *glxContext() const; + GLXContext glxContext() const; private: QScopedPointer<QOffscreenX11GLXContextData> d; |