diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2020-08-25 11:32:58 +0300 |
---|---|---|
committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2020-08-27 23:35:16 +0300 |
commit | fc4a73aa544bf03d881ddb7e2eb8ebd47d7da7b8 (patch) | |
tree | 6e0a334fa3b9535541d546ecffc890cbb4307a6a /src/gui/kernel/qplatformoffscreensurface.h | |
parent | 15db957585828af7a83896963fade95c3ddcc7e3 (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/qplatformoffscreensurface.h')
-rw-r--r-- | src/gui/kernel/qplatformoffscreensurface.h | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/gui/kernel/qplatformoffscreensurface.h b/src/gui/kernel/qplatformoffscreensurface.h index cef0fab7e1..1d06336956 100644 --- a/src/gui/kernel/qplatformoffscreensurface.h +++ b/src/gui/kernel/qplatformoffscreensurface.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 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. @@ -49,8 +49,9 @@ // source and binary incompatible with future versions of Qt. // -#include <QtGui/qtguiglobal.h> #include "qplatformsurface.h" + +#include <QtGui/qoffscreensurface.h> #include <QtCore/qscopedpointer.h> QT_BEGIN_NAMESPACE @@ -75,10 +76,30 @@ public: protected: QScopedPointer<QPlatformOffscreenSurfacePrivate> d_ptr; + friend class QOffscreenSurfacePrivate; private: Q_DISABLE_COPY(QPlatformOffscreenSurface) }; +template <typename T> +T *QOffscreenSurface::platformInterface() const +{ + return dynamic_cast<T*>(surfaceHandle()); +} + +namespace QPlatformInterface::Private { + +#if defined(Q_OS_ANDROID) +struct Q_GUI_EXPORT QAndroidOffScreenIntegration +{ + QT_DECLARE_PLATFORM_INTERFACE(QAndroidOffScreenIntegration) + virtual QOffscreenSurface *createOffscreenSurface(ANativeWindow *nativeSurface) const = 0; +}; +#endif + +} // QPlatformInterface::Private + + QT_END_NAMESPACE #endif // QPLATFORMOFFSCREENSURFACE_H |