iOS: Fix build with -no-opengl

Change-Id: I014fa1772f629ef4224ac98bfc30eb5a86f38fde
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ae92c571a36703f6ab95d98b55d070cc57023376)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2023-02-01 13:53:40 +01:00 committed by Qt Cherry-pick Bot
parent b9ed727556
commit c988a7eeb6
6 changed files with 27 additions and 5 deletions

View File

@ -15,7 +15,6 @@ qt_internal_add_plugin(QIOSIntegrationPlugin
plugin.mm
qiosapplicationdelegate.h qiosapplicationdelegate.mm
qiosapplicationstate.h qiosapplicationstate.mm
qioscontext.h qioscontext.mm
qioseventdispatcher.h qioseventdispatcher.mm
qiosglobal.h qiosglobal.mm
qiosinputcontext.h qiosinputcontext.mm
@ -51,6 +50,8 @@ qt_disable_apple_app_extension_api_only(QIOSIntegrationPlugin)
qt_internal_find_apple_system_framework(FWUniformTypeIdentifiers UniformTypeIdentifiers)
qt_internal_extend_target(QIOSIntegrationPlugin CONDITION QT_FEATURE_opengl
SOURCES
qioscontext.h qioscontext.mm
LIBRARIES
Qt::OpenGLPrivate
)

View File

@ -33,7 +33,10 @@ public:
QPlatformWindow *createPlatformWindow(QWindow *window) const override;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
#if QT_CONFIG(opengl)
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
#endif
QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override;
QPlatformFontDatabase *fontDatabase() const override;

View File

@ -7,7 +7,6 @@
#include "qioswindow.h"
#include "qiosscreen.h"
#include "qiosplatformaccessibility.h"
#include "qioscontext.h"
#ifndef Q_OS_TVOS
#include "qiosclipboard.h"
#endif
@ -29,6 +28,10 @@
#include <QDir>
#include <QOperatingSystemVersion>
#if QT_CONFIG(opengl)
#include "qioscontext.h"
#endif
#import <AudioToolbox/AudioServices.h>
#include <QtDebug>
@ -128,11 +131,15 @@ QIOSIntegration::~QIOSIntegration()
bool QIOSIntegration::hasCapability(Capability cap) const
{
switch (cap) {
#if QT_CONFIG(opengl)
case BufferQueueingOpenGL:
return true;
case OpenGL:
case ThreadedOpenGL:
return true;
case RasterGLSurface:
return true;
#endif
case ThreadedPixmaps:
return true;
case MultipleWindows:
@ -141,8 +148,6 @@ bool QIOSIntegration::hasCapability(Capability cap) const
return false;
case ApplicationState:
return true;
case RasterGLSurface:
return true;
default:
return QPlatformIntegration::hasCapability(cap);
}
@ -158,11 +163,13 @@ QPlatformBackingStore *QIOSIntegration::createPlatformBackingStore(QWindow *wind
return new QRhiBackingStore(window);
}
#if QT_CONFIG(opengl)
// Used when the QWindow's surface type is set by the client to QSurface::OpenGLSurface
QPlatformOpenGLContext *QIOSIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
return new QIOSContext(context);
}
#endif
class QIOSOffscreenSurface : public QPlatformOffscreenSurface
{

View File

@ -56,7 +56,9 @@ public:
void requestUpdate() override;
#if QT_CONFIG(opengl)
CAEAGLLayer *eaglLayer() const;
#endif
private:
void applicationStateChanged(Qt::ApplicationState state);

View File

@ -4,7 +4,6 @@
#include "qioswindow.h"
#include "qiosapplicationdelegate.h"
#include "qioscontext.h"
#include "qiosglobal.h"
#include "qiosintegration.h"
#include "qiosscreen.h"
@ -15,7 +14,10 @@
#include <QtGui/private/qwindow_p.h>
#include <qpa/qplatformintegration.h>
#if QT_CONFIG(opengl)
#import <QuartzCore/CAEAGLLayer.h>
#endif
#ifdef Q_OS_IOS
#import <QuartzCore/CAMetalLayer.h>
#endif
@ -352,11 +354,13 @@ void QIOSWindow::requestUpdate()
static_cast<QIOSScreen *>(screen())->setUpdatesPaused(false);
}
#if QT_CONFIG(opengl)
CAEAGLLayer *QIOSWindow::eaglLayer() const
{
Q_ASSERT([m_view.layer isKindOfClass:[CAEAGLLayer class]]);
return static_cast<CAEAGLLayer *>(m_view.layer);
}
#endif
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, const QIOSWindow *window)

View File

@ -82,7 +82,10 @@ inline ulong getTimeStamp(UIEvent *event)
+ (Class)layerClass
{
#if QT_CONFIG(opengl)
return [CAEAGLLayer class];
#endif
return [super layerClass];
}
- (instancetype)initWithQIOSWindow:(QT_PREPEND_NAMESPACE(QIOSWindow) *)window
@ -113,6 +116,7 @@ inline ulong getTimeStamp(UIEvent *event)
- (instancetype)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {
#if QT_CONFIG(opengl)
if ([self.layer isKindOfClass:[CAEAGLLayer class]]) {
// Set up EAGL layer
CAEAGLLayer *eaglLayer = static_cast<CAEAGLLayer *>(self.layer);
@ -122,6 +126,7 @@ inline ulong getTimeStamp(UIEvent *event)
kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8
};
}
#endif
if (isQtApplication())
self.hidden = YES;