diff options
author | Roman Kuznetsov <r.kuznetsov@corp.mail.ru> | 2015-12-05 23:04:37 +0300 |
---|---|---|
committer | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2015-12-29 16:36:13 +0300 |
commit | 0fe2b8089a14b1e93b603a720352d42b15762fe1 (patch) | |
tree | 9a238ceaeda6987c74378195d5e2742cda5218af /drape | |
parent | da4f39eebbd9591b314ca48791f270714b59b53f (diff) |
Added minimum visibility time to overlays to reduce jittering
Diffstat (limited to 'drape')
-rw-r--r-- | drape/overlay_handle.cpp | 24 | ||||
-rw-r--r-- | drape/overlay_tree.cpp | 4 |
2 files changed, 18 insertions, 10 deletions
diff --git a/drape/overlay_handle.cpp b/drape/overlay_handle.cpp index 3c556ca9c0..26104c974c 100644 --- a/drape/overlay_handle.cpp +++ b/drape/overlay_handle.cpp @@ -5,6 +5,8 @@ namespace dp { +double const k3dAdditionalExtention = 3.0; + struct OverlayHandle::OffsetNodeFinder { public: @@ -140,22 +142,20 @@ m2::RectD OverlayHandle::GetExtendedPixelRect(ScreenBase const & screen) const { m2::RectD rect = GetPixelRect(screen, screen.isPerspective()); rect.Inflate(m_extendingSize, m_extendingSize); + if (screen.isPerspective()) + rect.Scale(k3dAdditionalExtention); return rect; } void OverlayHandle::GetExtendedPixelShape(ScreenBase const & screen, Rects & rects) const { GetPixelShape(screen, rects, screen.isPerspective()); - for (auto & rect : rects) + { rect.Inflate(m_extendingSize, m_extendingSize); -} - -bool OverlayHandle::IsMinVisibilityTimeUp() const -{ - uint32_t const kMinVisibilityTimeMs = 500; - uint32_t const t = duration_cast<milliseconds>(steady_clock::now() - m_visibilityTimestamp).count(); - return t > kMinVisibilityTimeMs; + if (screen.isPerspective()) + rect.Scale(k3dAdditionalExtention); + } } m2::RectD OverlayHandle::GetPerspectiveRect(m2::RectD const & pixelRect, ScreenBase const & screen) const @@ -186,6 +186,14 @@ m2::RectD OverlayHandle::GetPixelRectPerspective(ScreenBase const & screen) cons return GetPerspectiveRect(GetPixelRect(screen, false), screen); } +bool OverlayHandle::IsMinVisibilityTimeUp() const +{ + uint32_t const kMinVisibilityTimeMs = 500; + uint32_t const t = duration_cast<milliseconds>(steady_clock::now() - m_visibilityTimestamp).count(); + return t > kMinVisibilityTimeMs; +} + + SquareHandle::SquareHandle(FeatureID const & id, dp::Anchor anchor, m2::PointD const & gbPivot, m2::PointD const & pxSize, uint64_t priority, diff --git a/drape/overlay_tree.cpp b/drape/overlay_tree.cpp index 388db5df94..beeddddb0e 100644 --- a/drape/overlay_tree.cpp +++ b/drape/overlay_tree.cpp @@ -149,8 +149,8 @@ void OverlayTree::InsertHandle(ref_ptr<OverlayHandle> handle, for (auto const & info : elements) { bool const rejectByDepth = is3dMode ? posY > info.m_handle->GetPivot(modelView, is3dMode).y : false; - bool const timeReject = !info.m_handle->IsMinVisibilityTimeUp(); - if (timeReject || rejectByDepth || comparator.IsGreater(info.m_handle, handleToCompare)) + bool const rejectByTime = !info.m_handle->IsMinVisibilityTimeUp(); + if (rejectByDepth || rejectByTime || comparator.IsGreater(info.m_handle, handleToCompare)) { // Handle is displaced and bound to its parent, parent will be displaced too. if (boundToParent) |