diff options
Diffstat (limited to 'drape')
-rw-r--r-- | drape/overlay_handle.cpp | 19 | ||||
-rw-r--r-- | drape/overlay_handle.hpp | 9 |
2 files changed, 15 insertions, 13 deletions
diff --git a/drape/overlay_handle.cpp b/drape/overlay_handle.cpp index f0be332c7c..d14a8e6125 100644 --- a/drape/overlay_handle.cpp +++ b/drape/overlay_handle.cpp @@ -44,13 +44,16 @@ void OverlayHandle::SetIsVisible(bool isVisible) m_isVisible = isVisible; } -bool OverlayHandle::IsIntersect(ScreenBase const & screen, OverlayHandle & h) +bool OverlayHandle::IsIntersect(ScreenBase const & screen, const OverlayHandle & h) const { - vector<m2::RectF> const & ar1 = GetPixelShape(screen); - vector<m2::RectF> const & ar2 = h.GetPixelShape(screen); + Rects ar1; + Rects ar2; - for (int i = 0; i < ar1.size(); ++i) - for (int j = 0; j < ar2.size(); ++j) + GetPixelShape(screen, ar1); + h.GetPixelShape(screen, ar2); + + for (size_t i = 0; i < ar1.size(); ++i) + for (size_t j = 0; j < ar2.size(); ++j) if (ar1[i].IsIntersect(ar2[j])) return true; @@ -116,7 +119,6 @@ SquareHandle::SquareHandle(FeatureID const & id, dp::Anchor anchor, : base_t(id, anchor, priority) , m_gbPivot(gbPivot) , m_pxHalfSize(pxSize.x / 2.0, pxSize.y / 2.0) - , m_bbox(1) { } @@ -140,11 +142,10 @@ m2::RectD SquareHandle::GetPixelRect(ScreenBase const & screen) const return result; } -vector<m2::RectF> & SquareHandle::GetPixelShape(ScreenBase const & screen) +void SquareHandle::GetPixelShape(ScreenBase const & screen, Rects & rects) const { m2::RectD rd = GetPixelRect(screen); - m_bbox[0] = m2::RectF(rd.minX(), rd.minY(), rd.maxX(), rd.maxY()); - return m_bbox; + rects.push_back(m2::RectF(rd.minX(), rd.minY(), rd.maxX(), rd.maxY())); } } // namespace dp diff --git a/drape/overlay_handle.hpp b/drape/overlay_handle.hpp index 841c77f0ba..164ec5a53d 100644 --- a/drape/overlay_handle.hpp +++ b/drape/overlay_handle.hpp @@ -19,6 +19,8 @@ namespace dp class OverlayHandle { public: + typedef vector<m2::RectF> Rects; + OverlayHandle(FeatureID const & id, dp::Anchor anchor, double priority); @@ -33,9 +35,9 @@ public: virtual void Update(ScreenBase const & /*screen*/) {} virtual m2::RectD GetPixelRect(ScreenBase const & screen) const = 0; - virtual vector<m2::RectF> & GetPixelShape(ScreenBase const & screen) = 0; + virtual void GetPixelShape(ScreenBase const & screen, Rects & rects) const = 0; - bool IsIntersect(ScreenBase const & screen, OverlayHandle & h); + bool IsIntersect(ScreenBase const & screen, OverlayHandle const & h) const; uint16_t * IndexStorage(uint16_t size); size_t GetIndexCount() const; @@ -88,12 +90,11 @@ public: double priority); virtual m2::RectD GetPixelRect(ScreenBase const & screen) const; - virtual vector<m2::RectF> & GetPixelShape(ScreenBase const & screen); + virtual void GetPixelShape(ScreenBase const & screen, Rects & rects) const; private: m2::PointD m_gbPivot; m2::PointD m_pxHalfSize; - vector<m2::RectF> m_bbox; }; } // namespace dp |