[drape] use pixel-dependent sizes

This commit is contained in:
ExMix 2014-08-01 17:01:07 +03:00 committed by Alex Zolotarev
parent c06c013ea2
commit 1d609d7c89
4 changed files with 37 additions and 11 deletions

View file

@ -16,8 +16,9 @@ DrapeEngine::DrapeEngine(dp::RefPointer<dp::OGLContextFactory> contextfactory, d
{
GLFunctions::Init();
VisualParams::Init(vs, df::CalculateTileSize(m_viewport.GetWidth(), m_viewport.GetHeight()));
m_navigator.OnSize(m_viewport.GetX0(), m_viewport.GetY0(),
m_viewport.GetWidth(), m_viewport.GetHeight());
m_navigator.LoadState();
m_navigator.OnSize(0, 0, m_viewport.GetWidth(), m_viewport.GetHeight());
m_textures.Reset(new dp::TextureManager());
dp::RefPointer<dp::TextureSetHolder> textureHolder = m_textures.GetRefPointer();
@ -52,7 +53,8 @@ void DrapeEngine::Resize(int w, int h)
return;
m_viewport.SetViewport(0, 0, w, h);
m_navigator.OnSize(0, 0, w, h);
m_navigator.OnSize(m_viewport.GetX0(), m_viewport.GetY0(),
m_viewport.GetWidth(), m_viewport.GetHeight());
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
dp::MovePointer<Message>(new ResizeMessage(m_viewport)));
}

View file

@ -116,7 +116,8 @@ void FrontendRenderer::AcceptMessage(dp::RefPointer<Message> message)
{
ResizeMessage * rszMsg = df::CastMessage<ResizeMessage>(message);
m_viewport = rszMsg->GetViewport();
m_view.OnSize(0, 0, m_viewport.GetWidth(), m_viewport.GetHeight());
m_view.OnSize(m_viewport.GetX0(), m_viewport.GetY0(),
m_viewport.GetWidth(), m_viewport.GetHeight());
RefreshProjection();
RefreshModelView();
ResolveTileKeys();

View file

@ -19,30 +19,49 @@ void Viewport::SetViewport(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h)
m_size = m2::PointU(w, h);
}
uint32_t Viewport::GetLogicX0() const
{
return m_zero.x;
}
uint32_t Viewport::GetLogicY0() const
{
return m_zero.y;
}
uint32_t Viewport::GetLogicWidth() const
{
return m_size.x;
}
uint32_t Viewport::GetLogicHeight() const
{
return m_size.y;
}
uint32_t Viewport::GetX0() const
{
return m_zero.x * m_pixelRatio;
return GetLogicX0() * m_pixelRatio;
}
uint32_t Viewport::GetY0() const
{
return m_zero.y * m_pixelRatio;
return GetLogicY0() * m_pixelRatio;
}
uint32_t Viewport::GetWidth() const
{
return m_size.x * m_pixelRatio;
return GetLogicWidth() * m_pixelRatio;
}
uint32_t Viewport::GetHeight() const
{
return m_size.y * m_pixelRatio;
return GetLogicHeight() * m_pixelRatio;
}
void Viewport::Apply() const
{
GLFunctions::glViewport(m_zero.x * m_pixelRatio, m_zero.y * m_pixelRatio,
m_size.x * m_pixelRatio, m_size.y * m_pixelRatio);
GLFunctions::glViewport(GetX0(), GetY0(), GetWidth(), GetHeight());
}
} // namespace df

View file

@ -18,12 +18,16 @@ public:
///@{ Device-independent pixels
void SetViewport(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h);
uint32_t GetLogicX0() const;
uint32_t GetLogicY0() const;
uint32_t GetLogicWidth() const;
uint32_t GetLogicHeight() const;
///@}
uint32_t GetX0() const;
uint32_t GetY0() const;
uint32_t GetWidth() const;
uint32_t GetHeight() const;
///@}
// Apply viewport to graphics pipeline
// with convert start poin and size to physical pixels
void Apply() const;