summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidplatformoffscreensurface.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/plugins/platforms/android/qandroidplatformoffscreensurface.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/plugins/platforms/android/qandroidplatformoffscreensurface.cpp')
-rw-r--r--src/plugins/platforms/android/qandroidplatformoffscreensurface.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformoffscreensurface.cpp b/src/plugins/platforms/android/qandroidplatformoffscreensurface.cpp
index f9589cea1a..9255ef4446 100644
--- a/src/plugins/platforms/android/qandroidplatformoffscreensurface.cpp
+++ b/src/plugins/platforms/android/qandroidplatformoffscreensurface.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 plugins of the Qt Toolkit.
@@ -39,28 +39,23 @@
#include "qandroidplatformoffscreensurface.h"
-#include <QtGui/QOffscreenSurface>
#include <QtGui/private/qeglconvenience_p.h>
-#include <android/native_window.h>
-
QT_BEGIN_NAMESPACE
-QAndroidPlatformOffscreenSurface::QAndroidPlatformOffscreenSurface(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface)
- : QPlatformOffscreenSurface(offscreenSurface)
- , m_format(format)
- , m_display(display)
- , m_surface(EGL_NO_SURFACE)
+QAndroidPlatformOffscreenSurface::QAndroidPlatformOffscreenSurface(
+ ANativeWindow *nativeSurface, EGLDisplay display, QOffscreenSurface *offscreenSurface)
+ : QPlatformOffscreenSurface(offscreenSurface), m_display(display), m_surface(EGL_NO_SURFACE)
{
- // Get native handle
- ANativeWindow *surfaceTexture = (ANativeWindow*)offscreenSurface->nativeHandle();
+ // FIXME: Read surface format properties from native surface using ANativeWindow_getFormat
+ m_format.setAlphaBufferSize(8);
+ m_format.setRedBufferSize(8);
+ m_format.setGreenBufferSize(8);
+ m_format.setBlueBufferSize(8);
- EGLConfig config = q_configFromGLFormat(m_display, m_format, false);
- if (config) {
- const EGLint attributes[] = {
- EGL_NONE
- };
- m_surface = eglCreateWindowSurface(m_display, config, surfaceTexture, attributes);
+ if (EGLConfig config = q_configFromGLFormat(m_display, m_format, false)) {
+ const EGLint attributes[] = { EGL_NONE };
+ m_surface = eglCreateWindowSurface(m_display, config, nativeSurface, attributes);
}
}