summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r--src/plugins/platforms/ios/qiosapplicationdelegate.mm6
-rw-r--r--src/plugins/platforms/ios/qioscontext.h4
-rw-r--r--src/plugins/platforms/ios/qioscontext.mm9
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm2
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm4
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.mm8
-rw-r--r--src/plugins/platforms/ios/qioswindow.h5
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm44
8 files changed, 45 insertions, 37 deletions
diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.mm b/src/plugins/platforms/ios/qiosapplicationdelegate.mm
index e06d2b8840..4d88faba75 100644
--- a/src/plugins/platforms/ios/qiosapplicationdelegate.mm
+++ b/src/plugins/platforms/ios/qiosapplicationdelegate.mm
@@ -60,11 +60,7 @@
self.qiosViewController = [[[QIOSViewController alloc] init] autorelease];
self.window.rootViewController = self.qiosViewController;
-#ifdef QT_DEBUG
- self.window.backgroundColor = [UIColor cyanColor];
-#endif
-
- [self.window makeKeyAndVisible];
+ self.window.hidden = NO;
return YES;
}
diff --git a/src/plugins/platforms/ios/qioscontext.h b/src/plugins/platforms/ios/qioscontext.h
index 961661c5d3..c48a0251a9 100644
--- a/src/plugins/platforms/ios/qioscontext.h
+++ b/src/plugins/platforms/ios/qioscontext.h
@@ -48,6 +48,8 @@
QT_BEGIN_NAMESPACE
+class QIOSWindow;
+
class QIOSContext : public QObject, public QPlatformOpenGLContext
{
Q_OBJECT
@@ -87,7 +89,7 @@ private:
static void deleteBuffers(const FramebufferObject &framebufferObject);
- mutable QHash<QWindow *, FramebufferObject> m_framebufferObjects;
+ mutable QHash<QIOSWindow *, FramebufferObject> m_framebufferObjects;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm
index d7b9314ae0..7310d2904f 100644
--- a/src/plugins/platforms/ios/qioscontext.mm
+++ b/src/plugins/platforms/ios/qioscontext.mm
@@ -113,7 +113,7 @@ void QIOSContext::swapBuffers(QPlatformSurface *surface)
{
Q_ASSERT(surface && surface->surface()->surfaceType() == QSurface::OpenGLSurface);
Q_ASSERT(surface->surface()->surfaceClass() == QSurface::Window);
- QWindow *window = static_cast<QWindow *>(surface->surface());
+ QIOSWindow *window = static_cast<QIOSWindow *>(surface);
Q_ASSERT(m_framebufferObjects.contains(window));
[EAGLContext setCurrentContext:m_eaglContext];
@@ -124,7 +124,7 @@ void QIOSContext::swapBuffers(QPlatformSurface *surface)
GLuint QIOSContext::defaultFramebufferObject(QPlatformSurface *surface) const
{
Q_ASSERT(surface && surface->surface()->surfaceClass() == QSurface::Window);
- QWindow *window = static_cast<QWindow *>(surface->surface());
+ QIOSWindow *window = static_cast<QIOSWindow *>(surface);
FramebufferObject &framebufferObject = m_framebufferObjects[window];
@@ -155,8 +155,7 @@ GLuint QIOSContext::defaultFramebufferObject(QPlatformSurface *surface) const
}
// Ensure that the FBO's buffers match the size of the layer
- QIOSWindow *platformWindow = static_cast<QIOSWindow *>(surface);
- UIView *view = reinterpret_cast<UIView *>(platformWindow->winId());
+ UIView *view = reinterpret_cast<UIView *>(window->winId());
CAEAGLLayer *layer = static_cast<CAEAGLLayer *>(view.layer);
if (framebufferObject.renderbufferWidth != (layer.frame.size.width * layer.contentsScale) ||
framebufferObject.renderbufferHeight != (layer.frame.size.height * layer.contentsScale)) {
@@ -191,7 +190,7 @@ GLuint QIOSContext::defaultFramebufferObject(QPlatformSurface *surface) const
void QIOSContext::windowDestroyed(QObject *object)
{
- QWindow *window = static_cast<QWindow *>(object);
+ QIOSWindow *window = static_cast<QIOSWindow *>(object);
if (m_framebufferObjects.contains(window)) {
EAGLContext *originalContext = [EAGLContext currentContext];
[EAGLContext setCurrentContext:m_eaglContext];
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 393a9f317d..44ac749454 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -101,6 +101,8 @@ QIOSIntegration::~QIOSIntegration()
bool QIOSIntegration::hasCapability(Capability cap) const
{
switch (cap) {
+ case BufferQueueingOpenGL:
+ return true;
case OpenGL:
case ThreadedOpenGL:
return true;
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index c28d8881bf..d57e678810 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -123,8 +123,6 @@ QIOSScreen::QIOSScreen(unsigned int screenIndex)
, m_uiScreen([[UIScreen screens] objectAtIndex:qMin(NSUInteger(screenIndex), [[UIScreen screens] count] - 1)])
, m_orientationListener(0)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
QString deviceIdentifier = deviceModelIdentifier();
if (deviceIdentifier == QStringLiteral("iPhone2,1") /* iPhone 3GS */
@@ -153,8 +151,6 @@ QIOSScreen::QIOSScreen(unsigned int screenIndex)
// When in a non-mixed environment, let QScreen follow the current interface orientation:
setPrimaryOrientation(toQtScreenOrientation(UIDeviceOrientation(qiosViewController().interfaceOrientation)));
}
-
- [pool release];
}
QIOSScreen::~QIOSScreen()
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm
index d315b49776..656a86027d 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.mm
+++ b/src/plugins/platforms/ios/qiosviewcontroller.mm
@@ -48,14 +48,6 @@
@implementation QIOSViewController
-- (void)viewDidLoad
-{
-#ifdef QT_DEBUG
- if (!self.nibName)
- self.view.backgroundColor = [UIColor magentaColor];
-#endif
-}
-
-(BOOL)shouldAutorotate
{
// Until a proper orientation and rotation API is in place, we always auto rotate.
diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h
index b60290e479..5ded589205 100644
--- a/src/plugins/platforms/ios/qioswindow.h
+++ b/src/plugins/platforms/ios/qioswindow.h
@@ -58,8 +58,10 @@ QT_BEGIN_NAMESPACE
@class QUIView;
-class QIOSWindow : public QPlatformWindow
+class QIOSWindow : public QObject, public QPlatformWindow
{
+ Q_OBJECT
+
public:
explicit QIOSWindow(QWindow *window);
~QIOSWindow();
@@ -87,7 +89,6 @@ private:
QRect m_normalGeometry;
int m_windowLevel;
- qreal m_devicePixelRatio;
void raiseOrLower(bool raise);
void updateWindowLevel();
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index f46616db1d..e02f570634 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -127,6 +127,32 @@
return self;
}
+- (void)willMoveToWindow:(UIWindow *)newWindow
+{
+ // UIKIt will normally set the scale factor of a view to match the corresponding
+ // screen scale factor, but views backed by CAEAGLLayers need to do this manually.
+ self.contentScaleFactor = newWindow && newWindow.screen ?
+ newWindow.screen.scale : [[UIScreen mainScreen] scale];
+
+ // FIXME: Allow the scale factor to be customized through QSurfaceFormat.
+}
+
+- (void)didAddSubview:(UIView *)subview
+{
+ if ([subview isKindOfClass:[QUIView class]])
+ self.clipsToBounds = YES;
+}
+
+- (void)willRemoveSubview:(UIView *)subview
+{
+ for (UIView *view in self.subviews) {
+ if (view != subview && [view isKindOfClass:[QUIView class]])
+ return;
+ }
+
+ self.clipsToBounds = NO;
+}
+
- (void)layoutSubviews
{
// This method is the de facto way to know that view has been resized,
@@ -331,19 +357,9 @@ QIOSWindow::QIOSWindow(QWindow *window)
, m_view([[QUIView alloc] initWithQIOSWindow:this])
, m_normalGeometry(QPlatformWindow::geometry())
, m_windowLevel(0)
- , m_devicePixelRatio(1.0)
{
- setParent(parent());
+ setParent(QPlatformWindow::parent());
setWindowState(window->windowState());
-
- // Retina support: get screen scale factor and set it in the content view.
- // This will make framebufferObject() create a 2x frame buffer on retina
- // displays. Also set m_devicePixelRatio which is used for scaling the
- // paint device.
- if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] == YES) {
- m_devicePixelRatio = [[UIScreen mainScreen] scale];
- [m_view setContentScaleFactor: m_devicePixelRatio];
- }
}
QIOSWindow::~QIOSWindow()
@@ -456,6 +472,8 @@ void QIOSWindow::requestActivateWindow()
if (!window()->isTopLevel() || blockedByModal())
return;
+ [m_view.window makeKeyWindow];
+
raise();
QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext();
static_cast<QIOSInputContext *>(context)->focusViewChanged(m_view);
@@ -522,7 +540,9 @@ void QIOSWindow::handleContentOrientationChange(Qt::ScreenOrientation orientatio
qreal QIOSWindow::devicePixelRatio() const
{
- return m_devicePixelRatio;
+ return m_view.contentScaleFactor;
}
+#include "moc_qioswindow.cpp"
+
QT_END_NAMESPACE