From 09e13c7196c8cd46d75230f59b1f1f0521abebc6 Mon Sep 17 00:00:00 2001 From: ExMix Date: Tue, 23 Sep 2014 12:38:15 +0300 Subject: [PATCH] [core] iphone6+ scaling fix --- graphics/defines.cpp | 5 +++-- graphics/defines.hpp | 3 ++- iphone/Maps/Classes/EAGLView.mm | 17 +++++++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/graphics/defines.cpp b/graphics/defines.cpp index c0fd2b0dcc..b3884dffc0 100644 --- a/graphics/defines.cpp +++ b/graphics/defines.cpp @@ -63,7 +63,8 @@ namespace graphics {EDensityMDPI, "mdpi"}, {EDensityHDPI, "hdpi"}, {EDensityXHDPI, "xhdpi"}, - {EDensityXXHDPI, "xxhdpi"} + {EDensityXXHDPI, "xxhdpi"}, + {EDensityIPhone6Plus, "xhdpi"} }; char const * convert(EDensity density) @@ -83,7 +84,7 @@ namespace graphics double visualScale(EDensity density) { - static double const vs [5] = { 0.75, 1, 1.5, 2, 3 }; + static double const vs [6] = { 0.75, 1, 1.5, 2, 3, 2.4 }; return vs[density]; } diff --git a/graphics/defines.hpp b/graphics/defines.hpp index 9ec798e7ef..64d4ad34b5 100644 --- a/graphics/defines.hpp +++ b/graphics/defines.hpp @@ -13,7 +13,8 @@ namespace graphics EDensityMDPI, EDensityHDPI, EDensityXHDPI, - EDensityXXHDPI + EDensityXXHDPI, + EDensityIPhone6Plus }; /// get density name diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index a0ecdb249c..a4a7bdc347 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -1,6 +1,8 @@ #import #import +#import "../Categories/UIKitCategories.h" + #import "EAGLView.h" #include "RenderBuffer.hpp" @@ -54,7 +56,7 @@ // Backbuffer : YES, (to prevent from loosing content when mixing with ordinary layers). eaglLayer.drawableProperties = @{kEAGLDrawablePropertyRetainedBacking : @NO, kEAGLDrawablePropertyColorFormat : kEAGLColorFormatRGB565}; // Correct retina display support in opengl renderbuffer - self.contentScaleFactor = [UIScreen mainScreen].scale; + self.contentScaleFactor = [self correctContentScale]; } NSLog(@"EAGLView initWithCoder Ended"); @@ -81,7 +83,7 @@ CGRect frameRect = screen.applicationFrame; CGRect screenRect = screen.bounds; - double vs = screen.scale; + double vs = self.contentScaleFactor; rpParams.m_screenWidth = screenRect.size.width * vs; rpParams.m_screenHeight = screenRect.size.height * vs; @@ -90,6 +92,8 @@ if (vs == 1.0) rpParams.m_density = graphics::EDensityMDPI; + else if (vs > 2.0) + rpParams.m_density = graphics::EDensityIPhone6Plus; else rpParams.m_density = graphics::EDensityXHDPI; @@ -146,6 +150,15 @@ screen->endFrame(); } +- (double)correctContentScale +{ + UIScreen * uiScreen = [UIScreen mainScreen]; + if (SYSTEM_VERSION_IS_LESS_THAN(@"8")) + return uiScreen.scale; + else + return uiScreen.nativeScale; +} + - (void)drawFrame { shared_ptr pe(new PaintEvent(renderPolicy->GetDrawer().get()));