| 168 | } |
| 169 | |
| 170 | void OverlayTree::Add(ref_ptr<OverlayHandle> handle) |
| 171 | { |
| 172 | /// @todo Fires when deleting downloaded country ?! |
| 173 | // ASSERT(handle->GetOverlayID().IsValid(), ()); |
| 174 | ASSERT(IsNeedUpdate(), ()); |
| 175 | |
| 176 | ScreenBase const & modelView = GetModelView(); |
| 177 | |
| 178 | handle->SetIsVisible(false); |
| 179 | |
| 180 | if (m_zoomLevel < handle->GetMinVisibleScale()) |
| 181 | return; |
| 182 | |
| 183 | handle->EnableCaching(true); |
| 184 | |
| 185 | // Skip duplicates. |
| 186 | if (IsInCache(handle)) |
| 187 | return; |
| 188 | |
| 189 | // Skip not-ready handles. |
| 190 | if (!handle->Update(modelView)) |
| 191 | { |
| 192 | InvalidateOnNextFrame(); |
| 193 | handle->SetReady(false); |
| 194 | return; |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | handle->SetReady(true); |
| 199 | } |
| 200 | |
| 201 | // Clip handles which are out of screen if these handles were not displacers |
| 202 | // last time. Also clip all handles in reverse projection. |
| 203 | m2::RectD const pixelRect = handle->GetExtendedPixelRect(modelView); |
| 204 | if (modelView.IsReverseProjection3d(pixelRect.Center()) || |
| 205 | (m_displacers.find(handle) == m_displacers.end() && !m_traits.GetExtendedScreenRect().IsIntersect(pixelRect))) |
| 206 | { |
| 207 | handle->SetIsVisible(false); |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | ASSERT_GREATER_OR_EQUAL(handle->GetOverlayRank(), 0, ()); |
| 212 | size_t const rank = static_cast<size_t>(handle->GetOverlayRank()); |
| 213 | ASSERT_LESS(rank, m_handles.size(), ()); |
| 214 | m_handles[rank].emplace_back(std::move(handle)); |
| 215 | } |
| 216 | |
| 217 | void OverlayTree::InsertHandle(ref_ptr<OverlayHandle> handle, int currentRank, |
| 218 | ref_ptr<OverlayHandle> const & parentOverlay) |
no test coverage detected