summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qoffscreensurface.cpp
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2020-08-25 11:32:58 +0300
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2020-08-27 23:35:16 +0300
commitfc4a73aa544bf03d881ddb7e2eb8ebd47d7da7b8 (patch)
tree6e0a334fa3b9535541d546ecffc890cbb4307a6a /src/gui/kernel/qoffscreensurface.cpp
parent15db957585828af7a83896963fade95c3ddcc7e3 (diff)
Add QOffScreenSurface platform API abstraction
This follows the work done in 6ff79478a44fce12ca18832a56db4a370a9ff417. The API is available by including qoffscreensurface.h, scoped in the QPlatformInterface namespace. The namespace exposes platform specific type-safe interfaces that provide: a) Factory functions for adopting native contexts, e.g. QAndroidPlatformOffscreenSurface::fromNative(ANativeWindow); b) Access to underlying native handles, e.g. surface->platformInterface<QAndroidPlatformOffscreenSurface>() ->nativeSurface() Fixes: QTBUG-85874 Change-Id: I29c459866e0355a52320d5d473e8b147e050acb3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/kernel/qoffscreensurface.cpp')
-rw-r--r--src/gui/kernel/qoffscreensurface.cpp81
1 files changed, 14 insertions, 67 deletions
diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp
index fbd5c6a079..9875911d30 100644
--- a/src/gui/kernel/qoffscreensurface.cpp
+++ b/src/gui/kernel/qoffscreensurface.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -42,7 +42,7 @@
#include "qguiapplication_p.h"
#include "qscreen.h"
#include "qplatformintegration.h"
-#include "qplatformoffscreensurface.h"
+#include "qoffscreensurface_p.h"
#include "qwindow.h"
#include "qplatformwindow.h"
@@ -50,6 +50,18 @@
QT_BEGIN_NAMESPACE
+
+/*!
+ \fn T QOffScreenSurface::platformInterface<T>()
+
+ Returns a platform interface of type T for the surface.
+
+ This function provides access to platform specific functionality
+ of QOffScreenSurface, as defined in the QPlatformInterface namespace.
+
+ If the requested interface is not available a \nullptr is returned.
+*/
+
/*!
\class QOffscreenSurface
\inmodule QtGui
@@ -91,36 +103,6 @@ QT_BEGIN_NAMESPACE
native surface. For the use cases of QOffscreenSurface (rendering to FBOs, texture
upload) this is not a problem.
*/
-class Q_GUI_EXPORT QOffscreenSurfacePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QOffscreenSurface)
-
-public:
- QOffscreenSurfacePrivate()
- : QObjectPrivate()
- , surfaceType(QSurface::OpenGLSurface)
- , platformOffscreenSurface(nullptr)
- , offscreenWindow(nullptr)
- , requestedFormat(QSurfaceFormat::defaultFormat())
- , screen(nullptr)
- , size(1, 1)
- , nativeHandle(nullptr)
- {
- }
-
- ~QOffscreenSurfacePrivate()
- {
- }
-
- QSurface::SurfaceType surfaceType;
- QPlatformOffscreenSurface *platformOffscreenSurface;
- QWindow *offscreenWindow;
- QSurfaceFormat requestedFormat;
- QScreen *screen;
- QSize size;
- void *nativeHandle;
-};
-
/*!
\since 5.10
@@ -228,8 +210,6 @@ void QOffscreenSurface::destroy()
delete d->offscreenWindow;
d->offscreenWindow = nullptr;
}
-
- d->nativeHandle = nullptr;
}
/*!
@@ -344,26 +324,6 @@ void QOffscreenSurface::setScreen(QScreen *newScreen)
}
/*!
- Sets the native handle to which the offscreen surface is connected to \a handle.
-
- The native handle will be resolved in the create() function. Calling
- this function after create() will not re-create a native surface.
-
- \note The interpretation of the native handle is platform specific. Only
- some platforms will support adopting native handles of offscreen surfaces
- and platforms that do not implement this support will ignore the handle.
-
- \since 5.9
- \sa nativeHandle()
-*/
-
-void QOffscreenSurface::setNativeHandle(void *handle)
-{
- Q_D(QOffscreenSurface);
- d->nativeHandle = handle;
-}
-
-/*!
Called when the offscreen surface's screen is destroyed.
\internal
@@ -395,19 +355,6 @@ QPlatformOffscreenSurface *QOffscreenSurface::handle() const
}
/*!
- Returns an optional native handle to which the offscreen surface is connected.
-
- \since 5.9
- \sa setNativeHandle()
-*/
-
-void *QOffscreenSurface::nativeHandle() const
-{
- Q_D(const QOffscreenSurface);
- return d->nativeHandle;
-}
-
-/*!
Returns the platform surface corresponding to the offscreen surface.
\internal