summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-07-28 15:31:44 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-07-29 20:34:15 +0200
commit3d03f4e989e0ae53569a1a2e390d71c41d91f329 (patch)
tree4504dea0fdb942778902ff823636da531ae69aaa /src
parentd14cf6d3d980e9289d95b197ca46a55e9e263b22 (diff)
Register QPlatformBackingStoreOpenGLSupport when needed
Static builds can not rely on a constructor function in the QtOpenGL library, as that will be linked out unless something in the application pulls it in. Instead we export a helper function that clients that depend on OpenGL support in QPlatformBackingStore can use to bring it it. Change-Id: Ic54058bf413a476287884c78df5624b862f97695 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/opengl/qplatformbackingstoreopenglsupport.cpp15
-rw-r--r--src/opengl/qplatformbackingstoreopenglsupport.h2
-rw-r--r--src/openglwidgets/qopenglwidget.cpp3
-rw-r--r--src/plugins/platforms/ios/qiosbackingstore.mm4
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm4
5 files changed, 15 insertions, 13 deletions
diff --git a/src/opengl/qplatformbackingstoreopenglsupport.cpp b/src/opengl/qplatformbackingstoreopenglsupport.cpp
index 6f893671c0..46e36c23d4 100644
--- a/src/opengl/qplatformbackingstoreopenglsupport.cpp
+++ b/src/opengl/qplatformbackingstoreopenglsupport.cpp
@@ -450,17 +450,14 @@ GLuint QPlatformBackingStoreOpenGLSupport::toTexture(const QRegion &dirtyRegion,
return textureId;
}
-static QPlatformBackingStoreOpenGLSupportBase *createOpenGLSupport()
+void qt_registerDefaultPlatformBackingStoreOpenGLSupport()
{
- return new QPlatformBackingStoreOpenGLSupport;
-}
-
-static void setDefaultOpenGLSupportFactoryFunction()
-{
- if (!QPlatformBackingStoreOpenGLSupportBase::factoryFunction())
- QPlatformBackingStoreOpenGLSupportBase::setFactoryFunction(createOpenGLSupport);
+ if (!QPlatformBackingStoreOpenGLSupportBase::factoryFunction()) {
+ QPlatformBackingStoreOpenGLSupportBase::setFactoryFunction([]() -> QPlatformBackingStoreOpenGLSupportBase* {
+ return new QPlatformBackingStoreOpenGLSupport;
+ });
+ }
}
-Q_CONSTRUCTOR_FUNCTION(setDefaultOpenGLSupportFactoryFunction);
#endif // QT_NO_OPENGL
diff --git a/src/opengl/qplatformbackingstoreopenglsupport.h b/src/opengl/qplatformbackingstoreopenglsupport.h
index 4821f7300f..ae9d972c6a 100644
--- a/src/opengl/qplatformbackingstoreopenglsupport.h
+++ b/src/opengl/qplatformbackingstoreopenglsupport.h
@@ -78,6 +78,8 @@ private:
QOpenGLTextureBlitter *blitter = nullptr;
};
+Q_OPENGL_EXPORT void qt_registerDefaultPlatformBackingStoreOpenGLSupport();
+
QT_END_NAMESPACE
#endif // QT_NO_OPENGL
diff --git a/src/openglwidgets/qopenglwidget.cpp b/src/openglwidgets/qopenglwidget.cpp
index b7abc89c0b..cb60de1fd1 100644
--- a/src/openglwidgets/qopenglwidget.cpp
+++ b/src/openglwidgets/qopenglwidget.cpp
@@ -55,6 +55,7 @@
#include <QtGui/private/qopenglcontext_p.h>
#include <QtOpenGL/private/qopenglframebufferobject_p.h>
#include <QtOpenGL/private/qopenglpaintdevice_p.h>
+#include <QtOpenGL/qpa/qplatformbackingstoreopenglsupport.h>
#include <QtWidgets/private/qwidget_p.h>
@@ -1411,6 +1412,8 @@ bool QOpenGLWidget::event(QEvent *e)
return QWidget::event(e);
}
+Q_CONSTRUCTOR_FUNCTION(qt_registerDefaultPlatformBackingStoreOpenGLSupport);
+
QT_END_NAMESPACE
#include "moc_qopenglwidget.cpp"
diff --git a/src/plugins/platforms/ios/qiosbackingstore.mm b/src/plugins/platforms/ios/qiosbackingstore.mm
index db4dd81b2e..074a8ee56d 100644
--- a/src/plugins/platforms/ios/qiosbackingstore.mm
+++ b/src/plugins/platforms/ios/qiosbackingstore.mm
@@ -43,6 +43,8 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/private/qwindow_p.h>
+#include <QtOpenGL/qpa/qplatformbackingstoreopenglsupport.h>
+
#include <QtDebug>
QT_BEGIN_NAMESPACE
@@ -88,4 +90,6 @@ void QIOSBackingStore::flush(QWindow *window, const QRegion &region, const QPoin
composeAndFlush(window, region, offset, &emptyTextureList, false);
}
+Q_CONSTRUCTOR_FUNCTION(qt_registerDefaultPlatformBackingStoreOpenGLSupport);
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 962456965a..725c280129 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -66,10 +66,6 @@
#import <AudioToolbox/AudioServices.h>
-#if QT_CONFIG(opengl)
-#include <QtOpenGL/qpa/qplatformbackingstoreopenglsupport.h>
-#endif
-
#include <QtDebug>
QT_BEGIN_NAMESPACE