Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drape/overlay_handle.cpp9
-rw-r--r--drape/overlay_handle.hpp6
-rw-r--r--drape/overlay_tree.cpp40
3 files changed, 37 insertions, 18 deletions
diff --git a/drape/overlay_handle.cpp b/drape/overlay_handle.cpp
index 69d10c9f5f..5dbf714287 100644
--- a/drape/overlay_handle.cpp
+++ b/drape/overlay_handle.cpp
@@ -37,6 +37,8 @@ bool OverlayHandle::IsVisible() const
void OverlayHandle::SetIsVisible(bool isVisible)
{
m_isVisible = isVisible;
+ if (m_isVisible && IsMinVisibilityTimeUp())
+ m_visibilityTimestamp = steady_clock::now();
}
m2::PointD OverlayHandle::GetPivot(ScreenBase const & screen) const
@@ -136,6 +138,13 @@ void OverlayHandle::GetExtendedPixelShape(ScreenBase const & screen, Rects & rec
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;
+}
+
SquareHandle::SquareHandle(FeatureID const & id, dp::Anchor anchor,
m2::PointD const & gbPivot, m2::PointD const & pxSize,
uint64_t priority)
diff --git a/drape/overlay_handle.hpp b/drape/overlay_handle.hpp
index d6aed64b57..ad17da2a7e 100644
--- a/drape/overlay_handle.hpp
+++ b/drape/overlay_handle.hpp
@@ -14,6 +14,8 @@
#include "base/buffer_vector.hpp"
+#include "std/chrono.hpp"
+
namespace dp
{
@@ -76,6 +78,8 @@ public:
int GetOverlayRank() const { return m_overlayRank; }
void SetOverlayRank(int overlayRank) { m_overlayRank = overlayRank; }
+ bool IsMinVisibilityTimeUp() const;
+
protected:
FeatureID const m_id;
dp::Anchor const m_anchor;
@@ -84,6 +88,8 @@ protected:
int m_overlayRank;
double m_extendingSize;
+ steady_clock::time_point m_visibilityTimestamp;
+
typedef pair<BindingInfo, MutateRegion> TOffsetNode;
TOffsetNode const & GetOffsetNode(uint8_t bufferID) const;
diff --git a/drape/overlay_tree.cpp b/drape/overlay_tree.cpp
index c3ecc9174a..94b497a2cf 100644
--- a/drape/overlay_tree.cpp
+++ b/drape/overlay_tree.cpp
@@ -126,26 +126,30 @@ void OverlayTree::InsertHandle(ref_ptr<OverlayHandle> handle, bool isTransparent
elements.push_back(info);
});
- bool const boundToParent = (parentOverlay.m_handle != nullptr && handle->IsBound());
-
- // If handle is bound to its parent, parent's handle will be used.
- ref_ptr<OverlayHandle> handleToCompare = handle;
- if (boundToParent)
- handleToCompare = parentOverlay.m_handle;
-
- // In this loop we decide which element must be visible.
- // If input element "handle" more priority than all "Intersected elements"
- // than we remove all "Intersected elements" and insert input element "handle".
- // But if some of already inserted elements more priority than we don't insert "handle".
- HandleComparator comparator;
- for (auto const & info : elements)
+ if (handle->IsMinVisibilityTimeUp())
{
- if (comparator.IsGreater(info.m_handle, handleToCompare))
+ bool const boundToParent = (parentOverlay.m_handle != nullptr && handle->IsBound());
+
+ // If handle is bound to its parent, parent's handle will be used.
+ ref_ptr<OverlayHandle> handleToCompare = handle;
+ if (boundToParent)
+ handleToCompare = parentOverlay.m_handle;
+
+ // In this loop we decide which element must be visible.
+ // If input element "handle" more priority than all "Intersected elements"
+ // than we remove all "Intersected elements" and insert input element "handle".
+ // But if some of already inserted elements more priority than we don't insert "handle".
+ HandleComparator comparator;
+ for (auto const & info : elements)
{
- // Handle is displaced and bound to its parent, parent will be displaced too.
- if (boundToParent)
- Erase(parentOverlay);
- return;
+ bool const timeReject = !info.m_handle->IsMinVisibilityTimeUp();
+ if (timeReject || comparator.IsGreater(info.m_handle, handleToCompare))
+ {
+ // Handle is displaced and bound to its parent, parent will be displaced too.
+ if (boundToParent)
+ Erase(parentOverlay);
+ return;
+ }
}
}