summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2020-01-21 15:21:00 +0100
committerJohan Klokkhammer Helsing <johan.helsing@qt.io>2020-02-03 22:05:44 +0100
commita13e8d6660913bec172d1374f78083498c539df0 (patch)
treeb1a2572fb71a9a896825e2cbbf9653abd9797d0d /src/plugins/platforms
parentc6e1b54f94e84950ee12c3bb2be0641f5742056b (diff)
Move backing store OpenGL support to the platformcompositor module
QPlatformBackingStore had a dependency on the QOpenGLTextureBlitter, which is a problem because we want to get rid of all the public QOpenGL* classes in the gui module. This splits the heavily QOpenGL dependent parts of the backing store implementation into a separate class and moves it to the platformcompositor module. qplatformbackingstore.cpp is now mostly free from OpenGL implementation details. Platform integrations now have to explicitly request backing store OpenGL support. This has been done for: - xcb - windows - cocoa - winrt - android - wasm - ios QPlatformGraphicsBufferHelper::lockAndBindToTexture is now exported so it can be used from other modules. Task-number: QTBUG-74409 Change-Id: I42ad9250e5a424939cf751a8ad880c7381ede2ae Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/android/android.pro2
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.cpp10
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm14
-rw-r--r--src/plugins/platforms/ios/kernel.pro2
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm10
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.cpp2
-rw-r--r--src/plugins/platforms/wasm/wasm.pro2
-rw-r--r--src/plugins/platforms/windows/qwindowsgdiintegration.cpp10
-rw-r--r--src/plugins/platforms/windows/windows.pro2
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.cpp9
-rw-r--r--src/plugins/platforms/winrt/winrt.pro2
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp24
-rw-r--r--src/plugins/platforms/xcb/xcb_qpa_lib.pro3
14 files changed, 81 insertions, 13 deletions
diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro
index 61cac51633..8ea78f7cba 100644
--- a/src/plugins/platforms/android/android.pro
+++ b/src/plugins/platforms/android/android.pro
@@ -9,6 +9,8 @@ QT += \
qtConfig(vulkan): QT += vulkan_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
OTHER_FILES += $$PWD/android.json
INCLUDEPATH += \
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp
index e0c437be27..ae584965e6 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp
@@ -43,6 +43,9 @@
#include <QtGui/private/qguiapplication_p.h>
#include <QGuiApplication>
#include <QOpenGLContext>
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
#include <QThread>
#include <QOffscreenSurface>
@@ -275,7 +278,12 @@ QPlatformBackingStore *QAndroidPlatformIntegration::createPlatformBackingStore(Q
{
if (!QtAndroid::activity())
return nullptr;
- return new QAndroidPlatformBackingStore(window);
+
+ auto *backingStore = new QAndroidPlatformBackingStore(window);
+#if QT_CONFIG(opengl)
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif // QT_CONFIG(opengl)
+ return backingStore;
}
QPlatformOpenGLContext *QAndroidPlatformIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index a919963cf4..953346c56e 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -101,6 +101,8 @@ QT += \
qtConfig(vulkan): QT += vulkan_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
CONFIG += no_app_extension_api_only
qtHaveModule(widgets) {
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index a77b97f538..b2698b05fe 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -68,6 +68,10 @@
#include <QtFontDatabaseSupport/private/qfontengine_coretext_p.h>
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
+
#ifdef QT_WIDGETS_LIB
#include <QtWidgets/qtwidgetsglobal.h>
#if QT_CONFIG(filedialog)
@@ -324,10 +328,16 @@ QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *wi
return nullptr;
}
+ QPlatformBackingStore *backingStore = nullptr;
if (platformWindow->view().layer)
- return new QCALayerBackingStore(window);
+ backingStore = new QCALayerBackingStore(window);
else
- return new QNSWindowBackingStore(window);
+ backingStore = new QNSWindowBackingStore(window);
+
+#if QT_CONFIG(opengl)
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif
+ return backingStore;
}
QAbstractEventDispatcher *QCocoaIntegration::createEventDispatcher() const
diff --git a/src/plugins/platforms/ios/kernel.pro b/src/plugins/platforms/ios/kernel.pro
index 71257d09f7..01e0105223 100644
--- a/src/plugins/platforms/ios/kernel.pro
+++ b/src/plugins/platforms/ios/kernel.pro
@@ -9,6 +9,8 @@ QT += \
core-private gui-private \
clipboard_support-private fontdatabase_support-private graphics_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AudioToolbox
OBJECTIVE_SOURCES = \
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 9eca0eaad3..d724e65717 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -65,6 +65,10 @@
#import <AudioToolbox/AudioServices.h>
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
+
#include <QtDebug>
QT_BEGIN_NAMESPACE
@@ -186,7 +190,11 @@ QPlatformWindow *QIOSIntegration::createPlatformWindow(QWindow *window) const
// Used when the QWindow's surface type is set by the client to QSurface::RasterSurface
QPlatformBackingStore *QIOSIntegration::createPlatformBackingStore(QWindow *window) const
{
- return new QIOSBackingStore(window);
+ auto *backingStore = new QIOSBackingStore(window);
+#if QT_CONFIG(opengl)
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif
+ return backingStore;
}
// Used when the QWindow's surface type is set by the client to QSurface::OpenGLSurface
diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp
index fd53cd0bae..ce83ad4e2f 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.cpp
+++ b/src/plugins/platforms/wasm/qwasmintegration.cpp
@@ -41,6 +41,7 @@
#include "qwasmwindow.h"
#ifndef QT_NO_OPENGL
# include "qwasmbackingstore.h"
+# include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
#endif
#include "qwasmfontdatabase.h"
#if defined(Q_OS_UNIX)
@@ -185,6 +186,7 @@ QPlatformBackingStore *QWasmIntegration::createPlatformBackingStore(QWindow *win
#ifndef QT_NO_OPENGL
QWasmCompositor *compositor = QWasmScreen::get(window->screen())->compositor();
QWasmBackingStore *backingStore = new QWasmBackingStore(compositor, window);
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
m_backingStores.insert(window, backingStore);
return backingStore;
#else
diff --git a/src/plugins/platforms/wasm/wasm.pro b/src/plugins/platforms/wasm/wasm.pro
index c8b28fb37d..1aee4a3e58 100644
--- a/src/plugins/platforms/wasm/wasm.pro
+++ b/src/plugins/platforms/wasm/wasm.pro
@@ -4,6 +4,8 @@ QT += \
core-private gui-private \
eventdispatcher_support-private fontdatabase_support-private egl_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
diff --git a/src/plugins/platforms/windows/qwindowsgdiintegration.cpp b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp
index c88f669eb5..7e9595321a 100644
--- a/src/plugins/platforms/windows/qwindowsgdiintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp
@@ -45,6 +45,10 @@
#include <QtCore/qdebug.h>
#include <QtGui/private/qpixmap_raster_p.h>
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
+
QT_BEGIN_NAMESPACE
class QWindowsGdiIntegrationPrivate
@@ -73,7 +77,11 @@ QPlatformPixmap *QWindowsGdiIntegration::createPlatformPixmap(QPlatformPixmap::P
QPlatformBackingStore *QWindowsGdiIntegration::createPlatformBackingStore(QWindow *window) const
{
- return new QWindowsBackingStore(window);
+ auto *backingStore = new QWindowsBackingStore(window);
+#ifndef QT_NO_OPENGL
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif
+ return backingStore;
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro
index 50a3bb41a9..8a27bd2770 100644
--- a/src/plugins/platforms/windows/windows.pro
+++ b/src/plugins/platforms/windows/windows.pro
@@ -5,6 +5,8 @@ QT += \
eventdispatcher_support-private \
fontdatabase_support-private theme_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
qtConfig(accessibility): QT += accessibility_support-private
qtConfig(vulkan): QT += vulkan_support-private
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp
index 27d3746933..dd8cd80fd9 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.cpp
+++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp
@@ -53,6 +53,9 @@
#if QT_CONFIG(accessibility)
# include "uiautomation/qwinrtuiaaccessibility.h"
#endif
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
#include <QtGui/QOffscreenSurface>
#include <QtGui/QOpenGLContext>
@@ -205,7 +208,11 @@ QPlatformWindow *QWinRTIntegration::createPlatformWindow(QWindow *window) const
QPlatformBackingStore *QWinRTIntegration::createPlatformBackingStore(QWindow *window) const
{
- return new QWinRTBackingStore(window);
+ auto *backingStore = new QWinRTBackingStore(window);
+#if QT_CONFIG(opengl)
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif
+ return backingStore;
}
QPlatformOpenGLContext *QWinRTIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro
index 43dc8f074c..7ac49f73c4 100644
--- a/src/plugins/platforms/winrt/winrt.pro
+++ b/src/plugins/platforms/winrt/winrt.pro
@@ -6,6 +6,8 @@ QT += \
core-private gui-private \
fontdatabase_support-private egl_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
DEFINES *= QT_NO_CAST_FROM_ASCII __WRL_NO_DEFAULT_LIB__
QMAKE_USE_PRIVATE += d3d11 ws2_32
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 3fd989e1f9..cea0511822 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -61,6 +61,9 @@
#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
#include <QtServiceSupport/private/qgenericunixservices_p.h>
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
#include <stdio.h>
@@ -288,16 +291,23 @@ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLCont
QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *window) const
{
- const bool isTrayIconWindow = QXcbWindow::isTrayIconWindow(window);
- if (isTrayIconWindow)
- return new QXcbSystemTrayBackingStore(window);
+ QPlatformBackingStore *backingStore = nullptr;
+ const bool isTrayIconWindow = QXcbWindow::isTrayIconWindow(window);
+ if (isTrayIconWindow) {
+ backingStore = new QXcbSystemTrayBackingStore(window);
#if QT_CONFIG(xcb_native_painting)
- if (nativePaintingEnabled())
- return new QXcbNativeBackingStore(window);
+ } else if (nativePaintingEnabled()) {
+ backingStore = new QXcbNativeBackingStore(window);
#endif
-
- return new QXcbBackingStore(window);
+ } else {
+ backingStore = new QXcbBackingStore(window);
+ }
+ Q_ASSERT(backingStore);
+#ifndef QT_NO_OPENGL
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif
+ return backingStore;
}
QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
index a5d05faa9c..1f651e7697 100644
--- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro
+++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
@@ -9,6 +9,9 @@ QT += \
edid_support-private \
xkbcommon_support-private
+qtHaveModule(platformcompositor_support-private): \
+ QT += platformcompositor_support-private
+
qtHaveModule(linuxaccessibility_support-private): \
QT += linuxaccessibility_support-private