diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index c9ff838262..b045be3a38 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -255,6 +255,9 @@ typedef FrameWork frame // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; + m_framework->MemoryWarning(); + m_framework->Repaint(); + // Release any cached data, images, etc that aren't in use. } diff --git a/map/framework.hpp b/map/framework.hpp index 08fe03f646..582dee51d0 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -370,6 +370,11 @@ public: UpdateNow(); } + void MemoryWarning() + { + m_informationDisplay.memoryWarning(); + } + void CenterViewport() { m_navigator.CenterViewport(m_informationDisplay.position()); diff --git a/map/information_display.cpp b/map/information_display.cpp index dfb77dd07c..e3c954d219 100644 --- a/map/information_display.cpp +++ b/map/information_display.cpp @@ -19,6 +19,7 @@ InformationDisplay::InformationDisplay() enableRuler(false); enableCenter(false); enableDebugInfo(false); + enableMemoryWarning(false); for (int i = 0; i < sizeof(m_DebugPts) / sizeof(m2::PointD); ++i) m_DebugPts[i] = m2::PointD(0, 0); @@ -322,6 +323,39 @@ void InformationDisplay::drawDebugInfo(DrawerYG * drawer) false); } +void InformationDisplay::enableMemoryWarning(bool flag) +{ + m_isMemoryWarningEnabled = flag; +} + +void InformationDisplay::memoryWarning() +{ + enableMemoryWarning(true); + m_lastMemoryWarning = my::Timer(); +} + +void InformationDisplay::drawMemoryWarning(DrawerYG * drawer) +{ + m2::PointD pos(m_displayRect.minX() + 10, m_displayRect.minY() + 20); + if (m_isDebugInfoEnabled) + pos += m2::PointD(0, 30); + if (m_isCenterEnabled) + pos += m2::PointD(0, 30); + + ostringstream out; + out << "MemoryWarning : " << m_lastMemoryWarning.ElapsedSeconds() << " sec. ago."; + + drawer->screen()->drawText(pos, + 0, 10, + out.str().c_str(), + yg::maxDepth, + true, + false); + + if (m_lastMemoryWarning.ElapsedSeconds() > 5) + enableMemoryWarning(false); +} + void InformationDisplay::doDraw(DrawerYG *drawer) { if (m_isHeadingEnabled) @@ -336,4 +370,6 @@ void InformationDisplay::doDraw(DrawerYG *drawer) drawCenter(drawer); if (m_isDebugInfoEnabled) drawDebugInfo(drawer); + if (m_isMemoryWarningEnabled) + drawMemoryWarning(drawer); } diff --git a/map/information_display.hpp b/map/information_display.hpp index cae410eb91..868853d229 100644 --- a/map/information_display.hpp +++ b/map/information_display.hpp @@ -3,6 +3,7 @@ #include "../geometry/point2d.hpp" #include "../geometry/rect2d.hpp" #include "../geometry/screenbase.hpp" +#include "../base/timer.hpp" class DrawerYG; @@ -43,6 +44,9 @@ private: double m_bottomShift; double m_visualScale; + my::Timer m_lastMemoryWarning; + bool m_isMemoryWarningEnabled; + public: InformationDisplay(); @@ -77,5 +81,9 @@ public: void setDebugInfo(double frameDuration, int currentScale); void drawDebugInfo(DrawerYG * pDrawer); + void enableMemoryWarning(bool doEnable); + void memoryWarning(); + void drawMemoryWarning(DrawerYG * pDrawer); + void doDraw(DrawerYG * drawer); };