From d700a02d5078d9334c0333bcd11dc3639f91328e Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Tue, 17 Nov 2015 14:18:47 +0300 Subject: [PATCH] Corrections after colleagues comments. --- graphics/defines.cpp | 6 +-- graphics/defines.hpp | 4 +- iphone/Maps/Classes/EAGLView.mm | 46 ++++++++----------- .../FrameworkUtils/MWMFrameworkUtils.mm | 5 +- render/render_policy.cpp | 4 +- render/render_policy.hpp | 2 +- 6 files changed, 30 insertions(+), 37 deletions(-) diff --git a/graphics/defines.cpp b/graphics/defines.cpp index 0fbd763129..f0dc2466ba 100644 --- a/graphics/defines.cpp +++ b/graphics/defines.cpp @@ -77,14 +77,14 @@ namespace graphics density = static_cast(FindFirstBySecond(s_density, name, EqualStrings())); } - double visualScaleExact(int exactDensity) + double visualScaleExact(int exactDensityDPI) { double const mdpiDensityDPI = 160.; // For some old devices (for example iPad 2) the density could be less than 160 DPI. // Returns one in that case to keep readable text on the map. - if (exactDensity <= mdpiDensityDPI) + if (exactDensityDPI <= mdpiDensityDPI) return 1.; - return exactDensity / mdpiDensityDPI; + return exactDensityDPI / mdpiDensityDPI; } DataIS s_semantics[] = { diff --git a/graphics/defines.hpp b/graphics/defines.hpp index 29984f6387..348d25effc 100644 --- a/graphics/defines.hpp +++ b/graphics/defines.hpp @@ -27,8 +27,8 @@ namespace graphics /// get density from name void convert(char const * name, EDensity & density); - /// get scaling koefficient for specified density - double visualScaleExact(int exactDensity); + /// Gets visual scale by exact density in dpi. + double visualScaleExact(int exactDensityDPI); /// When adding values here, /// please check constructor of ResourceManager, diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index 28fa79af5d..53f5342c82 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -28,34 +28,26 @@ namespace { - // returns DPI as exact as possible. It works for iPhone, iPad and iWatch. - double getExactDPI() +// Returns DPI as exact as possible. It works for iPhone, iPad and iWatch. +double getExactDPI() +{ + float const iPadDPI = 132.f; + float const iPhoneDPI = 163.f; + float const mDPI = 160.f; + + UIScreen * screen = [UIScreen mainScreen]; + float const scale = [screen respondsToSelector:@selector(scale)] ? [screen scale] : 1.f; + + switch (UI_USER_INTERFACE_IDIOM()) { - float const iPadDPI = 132.; - float const iPhoneDPI = 163.; - float const mDPI = 160; - - float scale = 1; - if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) - { - scale = [[UIScreen mainScreen] scale]; - } - - float dpi; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) - { - dpi = iPadDPI * scale; - } - else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) - { - dpi = iPhoneDPI * scale; - } - else - { - dpi = mDPI * scale; - }; - return dpi; + case UIUserInterfaceIdiomPhone: + return iPhoneDPI * scale; + case UIUserInterfaceIdiomPad: + return iPadDPI * scale; + default: + return mDPI * scale; } +} } // namespace // You must implement this method @@ -113,7 +105,7 @@ namespace NSLog(@"EAGLView initRenderPolicy Started"); #ifndef USE_DRAPE - float const dpi = getExactDPI(); + int const dpi = static_cast(getExactDPI()); graphics::ResourceManager::Params rmParams; rmParams.m_videoMemoryLimit = GetPlatform().VideoMemoryLimit(); diff --git a/iphone/Maps/maps.me WatchKit Extension/FrameworkUtils/MWMFrameworkUtils.mm b/iphone/Maps/maps.me WatchKit Extension/FrameworkUtils/MWMFrameworkUtils.mm index 1990339c1f..06a798062d 100644 --- a/iphone/Maps/maps.me WatchKit Extension/FrameworkUtils/MWMFrameworkUtils.mm +++ b/iphone/Maps/maps.me WatchKit Extension/FrameworkUtils/MWMFrameworkUtils.mm @@ -56,10 +56,11 @@ extern NSString * const kSearchResultPointKey; + (void)initSoftwareRenderer { - int const xhdpi = 320; + // @TODO. It's a hard code of apple watch dpi. It should be gotten dynamicly. + int const iWatchDPI = 384; Framework & f = GetFramework(); if (!f.IsSingleFrameRendererInited()) - f.InitSingleFrameRenderer(graphics::EDensityXHDPI, xhdpi); + f.InitSingleFrameRenderer(graphics::EDensityXHDPI, iWatchDPI); } + (void)releaseSoftwareRenderer diff --git a/render/render_policy.cpp b/render/render_policy.cpp index ca0f5d15f1..0a1d59fc6a 100644 --- a/render/render_policy.cpp +++ b/render/render_policy.cpp @@ -342,7 +342,7 @@ RenderPolicy * CreateRenderPolicy(RenderPolicy::Params const & params) graphics::GlyphCache::Params GetGlyphCacheParams(graphics::EDensity density, - int exactDensity, + int exactDensityDPI, size_t cacheMaxSize) { return graphics::GlyphCache::Params(UNICODE_BLOCK_FILE, @@ -350,7 +350,7 @@ graphics::GlyphCache::Params GetGlyphCacheParams(graphics::EDensity density, BLACK_LIST_FILE, cacheMaxSize, density, - exactDensity, + exactDensityDPI, false); } diff --git a/render/render_policy.hpp b/render/render_policy.hpp index 5a1f5ef6b0..77d45ba0b4 100644 --- a/render/render_policy.hpp +++ b/render/render_policy.hpp @@ -202,5 +202,5 @@ protected: RenderPolicy * CreateRenderPolicy(RenderPolicy::Params const & params); graphics::GlyphCache::Params GetGlyphCacheParams(graphics::EDensity density, - int exactDensity, size_t cacheMaxSize = 2 * 1024 * 1024); + int exactDensityDPI, size_t cacheMaxSize = 2 * 1024 * 1024); graphics::ResourceManager::GlyphCacheParams GetResourceGlyphCacheParams(graphics::EDensity density, size_t cacheMaxSize = 2 * 1024 * 1024);