Corrections after colleagues comments.

This commit is contained in:
Vladimir Byko-Ianko 2015-11-17 14:18:47 +03:00
parent c0b4117587
commit d700a02d50
6 changed files with 30 additions and 37 deletions

View file

@ -77,14 +77,14 @@ namespace graphics
density = static_cast<EDensity>(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[] = {

View file

@ -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,

View file

@ -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<int>(getExactDPI());
graphics::ResourceManager::Params rmParams;
rmParams.m_videoMemoryLimit = GetPlatform().VideoMemoryLimit();

View file

@ -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

View file

@ -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);
}

View file

@ -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);