summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/painting/qplatformbackingstore.cpp38
-rw-r--r--src/gui/painting/qplatformbackingstore.h15
-rw-r--r--src/opengl/qplatformbackingstoreopenglsupport.cpp12
-rw-r--r--src/opengl/qplatformbackingstoreopenglsupport.h2
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.cpp6
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm7
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm6
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.cpp1
-rw-r--r--src/plugins/platforms/windows/qwindowsgdiintegration.cpp6
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp3
12 files changed, 53 insertions, 51 deletions
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index e8ac494e04..743c183475 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -190,16 +190,13 @@ void QPlatformTextureList::clear()
Flushes the given \a region from the specified \a window onto the
screen, and composes it with the specified \a textures.
- If OpenGLSupport has been enabled using \c setOpenGLSupport,
- the default implementation retrieves the contents using toTexture()
+ The default implementation retrieves the contents using toTexture()
and composes using OpenGL. May be reimplemented in subclasses if there
is a more efficient native way to do it.
\note \a region is relative to the window which may not be top-level in case
\a window corresponds to a native child widget. \a offset is the position of
the native child relative to the top-level window.
-
- \sa setOpenGLSupport()
*/
void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &region,
@@ -238,8 +235,7 @@ QImage QPlatformBackingStore::toImage() const
The ownership of the texture is not transferred. The caller must not store
the return value between calls, but instead call this function before each use.
- If OpenGLSupport has been enabled using \c setOpenGLSupport,
- the default implementation returns a cached texture if \a dirtyRegion is empty and
+ The default implementation returns a cached texture if \a dirtyRegion is empty and
\a textureSize matches the backingstore size, otherwise it retrieves the content using
toImage() and performs a texture upload. This works only if the value of \a textureSize
is preserved between the calls to this function.
@@ -255,8 +251,6 @@ QImage QPlatformBackingStore::toImage() const
flags will be set to include \c TextureFlip.
\note \a dirtyRegion is relative to the backingstore so no adjustment is needed.
-
- \sa setOpenGLSupport()
*/
GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const
{
@@ -281,6 +275,12 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu
QPlatformBackingStore::QPlatformBackingStore(QWindow *window)
: d_ptr(new QPlatformBackingStorePrivate(window))
{
+#ifndef QT_NO_OPENGL
+ if (auto createOpenGLSupport = QPlatformBackingStoreOpenGLSupportBase::factoryFunction()) {
+ d_ptr->openGLSupport = createOpenGLSupport();
+ d_ptr->openGLSupport->backingStore = this;
+ }
+#endif
}
/*!
@@ -318,15 +318,27 @@ QBackingStore *QPlatformBackingStore::backingStore() const
}
#ifndef QT_NO_OPENGL
+
+using FactoryFunction = QPlatformBackingStoreOpenGLSupportBase::FactoryFunction;
+
/*!
- Injects an OpenGL implementation helper. Platform integrations need to
- call this if they intend to use the default OpenGL implementations of
- composeAndFlush or toTexture.
+ Registers a factory function for OpenGL implementation helper.
+
+ The QtOpenGL library automatically registers a default function,
+ unless already set by the platform plugin in other ways.
*/
-void QPlatformBackingStore::setOpenGLSupport(QPlatformBackingStoreOpenGLSupportBase *openGLSupport)
+void QPlatformBackingStoreOpenGLSupportBase::setFactoryFunction(FactoryFunction function)
+{
+ s_factoryFunction = function;
+}
+
+FactoryFunction QPlatformBackingStoreOpenGLSupportBase::factoryFunction()
{
- d_ptr->openGLSupport = openGLSupport;
+ return s_factoryFunction;
}
+
+FactoryFunction QPlatformBackingStoreOpenGLSupportBase::s_factoryFunction = nullptr;
+
#endif // QT_NO_OPENGL
/*!
diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h
index 2a3d7d20b5..e0fdca2f21 100644
--- a/src/gui/painting/qplatformbackingstore.h
+++ b/src/gui/painting/qplatformbackingstore.h
@@ -117,8 +117,6 @@ public:
QWindow *window() const;
QBackingStore *backingStore() const;
- void setOpenGLSupport(QPlatformBackingStoreOpenGLSupportBase *openGLSupport);
-
virtual QPaintDevice *paintDevice() = 0;
virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset) = 0;
@@ -155,13 +153,24 @@ private:
};
#ifndef QT_NO_OPENGL
-class Q_GUI_EXPORT QPlatformBackingStoreOpenGLSupportBase // pure interface
+class Q_GUI_EXPORT QPlatformBackingStoreOpenGLSupportBase
{
public:
virtual void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
QPlatformTextureList *textures, bool translucentBackground) = 0;
virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, QPlatformBackingStore::TextureFlags *flags) const = 0;
virtual ~QPlatformBackingStoreOpenGLSupportBase() {}
+
+ using FactoryFunction = QPlatformBackingStoreOpenGLSupportBase *(*)();
+ static void setFactoryFunction(FactoryFunction);
+ static FactoryFunction factoryFunction();
+
+protected:
+ QPlatformBackingStore *backingStore = nullptr;
+ friend class QPlatformBackingStore;
+
+private:
+ static FactoryFunction s_factoryFunction;
};
#endif // QT_NO_OPENGL
diff --git a/src/opengl/qplatformbackingstoreopenglsupport.cpp b/src/opengl/qplatformbackingstoreopenglsupport.cpp
index 511d85a400..a188d25db5 100644
--- a/src/opengl/qplatformbackingstoreopenglsupport.cpp
+++ b/src/opengl/qplatformbackingstoreopenglsupport.cpp
@@ -450,6 +450,18 @@ GLuint QPlatformBackingStoreOpenGLSupport::toTexture(const QRegion &dirtyRegion,
return textureId;
}
+static QPlatformBackingStoreOpenGLSupportBase *createOpenGLSupport()
+{
+ return new QPlatformBackingStoreOpenGLSupport;
+}
+
+static void setDefaultOpenGLSupportFactoryFunction()
+{
+ if (!QPlatformBackingStoreOpenGLSupportBase::factoryFunction())
+ QPlatformBackingStoreOpenGLSupportBase::setFactoryFunction(createOpenGLSupport);
+}
+Q_CONSTRUCTOR_FUNCTION(setDefaultOpenGLSupportFactoryFunction);
+
#endif // QT_NO_OPENGL
QT_END_NAMESPACE
diff --git a/src/opengl/qplatformbackingstoreopenglsupport.h b/src/opengl/qplatformbackingstoreopenglsupport.h
index 8868703deb..4821f7300f 100644
--- a/src/opengl/qplatformbackingstoreopenglsupport.h
+++ b/src/opengl/qplatformbackingstoreopenglsupport.h
@@ -64,14 +64,12 @@ class QOpenGLBackingStore;
class Q_OPENGL_EXPORT QPlatformBackingStoreOpenGLSupport : public QPlatformBackingStoreOpenGLSupportBase
{
public:
- explicit QPlatformBackingStoreOpenGLSupport(QPlatformBackingStore *backingStore) : backingStore(backingStore) {}
~QPlatformBackingStoreOpenGLSupport() override;
void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
QPlatformTextureList *textures, bool translucentBackground) override;
GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, QPlatformBackingStore::TextureFlags *flags) const override;
private:
- QPlatformBackingStore *backingStore = nullptr;
QScopedPointer<QOpenGLContext> context;
mutable GLuint textureId = 0;
mutable QSize textureSize;
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp
index aa57cb18f9..50ab772d5a 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp
@@ -289,11 +289,7 @@ QPlatformBackingStore *QAndroidPlatformIntegration::createPlatformBackingStore(Q
if (!QtAndroid::activity())
return nullptr;
- auto *backingStore = new QAndroidPlatformBackingStore(window);
-#if QT_CONFIG(opengl)
- backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
-#endif // QT_CONFIG(opengl)
- return backingStore;
+ return new QAndroidPlatformBackingStore(window);
}
QPlatformOpenGLContext *QAndroidPlatformIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index eed276aed3..087835bd81 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -98,8 +98,6 @@ QT += \
core-private gui-private \
theme_support-private
-qtConfig(opengl): QT += opengl-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 1fbe09fa9c..6b97eb710b 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -68,10 +68,6 @@
#include <QtGui/private/qfontengine_coretext_p.h>
-#if QT_CONFIG(opengl)
-#include <QtOpenGL/qpa/qplatformbackingstoreopenglsupport.h>
-#endif
-
#ifdef QT_WIDGETS_LIB
#include <QtWidgets/qtwidgetsglobal.h>
#if QT_CONFIG(filedialog)
@@ -333,9 +329,6 @@ QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *wi
else
backingStore = new QNSWindowBackingStore(window);
-#if QT_CONFIG(opengl)
- backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
-#endif
return backingStore;
}
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 8b68c83eef..7352e68562 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -191,11 +191,7 @@ 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
{
- auto *backingStore = new QIOSBackingStore(window);
-#if QT_CONFIG(opengl)
- backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
-#endif
- return backingStore;
+ return new QIOSBackingStore(window);
}
// 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 fd76f64dc9..24741f11ae 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.cpp
+++ b/src/plugins/platforms/wasm/qwasmintegration.cpp
@@ -181,7 +181,6 @@ 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/windows/qwindowsgdiintegration.cpp b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp
index 3b25840e16..bb24060dbe 100644
--- a/src/plugins/platforms/windows/qwindowsgdiintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp
@@ -77,11 +77,7 @@ QPlatformPixmap *QWindowsGdiIntegration::createPlatformPixmap(QPlatformPixmap::P
QPlatformBackingStore *QWindowsGdiIntegration::createPlatformBackingStore(QWindow *window) const
{
- auto *backingStore = new QWindowsBackingStore(window);
-#ifndef QT_NO_OPENGL
- backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
-#endif
- return backingStore;
+ return new QWindowsBackingStore(window);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp
index 0f76d7d65b..0d87832176 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.cpp
+++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp
@@ -208,11 +208,7 @@ QPlatformWindow *QWinRTIntegration::createPlatformWindow(QWindow *window) const
QPlatformBackingStore *QWinRTIntegration::createPlatformBackingStore(QWindow *window) const
{
- auto *backingStore = new QWinRTBackingStore(window);
-#if QT_CONFIG(opengl)
- backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
-#endif
- return backingStore;
+ return new QWinRTBackingStore(window);
}
QPlatformOpenGLContext *QWinRTIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 986ba862e5..c2109f8993 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -304,9 +304,6 @@ QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *wind
backingStore = new QXcbBackingStore(window);
}
Q_ASSERT(backingStore);
-#ifndef QT_NO_OPENGL
- backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
-#endif
return backingStore;
}