forked from organicmaps/organicmaps
fixed incorrect current scale drawing for TilingRenderPolicy
This commit is contained in:
parent
027d7de84c
commit
0ff7a0eec0
9 changed files with 65 additions and 13 deletions
|
@ -275,7 +275,15 @@ bool Framework::SetUpdatesEnabled(bool doEnable)
|
|||
return m_renderPolicy->GetWindowHandle()->setUpdatesEnabled(doEnable);
|
||||
}
|
||||
|
||||
double Framework::GetCurrentScale() const
|
||||
int Framework::GetDrawScale() const
|
||||
{
|
||||
if (m_renderPolicy)
|
||||
return m_renderPolicy->GetDrawScale(m_navigator.Screen());
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*double Framework::GetCurrentScale() const
|
||||
{
|
||||
m2::PointD textureCenter(m_navigator.Screen().PixelRect().Center());
|
||||
m2::RectD glbRect;
|
||||
|
@ -285,7 +293,7 @@ double Framework::GetCurrentScale() const
|
|||
textureCenter + m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2)),
|
||||
glbRect);
|
||||
return scales::GetScaleLevelD(glbRect);
|
||||
}
|
||||
}*/
|
||||
|
||||
RenderPolicy::TRenderFn Framework::DrawModelFn()
|
||||
{
|
||||
|
@ -348,21 +356,24 @@ void Framework::DoPaint(shared_ptr<PaintEvent> const & e)
|
|||
{
|
||||
DrawerYG * pDrawer = e->drawer();
|
||||
|
||||
e->drawer()->screen()->beginFrame();
|
||||
|
||||
m_renderPolicy->DrawFrame(e, m_navigator.Screen());
|
||||
|
||||
/// m_informationDisplay is set and drawn after the m_renderPolicy
|
||||
|
||||
m2::PointD const center = m_navigator.Screen().GlobalRect().GlobalCenter();
|
||||
|
||||
m_informationDisplay.setScreen(m_navigator.Screen());
|
||||
|
||||
m_informationDisplay.enableEmptyModelMessage(m_renderPolicy->IsEmptyModel());
|
||||
|
||||
m_informationDisplay.setDebugInfo(0/*m_renderQueue.renderState().m_duration*/, my::rounds(GetCurrentScale()));
|
||||
|
||||
m_informationDisplay.enableRuler(true/*!IsEmptyModel()*/);
|
||||
|
||||
m2::PointD const center = m_navigator.Screen().GlobalRect().GlobalCenter();
|
||||
m_informationDisplay.setDebugInfo(0/*m_renderQueue.renderState().m_duration*/,
|
||||
GetDrawScale());
|
||||
|
||||
m_informationDisplay.setCenter(m2::PointD(MercatorBounds::XToLon(center.x), MercatorBounds::YToLat(center.y)));
|
||||
|
||||
e->drawer()->screen()->beginFrame();
|
||||
|
||||
m_renderPolicy->DrawFrame(e, m_navigator.Screen());
|
||||
m_informationDisplay.enableRuler(true/*!IsEmptyModel()*/);
|
||||
|
||||
m_informationDisplay.doDraw(pDrawer);
|
||||
|
||||
|
@ -836,7 +847,7 @@ void Framework::GetFeatureTypes(m2::PointD pt, vector<string> & types) const
|
|||
m2::RectD glbR;
|
||||
m_navigator.Screen().PtoG(pixR, glbR);
|
||||
|
||||
int const scale = my::rounds(GetCurrentScale());
|
||||
int const scale = GetDrawScale();
|
||||
DoGetFeatureTypes getTypes(m_navigator.Screen().PtoG(pt),
|
||||
max(glbR.SizeX() / 2.0, glbR.SizeY() / 2.0),
|
||||
scale);
|
||||
|
|
|
@ -161,7 +161,8 @@ public:
|
|||
|
||||
bool SetUpdatesEnabled(bool doEnable);
|
||||
|
||||
double GetCurrentScale() const;
|
||||
// double GetCurrentScale() const;
|
||||
int GetDrawScale() const;
|
||||
|
||||
m2::PointD GetViewportCenter() const;
|
||||
void SetViewportCenter(m2::PointD const & pt);
|
||||
|
|
|
@ -15,8 +15,11 @@
|
|||
|
||||
#include "../yg/internal/opengl.hpp"
|
||||
|
||||
#include "../indexer/scales.hpp"
|
||||
|
||||
#include "../platform/video_timer.hpp"
|
||||
#include "../platform/settings.hpp"
|
||||
#include "../platform/platform.hpp"
|
||||
|
||||
RenderPolicy::~RenderPolicy()
|
||||
{
|
||||
|
@ -136,6 +139,18 @@ 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);
|
||||
}
|
||||
|
||||
RenderPolicy * CreateRenderPolicy(VideoTimer * videoTimer,
|
||||
bool useDefaultFB,
|
||||
yg::ResourceManager::Params const & rmParams,
|
||||
|
|
|
@ -86,6 +86,7 @@ public:
|
|||
|
||||
virtual bool NeedRedraw() const;
|
||||
virtual bool IsEmptyModel() const;
|
||||
virtual int GetDrawScale(ScreenBase const & s) const;
|
||||
|
||||
bool DoForceUpdate() const;
|
||||
void SetForceUpdate(bool flag);
|
||||
|
|
|
@ -37,6 +37,7 @@ ScreenCoverage * ScreenCoverage::Clone()
|
|||
res->m_screen = m_screen;
|
||||
res->m_coverageGenerator = m_coverageGenerator;
|
||||
res->m_tileRects = m_tileRects;
|
||||
res->m_drawScale = m_drawScale;
|
||||
|
||||
TileCache * tileCache = &m_tileRenderer->GetTileCache();
|
||||
|
||||
|
@ -143,6 +144,8 @@ void ScreenCoverage::SetScreen(ScreenBase const & screen)
|
|||
else
|
||||
CHECK(drawScale == allRects[i].m_drawScale, (drawScale, allRects[i].m_drawScale));
|
||||
|
||||
m_drawScale = drawScale;
|
||||
|
||||
for (unsigned i = 0; i < allRects.size(); ++i)
|
||||
{
|
||||
m_tileRects.insert(allRects[i]);
|
||||
|
@ -261,3 +264,8 @@ void ScreenCoverage::EndFrame(yg::gl::Screen *s)
|
|||
{
|
||||
s->clearAdditionalSkinPage();
|
||||
}
|
||||
|
||||
int ScreenCoverage::GetDrawScale() const
|
||||
{
|
||||
return m_drawScale;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ private:
|
|||
TileSet m_tiles; //< set of tiles, that are visible for the m_screen
|
||||
yg::InfoLayer m_infoLayer; //< composite infoLayers for visible tiles
|
||||
|
||||
//< scales, which are used in the tiles, drawn in the current screen.
|
||||
int m_drawScale;
|
||||
|
||||
CoverageGenerator * m_coverageGenerator;
|
||||
yg::StylesCache * m_stylesCache;
|
||||
|
||||
|
@ -71,5 +74,8 @@ public:
|
|||
void SetScreen(ScreenBase const & screen);
|
||||
/// draw screen coverage
|
||||
void Draw(yg::gl::Screen * s, ScreenBase const & currentScreen);
|
||||
/// perform end frame
|
||||
void EndFrame(yg::gl::Screen * s);
|
||||
/// get draw scale for the tiles in the current coverage
|
||||
int GetDrawScale() const;
|
||||
};
|
||||
|
|
|
@ -247,6 +247,13 @@ void TilingRenderPolicyST::DrawFrame(shared_ptr<PaintEvent> const & e, ScreenBas
|
|||
ScreenCoverage * curCvg = &m_coverageGenerator->CurrentCoverage();
|
||||
|
||||
curCvg->Draw(pDrawer->screen().get(), currentScreen);
|
||||
|
||||
m_drawScale = curCvg->GetDrawScale();
|
||||
}
|
||||
|
||||
int TilingRenderPolicyST::GetDrawScale(ScreenBase const & s) const
|
||||
{
|
||||
return m_drawScale;
|
||||
}
|
||||
|
||||
TileRenderer & TilingRenderPolicyST::GetTileRenderer()
|
||||
|
|
|
@ -37,6 +37,8 @@ private:
|
|||
bool m_isScaling;
|
||||
int m_maxTilesCount;
|
||||
|
||||
int m_drawScale;
|
||||
|
||||
protected:
|
||||
|
||||
TileRenderer & GetTileRenderer();
|
||||
|
@ -57,6 +59,7 @@ public:
|
|||
virtual void StopScale();
|
||||
|
||||
bool IsTiling() const;
|
||||
int GetDrawScale(ScreenBase const & s) const;
|
||||
|
||||
void SetRenderFn(TRenderFn renderFn);
|
||||
};
|
||||
|
|
|
@ -428,7 +428,7 @@ namespace qt
|
|||
if (m_pScale)
|
||||
{
|
||||
// don't send ScaleChanged
|
||||
m_pScale->SetPosWithBlockedSignals(m_framework->GetCurrentScale());
|
||||
m_pScale->SetPosWithBlockedSignals(m_framework->GetDrawScale());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue