diff --git a/iphone/Maps/Platform/IPhonePlatform.hpp b/iphone/Maps/Platform/IPhonePlatform.hpp index 29e203a40e..0e94b121b3 100644 --- a/iphone/Maps/Platform/IPhonePlatform.hpp +++ b/iphone/Maps/Platform/IPhonePlatform.hpp @@ -18,12 +18,14 @@ public: virtual double VisualScale() const; virtual string const SkinName() const; virtual bool IsMultiSampled() const; + virtual bool DoPeriodicalUpdate() const; private: string m_skinName; double m_visualScale; NSDate * m_StartDate; bool m_isMultiSampled; + bool m_doPeriodicalUpdate; string m_resourcesPath; string m_writablePath; }; diff --git a/iphone/Maps/Platform/IPhonePlatform.mm b/iphone/Maps/Platform/IPhonePlatform.mm index d708545498..ec2830f5d4 100644 --- a/iphone/Maps/Platform/IPhonePlatform.mm +++ b/iphone/Maps/Platform/IPhonePlatform.mm @@ -31,6 +31,7 @@ IPhonePlatform::IPhonePlatform() m_visualScale = 1.0; m_skinName = "basic.skn"; m_isMultiSampled = true; + m_doPeriodicalUpdate = false; /// Calculating resolution UIDevice * device = [UIDevice currentDevice]; @@ -162,6 +163,11 @@ bool IPhonePlatform::IsMultiSampled() const return m_isMultiSampled; } +bool IPhonePlatform::DoPeriodicalUpdate() const +{ + return m_doPeriodicalUpdate; +} + Platform & GetPlatform() { static IPhonePlatform platform; diff --git a/map/framework.hpp b/map/framework.hpp index 913879c184..657c4dcfd7 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -165,7 +165,7 @@ class FrameWork public: FrameWork(shared_ptr windowHandle) : m_windowHandle(windowHandle), - m_renderQueue(GetPlatform().SkinName(), GetPlatform().IsMultiSampled()), + m_renderQueue(GetPlatform().SkinName(), GetPlatform().IsMultiSampled(), GetPlatform().DoPeriodicalUpdate()), m_isHeadingEnabled(false), m_isPositionEnabled(false), m_isRedrawEnabled(true) diff --git a/map/render_queue.cpp b/map/render_queue.cpp index bcebe0374e..97a35a459d 100644 --- a/map/render_queue.cpp +++ b/map/render_queue.cpp @@ -5,7 +5,7 @@ #include "../yg/render_state.hpp" #include "../yg/rendercontext.hpp" -RenderQueue::RenderQueue(string const & skinName, bool isMultiSampled) +RenderQueue::RenderQueue(string const & skinName, bool isMultiSampled, bool doPeriodicalUpdate) : m_renderState(new yg::gl::RenderState()) { m_renderState->m_surfaceWidth = 100; @@ -13,7 +13,7 @@ RenderQueue::RenderQueue(string const & skinName, bool isMultiSampled) m_renderState->m_textureWidth = 256; m_renderState->m_textureHeight = 256; - m_routine = new RenderQueueRoutine(m_renderState, skinName, isMultiSampled); + m_routine = new RenderQueueRoutine(m_renderState, skinName, isMultiSampled, doPeriodicalUpdate); } void RenderQueue::initializeGL(shared_ptr const & primaryContext, diff --git a/map/render_queue.hpp b/map/render_queue.hpp index 7ebbf68e8a..17761c30b2 100644 --- a/map/render_queue.hpp +++ b/map/render_queue.hpp @@ -31,7 +31,7 @@ private: public: /// constructor. - RenderQueue(string const & skinName, bool isMultiSampled); + RenderQueue(string const & skinName, bool isMultiSampled, bool doPeriodicalUpdate); /// destructor. ~RenderQueue(); /// set the primary context. it starts the rendering thread. diff --git a/map/render_queue_routine.cpp b/map/render_queue_routine.cpp index 844596debe..788d1d542d 100644 --- a/map/render_queue_routine.cpp +++ b/map/render_queue_routine.cpp @@ -31,13 +31,15 @@ RenderQueueRoutine::RenderModelCommand::RenderModelCommand(ScreenBase const & fr RenderQueueRoutine::RenderQueueRoutine(shared_ptr const & renderState, string const & skinName, - bool isMultiSampled) + bool isMultiSampled, + bool doPeriodicalUpdate) { m_skinName = skinName; m_visualScale = 0; m_renderState = renderState; m_renderState->addInvalidateFn(bind(&RenderQueueRoutine::invalidate, this)); m_isMultiSampled = isMultiSampled; + m_doPeriodicalUpdate = doPeriodicalUpdate; } void RenderQueueRoutine::Cancel() @@ -209,6 +211,8 @@ void RenderQueueRoutine::Do() params.m_isMultiSampled = m_isMultiSampled; params.m_useTextLayer = true; params.m_frameBuffer = m_frameBuffer; + params.m_renderState = m_renderState; + params.m_doPeriodicalUpdate = m_doPeriodicalUpdate; m_threadDrawer = make_shared_ptr(new DrawerYG(m_skinName, params)); CHECK(m_visualScale != 0, ("Set the VisualScale first!")); @@ -216,8 +220,6 @@ void RenderQueueRoutine::Do() m_fakeTarget = make_shared_ptr(new yg::gl::RGBA8Texture(2, 2)); - m_threadDrawer->screen()->setRenderState(m_renderState); - yg::gl::RenderState s; while (!IsCancelled()) @@ -323,6 +325,8 @@ void RenderQueueRoutine::Do() threads::MutexGuard guard(*m_renderState->m_mutex.get()); m_renderState->m_duration = duration; } + + invalidate(); } } diff --git a/map/render_queue_routine.hpp b/map/render_queue_routine.hpp index ec95c37bea..567b85ad21 100644 --- a/map/render_queue_routine.hpp +++ b/map/render_queue_routine.hpp @@ -71,13 +71,15 @@ private: list > m_windowHandles; bool m_isMultiSampled; + bool m_doPeriodicalUpdate; double m_visualScale; string m_skinName; public: RenderQueueRoutine(shared_ptr const & renderState, string const & skinName, - bool isMultiSampled); + bool isMultiSampled, + bool doPeriodicalUpdate); /// initialize GL rendering /// this function is called just before the thread starts. void initializeGL(shared_ptr const & renderContext, diff --git a/platform/platform.hpp b/platform/platform.hpp index 3f6da6100d..1c2fe3b4fc 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -64,6 +64,8 @@ public: virtual string const SkinName() const = 0; virtual bool IsMultiSampled() const = 0; + + virtual bool DoPeriodicalUpdate() const = 0; }; extern "C" Platform & GetPlatform(); diff --git a/platform/qtplatform.cpp b/platform/qtplatform.cpp index 965dd47ef4..f8d54c0b59 100644 --- a/platform/qtplatform.cpp +++ b/platform/qtplatform.cpp @@ -351,6 +351,11 @@ public: { return true; } + + bool DoPeriodicalUpdate() const + { + return false; + } }; extern "C" Platform & GetPlatform() diff --git a/yg/render_state_updater.cpp b/yg/render_state_updater.cpp index c204bc945e..08c5ef1c4c 100644 --- a/yg/render_state_updater.cpp +++ b/yg/render_state_updater.cpp @@ -7,13 +7,15 @@ namespace yg { namespace gl { - RenderStateUpdater::RenderStateUpdater(base_t::Params const & params) : base_t(params) + RenderStateUpdater::Params::Params() + : m_doPeriodicalUpdate(false) {} - void RenderStateUpdater::setRenderState(shared_ptr const & renderState) - { - m_renderState = renderState; - } + RenderStateUpdater::RenderStateUpdater(Params const & params) + : base_t(params), + m_renderState(params.m_renderState), + m_doPeriodicalUpdate(params.m_doPeriodicalUpdate) + {} shared_ptr const & RenderStateUpdater::renderState() const { @@ -27,7 +29,7 @@ namespace yg { base_t::drawGeometry(texture, vertices, indices, indicesCount); m_indicesCount += indicesCount; - if ((m_renderState) && (m_indicesCount > 20000)) + if (m_doPeriodicalUpdate && m_renderState && (m_indicesCount > 20000)) { updateActualTarget(); m_indicesCount %= 20000; diff --git a/yg/render_state_updater.hpp b/yg/render_state_updater.hpp index 4a20cc877e..3fa832c270 100644 --- a/yg/render_state_updater.hpp +++ b/yg/render_state_updater.hpp @@ -22,12 +22,19 @@ namespace yg void updateActualTarget(); int m_indicesCount; + bool m_doPeriodicalUpdate; public: - RenderStateUpdater(base_t::Params const & params); + struct Params : base_t::Params + { + bool m_doPeriodicalUpdate; + shared_ptr m_renderState; + Params(); + }; + + RenderStateUpdater(Params const & params); - void setRenderState(shared_ptr const & renderState); shared_ptr const & renderState() const; void drawGeometry(shared_ptr const & texture,