diff --git a/drape/batcher.cpp b/drape/batcher.cpp index ab333bfd54..5f4e38c0cc 100644 --- a/drape/batcher.cpp +++ b/drape/batcher.cpp @@ -4,7 +4,6 @@ #include "drape/glextensions_list.hpp" #include "drape/index_storage.hpp" #include "drape/vertex_array_buffer.hpp" -#include "drape/shader_def.hpp" #include "base/assert.hpp" #include "base/stl_add.hpp" @@ -216,8 +215,7 @@ template IndicesRange Batcher::InsertTriangles(GLState const & state, ref_ptr params, drape_ptr && transferHandle, uint8_t vertexStride) { - ref_ptr bucket = GetBucket(state); - ref_ptr vao = bucket->GetBuffer(); + ref_ptr vao = GetBucket(state)->GetBuffer(); IndicesRange range; drape_ptr handle = move(transferHandle); diff --git a/drape/index_storage.cpp b/drape/index_storage.cpp index ed4a789f73..6a217ff7b4 100644 --- a/drape/index_storage.cpp +++ b/drape/index_storage.cpp @@ -56,8 +56,9 @@ void const * IndexStorage::GetRawConst() const bool IndexStorage::IsSupported32bit() { - static bool const supports32bit = false;//GLExtensionsList::Instance().IsSupported(GLExtensionsList::UintIndices); - return supports32bit; + // We do not use 32-bit indices now to reduce size of index buffers. + static bool const supports32Bit = false;//GLExtensionsList::Instance().IsSupported(GLExtensionsList::UintIndices); + return supports32Bit; } uint32_t IndexStorage::SizeOfIndex() diff --git a/drape_frontend/engine_context.cpp b/drape_frontend/engine_context.cpp index d7ac6a83d6..7cefcd6959 100644 --- a/drape_frontend/engine_context.cpp +++ b/drape_frontend/engine_context.cpp @@ -24,7 +24,7 @@ void EngineContext::BeginReadTile() PostMessage(make_unique_dp(m_tileKey)); } -void EngineContext::Flush(vector> && shapes) +void EngineContext::Flush(TMapShapes && shapes) { PostMessage(make_unique_dp(m_tileKey, move(shapes))); } diff --git a/drape_frontend/engine_context.hpp b/drape_frontend/engine_context.hpp index f8a3bb209f..e9330f1892 100644 --- a/drape_frontend/engine_context.hpp +++ b/drape_frontend/engine_context.hpp @@ -27,7 +27,7 @@ public: ref_ptr GetTextureManager() const; void BeginReadTile(); - void Flush(vector> && shapes); + void Flush(TMapShapes && shapes); void EndReadTile(); private: diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index e8e12e71fa..4bc9129574 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -869,8 +869,8 @@ void FrontendRenderer::Routine::Do() } else { - double availableTime = max(VSyncInterval - timer.ElapsedSeconds(), 0.01); - while (availableTime > 0) + double availableTime = VSyncInterval - timer.ElapsedSeconds(); + do { if (!m_renderer.ProcessSingleMessage(false /* waitForMessage */)) break; @@ -878,6 +878,7 @@ void FrontendRenderer::Routine::Do() activityTimer.Reset(); availableTime = VSyncInterval - timer.ElapsedSeconds(); } + while (availableTime > 0); } context->present(); diff --git a/drape_frontend/line_shape.cpp b/drape_frontend/line_shape.cpp index 3671f44229..f6c8a53257 100644 --- a/drape_frontend/line_shape.cpp +++ b/drape_frontend/line_shape.cpp @@ -410,7 +410,7 @@ template void LineShape::Construct(TBuilder & builder) const { vector const & path = m_spline->GetPath(); - ASSERT(path.size() > 1, ()); + ASSERT_GREATER(path.size(), 1, ()); // skip joins generation float const kJoinsGenerationThreshold = 2.5f; @@ -473,7 +473,7 @@ template <> void LineShape::Construct(SolidLineBuilder & builder) const { vector const & path = m_spline->GetPath(); - ASSERT(path.size() > 1, ()); + ASSERT_GREATER(path.size(), 1, ()); // skip joins generation float const kJoinsGenerationThreshold = 2.5f; @@ -524,7 +524,7 @@ void LineShape::Prepare(ref_ptr textures) const textures->GetColorRegion(m_params.m_color, colorRegion); float const pxHalfWidth = m_params.m_width / 2.0f; - auto commonParamsFiller = [&](BaseBuilderParams & p) + auto commonParamsBuilder = [&](BaseBuilderParams & p) { p.m_cap = m_params.m_cap; p.m_color = colorRegion; @@ -536,7 +536,7 @@ void LineShape::Prepare(ref_ptr textures) const if (m_params.m_pattern.empty()) { SolidLineBuilder::BuilderParams p; - commonParamsFiller(p); + commonParamsBuilder(p); auto builder = make_unique(p, m_spline->GetPath().size()); Construct(*builder); @@ -548,7 +548,7 @@ void LineShape::Prepare(ref_ptr textures) const textures->GetStippleRegion(m_params.m_pattern, maskRegion); DashedLineBuilder::BuilderParams p; - commonParamsFiller(p); + commonParamsBuilder(p); p.m_stipple = maskRegion; p.m_baseGtoP = m_params.m_baseGtoPScale; p.m_glbHalfWidth = pxHalfWidth / m_params.m_baseGtoPScale; diff --git a/drape_frontend/line_shape_helper.cpp b/drape_frontend/line_shape_helper.cpp index 5e27478239..37fad390b3 100644 --- a/drape_frontend/line_shape_helper.cpp +++ b/drape_frontend/line_shape_helper.cpp @@ -76,7 +76,7 @@ void UpdateNormalBetweenSegments(LineSegment * segment1, LineSegment * segment2) } } -} +} // namespace void CalculateTangentAndNormals(glsl::vec2 const & pt0, glsl::vec2 const & pt1, glsl::vec2 & tangent, glsl::vec2 & leftNormal, diff --git a/drape_frontend/map_shape.hpp b/drape_frontend/map_shape.hpp index b776828893..813f3ad8b0 100644 --- a/drape_frontend/map_shape.hpp +++ b/drape_frontend/map_shape.hpp @@ -33,11 +33,11 @@ public: virtual MapShapePriority GetPriority() const { return MapShapePriority::AreaPriority; } }; +using TMapShapes = vector>; + class MapShapeReadedMessage : public Message { public: - using TMapShapes = vector>; - MapShapeReadedMessage(TileKey const & key, TMapShapes && shapes) : m_key(key), m_shapes(move(shapes)) {} diff --git a/drape_frontend/message_queue.cpp b/drape_frontend/message_queue.cpp index edbbe7d3a5..6b22769287 100644 --- a/drape_frontend/message_queue.cpp +++ b/drape_frontend/message_queue.cpp @@ -15,7 +15,7 @@ MessageQueue::MessageQueue() MessageQueue::~MessageQueue() { - CancelWait(); + CancelWaitImpl(); ClearQuery(); } @@ -57,7 +57,7 @@ void MessageQueue::PushMessage(drape_ptr && message, MessagePriority pr ASSERT(false, ("Unknown message priority type")); } - CancelWait(); + CancelWaitImpl(); } bool MessageQueue::IsEmpty() @@ -67,6 +67,12 @@ bool MessageQueue::IsEmpty() } void MessageQueue::CancelWait() +{ + lock_guard lock(m_mutex); + CancelWaitImpl(); +} + +void MessageQueue::CancelWaitImpl() { if (m_isWaiting) { diff --git a/drape_frontend/message_queue.hpp b/drape_frontend/message_queue.hpp index c1b1f8cbe1..5eef064ad6 100644 --- a/drape_frontend/message_queue.hpp +++ b/drape_frontend/message_queue.hpp @@ -27,6 +27,8 @@ public: bool IsEmpty(); private: + void CancelWaitImpl(); + mutex m_mutex; condition_variable m_condition; bool m_isWaiting; diff --git a/drape_frontend/rule_drawer.cpp b/drape_frontend/rule_drawer.cpp index 6d5b5ea4d6..72c090c7ea 100644 --- a/drape_frontend/rule_drawer.cpp +++ b/drape_frontend/rule_drawer.cpp @@ -49,17 +49,15 @@ RuleDrawer::RuleDrawer(TDrawerCallback const & fn, ref_ptr contex RuleDrawer::~RuleDrawer() { - for (size_t i = 0; i < m_mapShapes.size(); i++) + for (auto & shapes : m_mapShapes) { - if (!m_mapShapes[i].empty()) - { - for (auto const & shape : m_mapShapes[i]) - shape->Prepare(m_context->GetTextureManager()); + if (shapes.empty()) + continue; - vector> mapShapes; - mapShapes.swap(m_mapShapes[i]); - m_context->Flush(move(mapShapes)); - } + for (auto const & shape : shapes) + shape->Prepare(m_context->GetTextureManager()); + + m_context->Flush(move(shapes)); } } @@ -160,15 +158,15 @@ void RuleDrawer::operator()(FeatureType const & f) for (size_t i = 0; i < m_mapShapes.size(); i++) { - if (m_mapShapes[i].size() >= kMinFlushSizes[i]) - { - for (auto const & shape : m_mapShapes[i]) - shape->Prepare(m_context->GetTextureManager()); + if (m_mapShapes[i].size() < kMinFlushSizes[i]) + continue; - vector> mapShapes; - mapShapes.swap(m_mapShapes[i]); - m_context->Flush(move(mapShapes)); - } + for (auto const & shape : m_mapShapes[i]) + shape->Prepare(m_context->GetTextureManager()); + + TMapShapes mapShapes; + mapShapes.swap(m_mapShapes[i]); + m_context->Flush(move(mapShapes)); } } diff --git a/drape_frontend/rule_drawer.hpp b/drape_frontend/rule_drawer.hpp index 8102cec656..730d56bf61 100644 --- a/drape_frontend/rule_drawer.hpp +++ b/drape_frontend/rule_drawer.hpp @@ -1,7 +1,7 @@ #pragma once -#include "drape_frontend/tile_key.hpp" #include "drape_frontend/map_shape.hpp" +#include "drape_frontend/tile_key.hpp" #include "drape/pointers.hpp" @@ -38,7 +38,7 @@ private: double m_currentScaleGtoP; set m_coastlines; - array>, df::PrioritiesCount> m_mapShapes; + array m_mapShapes; }; } // namespace dfo