forked from organicmaps/organicmaps
turned on Screen rotation in TilingRenderPolicyMT.
This commit is contained in:
parent
c08a25cd6a
commit
15d30304a1
12 changed files with 66 additions and 15 deletions
|
@ -105,6 +105,8 @@ Framework<TModel>::Framework(shared_ptr<WindowHandle> windowHandle,
|
|||
SetRenderPolicy(make_shared_ptr(new RenderPolicyMT(windowHandle, bind(&this_type::DrawModel, this, _1, _2, _3, _4, _5, false))));
|
||||
#endif
|
||||
|
||||
m_navigator.SetSupportRotation(m_renderPolicy->DoSupportRotation());
|
||||
|
||||
m_informationDisplay.setBottomShift(bottomShift);
|
||||
|
||||
#ifdef DRAW_TOUCH_POINTS
|
||||
|
|
|
@ -21,16 +21,18 @@
|
|||
Navigator::Navigator()
|
||||
: m_worldRect(MercatorBounds::minX, MercatorBounds::minY, MercatorBounds::maxX, MercatorBounds::maxY),
|
||||
m_InAction(false),
|
||||
m_orientation(EOrientation0)
|
||||
m_orientation(EOrientation0),
|
||||
m_doSupportRotation(false)
|
||||
{
|
||||
}
|
||||
|
||||
Navigator::Navigator(ScreenBase const & screen)
|
||||
: m_worldRect(MercatorBounds::minX, MercatorBounds::minY, MercatorBounds::maxX, MercatorBounds::maxY),
|
||||
m_StartScreen(screen),
|
||||
m_Screen(screen),
|
||||
m_InAction(false),
|
||||
m_orientation(EOrientation0)
|
||||
m_StartScreen(screen),
|
||||
m_Screen(screen),
|
||||
m_InAction(false),
|
||||
m_orientation(EOrientation0),
|
||||
m_doSupportRotation(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -103,6 +105,10 @@ bool Navigator::CanShrinkInto(ScreenBase const & screen, m2::RectD const & bound
|
|||
ScreenBase const Navigator::ShrinkInto(ScreenBase const & screen, m2::RectD const & boundRect)
|
||||
{
|
||||
ScreenBase res = screen;
|
||||
|
||||
if (m_doSupportRotation)
|
||||
return res;
|
||||
|
||||
m2::RectD globalRect = res.ClipRect();
|
||||
if (globalRect.minX() < boundRect.minX())
|
||||
globalRect.Offset(boundRect.minX() - globalRect.minX(), 0);
|
||||
|
@ -119,6 +125,10 @@ ScreenBase const Navigator::ShrinkInto(ScreenBase const & screen, m2::RectD cons
|
|||
ScreenBase const Navigator::ScaleInto(ScreenBase const & screen, m2::RectD const & boundRect)
|
||||
{
|
||||
ScreenBase res = screen;
|
||||
|
||||
if (m_doSupportRotation)
|
||||
return res;
|
||||
|
||||
m2::RectD globalRect = res.ClipRect();
|
||||
|
||||
if (globalRect.minX() < boundRect.minX())
|
||||
|
@ -137,6 +147,10 @@ ScreenBase const Navigator::ScaleInto(ScreenBase const & screen, m2::RectD const
|
|||
ScreenBase const Navigator::ShrinkAndScaleInto(ScreenBase const & screen, m2::RectD const & boundRect)
|
||||
{
|
||||
ScreenBase res = screen;
|
||||
|
||||
if (m_doSupportRotation)
|
||||
return res;
|
||||
|
||||
m2::RectD globalRect = res.ClipRect();
|
||||
|
||||
if (globalRect.minX() < boundRect.minX())
|
||||
|
@ -331,7 +345,8 @@ bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2,
|
|||
|
||||
ScreenBase tmp = m_Screen;
|
||||
tmp.SetGtoPMatrix(newM);
|
||||
tmp.Rotate(-tmp.GetAngle());
|
||||
if (!m_doSupportRotation)
|
||||
tmp.Rotate(-tmp.GetAngle());
|
||||
|
||||
if (!skipMaxScaleAndBordersCheck && !CheckMaxScale(tmp))
|
||||
return false;
|
||||
|
@ -441,3 +456,8 @@ m2::PointD const Navigator::OrientPoint(m2::PointD const & pt) const
|
|||
return ptShift;
|
||||
}
|
||||
|
||||
void Navigator::SetSupportRotation(bool flag)
|
||||
{
|
||||
m_doSupportRotation = flag;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
// Do appropriate coordinate axes swapping according to orientation
|
||||
m2::PointD const OrientPoint(m2::PointD const & pt) const;
|
||||
|
||||
void SetSupportRotation(bool flag);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -102,6 +103,8 @@ private:
|
|||
bool m_InAction;
|
||||
// Device orientation
|
||||
EOrientation m_orientation;
|
||||
// Does Navigator supports screen rotation.
|
||||
bool m_doSupportRotation;
|
||||
// Used in DoScale and ScaleByPoint
|
||||
bool ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, m2::PointD const & oldPt1, m2::PointD const & oldPt2, bool skipMaxScaleAndBordersCheck);
|
||||
};
|
||||
|
|
|
@ -3,10 +3,13 @@
|
|||
#include "render_policy.hpp"
|
||||
#include "window_handle.hpp"
|
||||
|
||||
RenderPolicy::RenderPolicy(shared_ptr<WindowHandle> const & windowHandle, TRenderFn const & renderFn)
|
||||
RenderPolicy::RenderPolicy(shared_ptr<WindowHandle> const & windowHandle,
|
||||
TRenderFn const & renderFn,
|
||||
bool doSupportRotation)
|
||||
: m_bgColor(0xEE, 0xEE, 0xDD, 0xFF),
|
||||
m_windowHandle(windowHandle),
|
||||
m_renderFn(renderFn)
|
||||
m_renderFn(renderFn),
|
||||
m_doSupportRotation(doSupportRotation)
|
||||
{}
|
||||
|
||||
yg::Color const & RenderPolicy::bgColor() const
|
||||
|
@ -90,3 +93,8 @@ void RenderPolicy::BeginFrame(shared_ptr<PaintEvent> const & e, ScreenBase const
|
|||
|
||||
void RenderPolicy::EndFrame(shared_ptr<PaintEvent> const & e, ScreenBase const & s)
|
||||
{}
|
||||
|
||||
bool RenderPolicy::DoSupportRotation() const
|
||||
{
|
||||
return m_doSupportRotation;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ private:
|
|||
shared_ptr<yg::ResourceManager> m_resourceManager;
|
||||
shared_ptr<WindowHandle> m_windowHandle;
|
||||
TRenderFn m_renderFn;
|
||||
bool m_doSupportRotation;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -45,7 +46,7 @@ protected:
|
|||
public:
|
||||
|
||||
/// constructor
|
||||
RenderPolicy(shared_ptr<WindowHandle> const & windowHandle, TRenderFn const & renderFn);
|
||||
RenderPolicy(shared_ptr<WindowHandle> const & windowHandle, TRenderFn const & renderFn, bool doSupportRotation);
|
||||
virtual ~RenderPolicy() {}
|
||||
/// starting frame
|
||||
virtual void BeginFrame(shared_ptr<PaintEvent> const & e, ScreenBase const & s);
|
||||
|
@ -73,4 +74,6 @@ public:
|
|||
virtual void DoRotate(double a, double timeInSec);
|
||||
virtual void StopRotate(double a, double timeInSec);
|
||||
/// @}
|
||||
|
||||
bool DoSupportRotation() const;
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
RenderPolicyMT::RenderPolicyMT(shared_ptr<WindowHandle> const & wh,
|
||||
RenderPolicy::TRenderFn const & renderFn)
|
||||
: RenderPolicy(wh, renderFn),
|
||||
: RenderPolicy(wh, renderFn, false),
|
||||
m_renderQueue(GetPlatform().SkinName(),
|
||||
false,
|
||||
true,
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
RenderPolicyST::RenderPolicyST(shared_ptr<WindowHandle> const & wh,
|
||||
RenderPolicy::TRenderFn const & renderFn)
|
||||
: RenderPolicy(wh, renderFn)
|
||||
: RenderPolicy(wh, renderFn, false)
|
||||
{}
|
||||
|
||||
void RenderPolicyST::Initialize(shared_ptr<yg::gl::RenderContext> const & rc,
|
||||
|
|
|
@ -119,7 +119,7 @@ bool LessRectInfo::operator()(Tile const * l, Tile const * r) const
|
|||
return l->m_rectInfo.toUInt64Cell() < r->m_rectInfo.toUInt64Cell();
|
||||
}
|
||||
|
||||
void ScreenCoverage::SetScreen(ScreenBase const & screen, bool /*mergePathNames*/)
|
||||
void ScreenCoverage::SetScreen(ScreenBase const & screen)
|
||||
{
|
||||
m_screen = screen;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
/// remove tile from coverage
|
||||
void Remove(Tile const * tile);
|
||||
/// recalculate screen coverage, using as much info from prev coverage as possible
|
||||
void SetScreen(ScreenBase const & screen, bool mergePathNames = true);
|
||||
void SetScreen(ScreenBase const & screen);
|
||||
/// draw screen coverage
|
||||
void Draw(yg::gl::Screen * s, ScreenBase const & currentScreen);
|
||||
void EndFrame(yg::gl::Screen * s);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
TilingRenderPolicyMT::TilingRenderPolicyMT(shared_ptr<WindowHandle> const & windowHandle,
|
||||
RenderPolicy::TRenderFn const & renderFn)
|
||||
: RenderPolicy(windowHandle, renderFn),
|
||||
: RenderPolicy(windowHandle, renderFn, true),
|
||||
m_tileRenderer(GetPlatform().SkinName(),
|
||||
GetPlatform().MaxTilesCount(),
|
||||
1, //GetPlatform().CpuCores(),
|
||||
|
@ -72,3 +72,13 @@ TileRenderer & TilingRenderPolicyMT::GetTileRenderer()
|
|||
{
|
||||
return m_tileRenderer;
|
||||
}
|
||||
|
||||
void TilingRenderPolicyMT::StartScale(m2::PointD const & pt1, m2::PointD const & pt2, double timeInSec)
|
||||
{
|
||||
m_isScaling = true;
|
||||
}
|
||||
|
||||
void TilingRenderPolicyMT::StopScale(m2::PointD const & pt1, m2::PointD const & pt2, double timeInSec)
|
||||
{
|
||||
m_isScaling = false;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ private:
|
|||
|
||||
ScreenBase m_currentScreen;
|
||||
|
||||
bool m_isScaling;
|
||||
|
||||
// ScreenCoverage m_screenCoverage;
|
||||
|
||||
protected:
|
||||
|
@ -46,4 +48,7 @@ public:
|
|||
void BeginFrame(shared_ptr<PaintEvent> const & ev, ScreenBase const & s);
|
||||
void DrawFrame(shared_ptr<PaintEvent> const & ev, ScreenBase const & s);
|
||||
void EndFrame(shared_ptr<PaintEvent> const & ev, ScreenBase const & s);
|
||||
|
||||
void StartScale(m2::PointD const & pt1, m2::PointD const & pt2, double timeInSec);
|
||||
void StopScale(m2::PointD const & pt1, m2::PointD const & pt2, double timeInSec);
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
TilingRenderPolicyST::TilingRenderPolicyST(shared_ptr<WindowHandle> const & windowHandle,
|
||||
RenderPolicy::TRenderFn const & renderFn)
|
||||
: RenderPolicy(windowHandle, renderFn),
|
||||
: RenderPolicy(windowHandle, renderFn, false),
|
||||
m_tileCache(GetPlatform().MaxTilesCount() - 1),
|
||||
m_tiler(GetPlatform().TileSize(), GetPlatform().ScaleEtalonSize())
|
||||
{}
|
||||
|
|
Loading…
Add table
Reference in a new issue