forked from organicmaps/organicmaps
Periodical Update made switchable.
This commit is contained in:
parent
1addc42080
commit
7dcc636771
11 changed files with 46 additions and 16 deletions
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -165,7 +165,7 @@ class FrameWork
|
|||
public:
|
||||
FrameWork(shared_ptr<window_handle_t> 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)
|
||||
|
|
|
@ -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<yg::gl::RenderContext> const & primaryContext,
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -31,13 +31,15 @@ RenderQueueRoutine::RenderModelCommand::RenderModelCommand(ScreenBase const & fr
|
|||
|
||||
RenderQueueRoutine::RenderQueueRoutine(shared_ptr<yg::gl::RenderState> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,13 +71,15 @@ private:
|
|||
list<shared_ptr<WindowHandle> > m_windowHandles;
|
||||
|
||||
bool m_isMultiSampled;
|
||||
bool m_doPeriodicalUpdate;
|
||||
double m_visualScale;
|
||||
string m_skinName;
|
||||
|
||||
public:
|
||||
RenderQueueRoutine(shared_ptr<yg::gl::RenderState> 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<yg::gl::RenderContext> const & renderContext,
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -351,6 +351,11 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DoPeriodicalUpdate() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
extern "C" Platform & GetPlatform()
|
||||
|
|
|
@ -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<RenderState> 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<RenderState> 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;
|
||||
|
|
|
@ -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<RenderState> m_renderState;
|
||||
Params();
|
||||
};
|
||||
|
||||
RenderStateUpdater(Params const & params);
|
||||
|
||||
void setRenderState(shared_ptr<RenderState> const & renderState);
|
||||
shared_ptr<RenderState> const & renderState() const;
|
||||
|
||||
void drawGeometry(shared_ptr<BaseTexture> const & texture,
|
||||
|
|
Loading…
Add table
Reference in a new issue