Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/jni/com/mapswithme/platform/Platform.cpp28
-rw-r--r--android/jni/com/mapswithme/platform/Platform.hpp2
-rw-r--r--graphics/resource_manager.cpp10
-rw-r--r--map/framework.cpp13
-rw-r--r--map/framework.hpp5
-rw-r--r--map/render_policy.cpp18
-rw-r--r--map/render_policy.hpp4
-rw-r--r--map/simple_render_policy.cpp25
-rw-r--r--map/simple_render_policy.hpp4
-rw-r--r--platform/platform.cpp5
-rw-r--r--platform/platform.hpp7
-rw-r--r--platform/platform_android.cpp22
-rw-r--r--platform/platform_ios.mm45
-rw-r--r--platform/platform_linux.cpp4
-rw-r--r--platform/platform_mac.mm4
-rw-r--r--platform/platform_qt.cpp15
16 files changed, 56 insertions, 155 deletions
diff --git a/android/jni/com/mapswithme/platform/Platform.cpp b/android/jni/com/mapswithme/platform/Platform.cpp
index 9e3abbcf6a..905febb393 100644
--- a/android/jni/com/mapswithme/platform/Platform.cpp
+++ b/android/jni/com/mapswithme/platform/Platform.cpp
@@ -6,25 +6,6 @@
#include "../../../../../base/logging.hpp"
-// For the future: It's better to use virtual functions instead of this stuff.
-/*
-class Platform::PlatformImpl
-{
-public:
-
- PlatformImpl() : m_preCachingDepth(3)
- {}
-
- size_t m_preCachingDepth;
-};
-*/
-
-int Platform::PreCachingDepth() const
-{
- //return m_impl->m_preCachingDepth;
- return 3;
-}
-
string Platform::UniqueClientId() const
{
string res;
@@ -70,11 +51,6 @@ string Platform::UniqueClientId() const
namespace android
{
- Platform::~Platform()
- {
- //delete m_impl;
- }
-
void Platform::Initialize(JNIEnv * env,
jstring apkPath,
jstring storagePath,
@@ -82,10 +58,6 @@ namespace android
jstring extTmpPath,
bool isPro)
{
- //if (m_impl)
- // delete m_impl;
- //m_impl = new PlatformImpl();
-
m_resourcesDir = jni::ToNativeString(env, apkPath);
// Settings file should always be in one place (default external storage).
diff --git a/android/jni/com/mapswithme/platform/Platform.hpp b/android/jni/com/mapswithme/platform/Platform.hpp
index fdb6172714..08b41c5fb8 100644
--- a/android/jni/com/mapswithme/platform/Platform.hpp
+++ b/android/jni/com/mapswithme/platform/Platform.hpp
@@ -15,8 +15,6 @@ namespace android
public:
- ~Platform();
-
void Initialize(JNIEnv * env,
jstring apkPath,
jstring storagePath,
diff --git a/graphics/resource_manager.cpp b/graphics/resource_manager.cpp
index 4409d757c4..84a6561b86 100644
--- a/graphics/resource_manager.cpp
+++ b/graphics/resource_manager.cpp
@@ -259,12 +259,12 @@ namespace
m_texRtFormat = graphics::Data8Bpp;
}
- bool isAndroidDevice = GetPlatform().DeviceName() == "Android";
-
- /// on PowerVR chips on Android glFinish doesn't work, so we should use
- /// glReadPixels instead of glFinish to synchronize.
- if (isGPU("Imagination Technologies", "PowerVR", false) && isAndroidDevice)
+#ifdef OMIM_OS_ANDROID
+ // on PowerVR chips on Android glFinish doesn't work, so we should use
+ // glReadPixels instead of glFinish to synchronize.
+ if (isGPU("Imagination Technologies", "PowerVR", false))
m_useReadPixelsToSynchronize = true;
+#endif
LOG(LINFO, ("selected", graphics::formatName(m_texRtFormat), "format for tile textures"));
diff --git a/map/framework.cpp b/map/framework.cpp
index 0156399973..c3bd8ad663 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -166,7 +166,6 @@ Framework::Framework()
: //m_hasPendingInvalidate(false),
//m_doForceUpdate(false),
m_animator(this),
- m_etalonSize(GetPlatform().ScaleEtalonSize()),
m_queryMaxScaleMode(false),
m_drawPlacemark(false),
//m_hasPendingShowRectFixed(false),
@@ -262,6 +261,11 @@ double Framework::GetVisualScale() const
return (m_renderPolicy ? m_renderPolicy->VisualScale() : 1);
}
+int Framework::GetScaleEtalonSize() const
+{
+ return (m_renderPolicy ? m_renderPolicy->ScaleEtalonSize() : 512 + 256);
+}
+
void Framework::DeleteCountry(TIndex const & index)
{
if (!m_storage.DeleteFromDownloader(index))
@@ -962,8 +966,9 @@ void Framework::ShowRectFixed(m2::AnyRectD const & r)
//size_t const sz = m_renderPolicy->ScaleEtalonSize();
/// @todo Get stored value instead of m_renderPolicy call because of invalid render policy here.
- m2::RectD etalonRect(0, 0, m_etalonSize, m_etalonSize);
- etalonRect.Offset(-m_etalonSize / 2, -m_etalonSize);
+ int const etalonSize = GetScaleEtalonSize();
+ m2::RectD etalonRect(0, 0, etalonSize, etalonSize);
+ etalonRect.Offset(-etalonSize / 2, -etalonSize);
m2::PointD const pxCenter = m_navigator.Screen().PixelRect().Center();
etalonRect.Offset(pxCenter);
@@ -1375,8 +1380,6 @@ void Framework::SetRenderPolicy(RenderPolicy * renderPolicy)
if (m_renderPolicy)
{
- m_etalonSize = m_renderPolicy->ScaleEtalonSize();
-
gui::Controller::RenderParams rp(m_renderPolicy->VisualScale(),
bind(&WindowHandle::invalidate,
renderPolicy->GetWindowHandle().get()),
diff --git a/map/framework.hpp b/map/framework.hpp
index e924381ed0..1a6065cd0d 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -90,13 +90,10 @@ protected:
/// Call it when you need do calculate pixel rect (not matter if m_renderPolicy == 0).
/// @return 1.0 if m_renderPolicy == 0 (possible for Android).
double GetVisualScale() const;
+ int GetScaleEtalonSize() const;
double m_StartForegroundTime;
- /// @todo Need deep analyzing in future.
- /// Now it's like a replacement of "m_hasPendingXXX" stuff.
- int m_etalonSize;
-
//bool m_hasPendingInvalidate, m_doForceUpdate, m_queryMaxScaleMode, m_drawPlacemark, m_hasPendingShowRectFixed;
bool m_queryMaxScaleMode, m_drawPlacemark;
diff --git a/map/render_policy.cpp b/map/render_policy.cpp
index 15ff3cbac9..344b28eb68 100644
--- a/map/render_policy.cpp
+++ b/map/render_policy.cpp
@@ -2,7 +2,6 @@
#include "render_policy.hpp"
#include "window_handle.hpp"
-#include "simple_render_policy.hpp"
#include "tiling_render_policy_st.hpp"
#include "tiling_render_policy_mt.hpp"
@@ -198,23 +197,6 @@ bool RenderPolicy::IsEmptyModel() const
return false;
}
-int RenderPolicy::GetDrawScale(ScreenBase const & s) const
-{
- m2::PointD textureCenter(s.PixelRect().Center());
- m2::RectD glbRect;
-
- unsigned scaleEtalonSize = GetPlatform().ScaleEtalonSize();
- s.PtoG(m2::RectD(textureCenter - m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2),
- textureCenter + m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2)),
- glbRect);
- return scales::GetScaleLevel(glbRect);
-}
-
-size_t RenderPolicy::ScaleEtalonSize() const
-{
- return GetPlatform().ScaleEtalonSize();
-}
-
double RenderPolicy::VisualScale() const
{
return m_visualScale;
diff --git a/map/render_policy.hpp b/map/render_policy.hpp
index fc98db5ac7..1462f11c60 100644
--- a/map/render_policy.hpp
+++ b/map/render_policy.hpp
@@ -128,7 +128,7 @@ public:
virtual bool NeedRedraw() const;
virtual bool IsEmptyModel() const;
virtual storage::TIndex GetCountryIndex() const { return storage::TIndex(); }
- virtual int GetDrawScale(ScreenBase const & s) const;
+ virtual int GetDrawScale(ScreenBase const & s) const = 0;
bool DoForceUpdate() const;
void SetForceUpdate(bool flag);
@@ -142,7 +142,7 @@ public:
shared_ptr<WindowHandle> const & GetWindowHandle() const;
graphics::GlyphCache * GetGlyphCache() const;
- virtual size_t ScaleEtalonSize() const;
+ virtual size_t ScaleEtalonSize() const = 0;
double VisualScale() const;
string const & SkinName() const;
diff --git a/map/simple_render_policy.cpp b/map/simple_render_policy.cpp
index c97f6cd38f..23bffa295c 100644
--- a/map/simple_render_policy.cpp
+++ b/map/simple_render_policy.cpp
@@ -113,7 +113,7 @@ SimpleRenderPolicy::SimpleRenderPolicy(Params const & p)
void SimpleRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e,
ScreenBase const & s)
{
- int scaleEtalonSize = GetPlatform().ScaleEtalonSize();
+ size_t const scaleEtalonSize = ScaleEtalonSize();
m2::RectD glbRect;
m2::PointD const pxCenter = s.PixelRect().Center();
@@ -124,15 +124,26 @@ void SimpleRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e,
shared_ptr<graphics::Overlay> overlay(new graphics::Overlay());
Drawer * pDrawer = e->drawer();
+ graphics::Screen * pScreen = pDrawer->screen().get();
- pDrawer->screen()->setOverlay(overlay);
- pDrawer->screen()->beginFrame();
- pDrawer->screen()->clear(m_bgColor);
+ pScreen->setOverlay(overlay);
+ pScreen->beginFrame();
+ pScreen->clear(m_bgColor);
m_renderFn(e, s, s.ClipRect(), s.ClipRect(), scales::GetScaleLevel(glbRect), false);
- overlay->draw(pDrawer->screen().get(), math::Identity<double, 3>());
- pDrawer->screen()->resetOverlay();
+ overlay->draw(pScreen, math::Identity<double, 3>());
+ pScreen->resetOverlay();
- pDrawer->screen()->endFrame();
+ pScreen->endFrame();
+}
+
+size_t SimpleRenderPolicy::ScaleEtalonSize() const
+{
+ return 512 + 256;
+}
+
+int SimpleRenderPolicy::GetDrawScale(ScreenBase const & s) const
+{
+ return 0;
}
diff --git a/map/simple_render_policy.hpp b/map/simple_render_policy.hpp
index 90fb6e25aa..03886d9059 100644
--- a/map/simple_render_policy.hpp
+++ b/map/simple_render_policy.hpp
@@ -9,4 +9,8 @@ public:
void DrawFrame(shared_ptr<PaintEvent> const & paintEvent,
ScreenBase const & screenBase);
+
+ size_t ScaleEtalonSize() const;
+
+ int GetDrawScale(ScreenBase const & s) const;
};
diff --git a/platform/platform.cpp b/platform/platform.cpp
index 185632e552..9f6f4e2d32 100644
--- a/platform/platform.cpp
+++ b/platform/platform.cpp
@@ -76,3 +76,8 @@ void Platform::GetFilesByExt(string const & directory, string const & ext, Files
GetFilesByRegExp(directory, '\\' + ext + '$', outFiles);
}
+
+string Platform::DeviceName() const
+{
+ return OMIM_OS_NAME;
+}
diff --git a/platform/platform.hpp b/platform/platform.hpp
index c47ff5beb9..b826dc970e 100644
--- a/platform/platform.hpp
+++ b/platform/platform.hpp
@@ -29,10 +29,6 @@ protected:
/// Flag that it's a paid PRO version of app.
bool m_isPro;
- class PlatformImpl;
- /// Used only on those platforms where needed
- PlatformImpl * m_impl;
-
/// Internal function to use files from writable dir
/// if they override the same file in the resources dir
string ReadPathForFile(string const & file) const;
@@ -42,7 +38,6 @@ protected:
public:
Platform();
- ~Platform();
static bool IsFileExistsByFullPath(string const & filePath);
@@ -122,8 +117,6 @@ public:
string DeviceName() const;
- int ScaleEtalonSize() const;
-
string UniqueClientId() const;
inline bool IsPro() const { return m_isPro; }
diff --git a/platform/platform_android.cpp b/platform/platform_android.cpp
index 9ff174079b..04ca781ed1 100644
--- a/platform/platform_android.cpp
+++ b/platform/platform_android.cpp
@@ -11,11 +11,10 @@
#include <unistd.h>
-Platform::Platform() : m_impl(0)
-{}
-
-Platform::~Platform()
-{}
+Platform::Platform()
+{
+ /// @see initialization routine in android/jni/com/.../Platform.hpp
+}
ModelReader * Platform::GetReader(string const & file) const
{
@@ -77,19 +76,14 @@ int Platform::CpuCores() const
return (numCPU > 1 ? static_cast<int>(numCPU) : 1);
}
-string Platform::DeviceName() const
-{
- return "Android";
-}
-
-int Platform::ScaleEtalonSize() const
+int Platform::VideoMemoryLimit() const
{
- return 512 + 256;
+ return 10 * 1024 * 1024;
}
-int Platform::VideoMemoryLimit() const
+int Platform::PreCachingDepth() const
{
- return 10 * 1024 * 1024;
+ return 3;
}
bool Platform::GetFileSizeByName(string const & fileName, uint64_t & size) const
diff --git a/platform/platform_ios.mm b/platform/platform_ios.mm
index 5b99e1e161..8492d4b605 100644
--- a/platform/platform_ios.mm
+++ b/platform/platform_ios.mm
@@ -26,18 +26,8 @@
#import <UIKit/UIScreenMode.h>
-class Platform::PlatformImpl
-{
-public:
- int m_scaleEtalonSize;
- string m_deviceName;
- int m_videoMemoryLimit;
-};
-
Platform::Platform()
{
- m_impl = new PlatformImpl;
-
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSBundle * bundle = [NSBundle mainBundle];
@@ -53,37 +43,16 @@ Platform::Platform()
m_tmpDir = [NSHomeDirectory() UTF8String];
m_tmpDir += "/tmp/";
- m_impl->m_videoMemoryLimit = 8 * 1024 * 1024;
-
- UIDevice * device = [UIDevice currentDevice];
- NSRange range = [device.model rangeOfString:@"iPad"];
- if (range.location != NSNotFound)
- m_impl->m_deviceName = "iPad";
- else
- {
- range = [device.model rangeOfString:@"iPod"];
- if (range.location != NSNotFound)
- m_impl->m_deviceName = "iPod";
- else
- m_impl->m_deviceName = "iPhone";
- }
-
- m_impl->m_scaleEtalonSize = 256 * 1.5 * [[UIScreen mainScreen] scale];
-
NSString * appID = [[bundle infoDictionary] objectForKey:@"CFBundleIdentifier"];
// .travelguide corresponds to the Lite version without search
m_isPro = ([appID rangeOfString:@"com.mapswithme.travelguide"].location == NSNotFound);
+ UIDevice * device = [UIDevice currentDevice];
NSLog(@"Device: %@, SystemName: %@, SystemVersion: %@", device.model, device.systemName, device.systemVersion);
[pool release];
}
-Platform::~Platform()
-{
- delete m_impl;
-}
-
void Platform::GetFilesByRegExp(string const & directory, string const & regexp, FilesList & res)
{
pl::EnumerateFilesByRegExp(directory, regexp, res);
@@ -115,14 +84,9 @@ int Platform::CpuCores() const
return 1;
}
-int Platform::ScaleEtalonSize() const
-{
- return m_impl->m_scaleEtalonSize;
-}
-
int Platform::VideoMemoryLimit() const
{
- return m_impl->m_videoMemoryLimit;
+ return 8 * 1024 * 1024;
}
int Platform::PreCachingDepth() const
@@ -130,11 +94,6 @@ int Platform::PreCachingDepth() const
return 2;
}
-string Platform::DeviceName() const
-{
- return m_impl->m_deviceName;
-}
-
static string GetDeviceUid()
{
NSString * uid = [[UIDevice currentDevice] uniqueIdentifier];
diff --git a/platform/platform_linux.cpp b/platform/platform_linux.cpp
index b3c20ab0ad..2b44259284 100644
--- a/platform/platform_linux.cpp
+++ b/platform/platform_linux.cpp
@@ -42,10 +42,6 @@ Platform::Platform()
LOG(LDEBUG, ("Settings directory:", m_settingsDir));
}
-Platform::~Platform()
-{
-}
-
int Platform::CpuCores() const
{
const long numCPU = sysconf(_SC_NPROCESSORS_ONLN);
diff --git a/platform/platform_mac.mm b/platform/platform_mac.mm
index b1efe1c197..248892e3d5 100644
--- a/platform/platform_mac.mm
+++ b/platform/platform_mac.mm
@@ -65,10 +65,6 @@ Platform::Platform()
LOG(LDEBUG, ("Settings Directory:", m_settingsDir));
}
-Platform::~Platform()
-{
-}
-
int Platform::CpuCores() const
{
int mib[2], numCPU = 0;
diff --git a/platform/platform_qt.cpp b/platform/platform_qt.cpp
index e5bf38d9b7..25165f59d6 100644
--- a/platform/platform_qt.cpp
+++ b/platform/platform_qt.cpp
@@ -12,7 +12,6 @@
#include <QtCore/QFileInfo>
-////////////////////////////////////////////////////////////////////////////////////////
ModelReader * Platform::GetReader(string const & file) const
{
return new FileReader(ReadPathForFile(file),
@@ -47,29 +46,21 @@ void Platform::GetFilesByRegExp(string const & directory, string const & regexp,
}
}
-string Platform::DeviceName() const
-{
- return OMIM_OS_NAME;
-}
-
int Platform::PreCachingDepth() const
{
return 3;
}
-int Platform::ScaleEtalonSize() const
-{
- return 512 + 256;
-}
-
int Platform::VideoMemoryLimit() const
{
return 20 * 1024 * 1024;
}
-///////////////////////////////////////////////////////////////////////////////
+
extern Platform & GetPlatform()
{
+ // We need this derive class because Platform::Platform for desktop
+ // has special initialization in every platform.
class PlatformQt : public Platform
{
public: