From fc4a73aa544bf03d881ddb7e2eb8ebd47d7da7b8 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Tue, 25 Aug 2020 11:32:58 +0300 Subject: Add QOffScreenSurface platform API abstraction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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() ->nativeSurface() Fixes: QTBUG-85874 Change-Id: I29c459866e0355a52320d5d473e8b147e050acb3 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qoffscreensurface.cpp | 81 +++++++----------------------------- 1 file changed, 14 insertions(+), 67 deletions(-) (limited to 'src/gui/kernel/qoffscreensurface.cpp') 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() + + 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; } /*! @@ -343,26 +323,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. @@ -394,19 +354,6 @@ QPlatformOffscreenSurface *QOffscreenSurface::handle() const return d->platformOffscreenSurface; } -/*! - 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. -- cgit v1.2.3