summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2012-11-04 19:39:45 +0100
committerTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-02-27 23:55:34 +0100
commit5e85aa9ab4c30c123de6431679d3870a4b7836c2 (patch)
tree33b0f5e682c84de203177ec40a666ff96adb2526 /src
parent14e93f7e8e0ef58b0e47bfe277d52b2fa8f24ee7 (diff)
iOS: Keep UIScreen* for current QIOSScreen instead of looking up each time
Also, add enum for screen numbers, for better code readability. Change-Id: Id5162c34e80ff5efb149ae86b49f51df183d1c1d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm2
-rw-r--r--src/plugins/platforms/ios/qiosscreen.h7
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm12
3 files changed, 11 insertions, 10 deletions
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 68a9bf343f..7a6dec43d4 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -52,7 +52,7 @@
QT_BEGIN_NAMESPACE
QIOSIntegration::QIOSIntegration()
- :m_fontDb(new QCoreTextFontDatabase), m_screen(new QIOSScreen(0))
+ :m_fontDb(new QCoreTextFontDatabase), m_screen(new QIOSScreen(QIOSScreen::MainScreen))
{
screenAdded(m_screen);
}
diff --git a/src/plugins/platforms/ios/qiosscreen.h b/src/plugins/platforms/ios/qiosscreen.h
index 628d764f53..98771b9ac2 100644
--- a/src/plugins/platforms/ios/qiosscreen.h
+++ b/src/plugins/platforms/ios/qiosscreen.h
@@ -51,9 +51,11 @@ QT_BEGIN_NAMESPACE
class QIOSScreen : public QPlatformScreen
{
public:
- QIOSScreen(int screenIndex);
+ QIOSScreen(unsigned int screenIndex);
~QIOSScreen();
+ enum ScreenIndex { MainScreen = 0 };
+
QRect geometry() const { return m_geometry; }
int depth() const { return m_depth; }
QImage::Format format() const { return m_format; }
@@ -63,14 +65,13 @@ public:
void updateInterfaceOrientation();
private:
+ UIScreen *m_uiScreen;
QRect m_geometry;
int m_depth;
QImage::Format m_format;
QSize m_physicalSize;
- int m_index;
};
QT_END_NAMESPACE
-
#endif
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 5d9841734a..64b9022a29 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -48,13 +48,13 @@
QT_BEGIN_NAMESPACE
-QIOSScreen::QIOSScreen(int screenIndex)
- : QPlatformScreen(),
- m_index(screenIndex)
+QIOSScreen::QIOSScreen(unsigned int screenIndex)
+ : QPlatformScreen()
+ , m_uiScreen([[UIScreen screens] objectAtIndex:qMin(screenIndex, [[UIScreen screens] count] - 1)])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- CGRect bounds = [uiScreen() bounds];
- CGFloat scale = [uiScreen() scale];
+ CGRect bounds = [m_uiScreen bounds];
+ CGFloat scale = [m_uiScreen scale];
updateInterfaceOrientation();
m_format = QImage::Format_ARGB32_Premultiplied;
@@ -87,7 +87,7 @@ QIOSScreen::~QIOSScreen()
UIScreen *QIOSScreen::uiScreen() const
{
- return [[UIScreen screens] objectAtIndex:m_index];
+ return m_uiScreen;
}
void QIOSScreen::updateInterfaceOrientation()