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/platform/android/android.pri | 1 + .../platform/android/qandroidplatforminterface.cpp | 61 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/gui/platform/android/android.pri create mode 100644 src/gui/platform/android/qandroidplatforminterface.cpp (limited to 'src/gui/platform/android') diff --git a/src/gui/platform/android/android.pri b/src/gui/platform/android/android.pri new file mode 100644 index 0000000000..bdaa4b1279 --- /dev/null +++ b/src/gui/platform/android/android.pri @@ -0,0 +1 @@ +SOURCES += $$PWD/qandroidplatforminterface.cpp diff --git a/src/gui/platform/android/qandroidplatforminterface.cpp b/src/gui/platform/android/qandroidplatforminterface.cpp new file mode 100644 index 0000000000..a3c4a5028d --- /dev/null +++ b/src/gui/platform/android/qandroidplatforminterface.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +using namespace QPlatformInterface::Private; + +#if defined(Q_OS_ANDROID) +QT_DEFINE_PLATFORM_INTERFACE(QAndroidPlatformOffscreenSurface, QOffscreenSurface); +QT_DEFINE_PRIVATE_PLATFORM_INTERFACE(QAndroidOffScreenIntegration); + +QOffscreenSurface *QPlatformInterface::QAndroidPlatformOffscreenSurface::fromNative(ANativeWindow *nativeSurface) +{ + return QGuiApplicationPrivate::platformIntegration()->call< + &QAndroidOffScreenIntegration::createOffscreenSurface>(nativeSurface); +} +#endif + +QT_END_NAMESPACE -- cgit v1.2.3