From 142dcde42583861ab2279f60c6065804ec5b7b68 Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Wed, 13 Mar 2019 12:54:48 +0300 Subject: [PATCH] Review fixes --- drape/drape_routine.hpp | 6 +- drape/metal/metal_vertex_array_buffer_impl.mm | 3 +- drape/vertex_array_buffer.cpp | 24 +++---- .../vulkan_vertex_array_buffer_impl.cpp | 3 +- drape_frontend/frontend_renderer.cpp | 2 +- drape_frontend/message_subclasses.hpp | 2 +- drape_frontend/route_renderer.cpp | 8 +-- drape_frontend/route_shape.cpp | 66 +++++++++---------- 8 files changed, 57 insertions(+), 57 deletions(-) diff --git a/drape/drape_routine.hpp b/drape/drape_routine.hpp index 5d000ec2f5..856ca88c5f 100644 --- a/drape/drape_routine.hpp +++ b/drape/drape_routine.hpp @@ -62,7 +62,7 @@ public: static ResultPtr Run(Task && t) { ResultPtr result(new Result(Instance().GetNextId())); - bool const success = Instance().m_workerThread.Push([result, t]() mutable + bool const success = Instance().m_workerThread.Push([result, t = std::move(t)]() mutable { t(); Instance().Notify(result->Finish()); @@ -78,7 +78,7 @@ public: static ResultPtr RunDelayed(base::thread_pool::delayed::ThreadPool::Duration const & duration, Task && t) { ResultPtr result(new Result(Instance().GetNextId())); - bool const success = Instance().m_workerThread.PushDelayed(duration, [result, t]() mutable + bool const success = Instance().m_workerThread.PushDelayed(duration, [result, t = std::move(t)]() mutable { t(); Instance().Notify(result->Finish()); @@ -95,7 +95,7 @@ public: static ResultPtr RunSequential(Task && t) { ResultPtr result(new Result(Instance().GetNextId())); - bool const success = Instance().m_sequentialWorkerThread.Push([result, t]() mutable + bool const success = Instance().m_sequentialWorkerThread.Push([result, t = std::move(t)]() mutable { t(); Instance().Notify(result->Finish()); diff --git a/drape/metal/metal_vertex_array_buffer_impl.mm b/drape/metal/metal_vertex_array_buffer_impl.mm index f60336e214..09abaa1876 100644 --- a/drape/metal/metal_vertex_array_buffer_impl.mm +++ b/drape/metal/metal_vertex_array_buffer_impl.mm @@ -36,8 +36,7 @@ public: void RenderRange(ref_ptr context, bool drawAsLine, IndicesRange const & range) override { - if (!m_vertexArrayBuffer->HasBuffers()) - return; + CHECK(m_vertexArrayBuffer->HasBuffers(), ()); ref_ptr metalContext = context; if (!metalContext->HasAppliedPipelineState()) diff --git a/drape/vertex_array_buffer.cpp b/drape/vertex_array_buffer.cpp index a960d7a7f9..68da68d5aa 100644 --- a/drape/vertex_array_buffer.cpp +++ b/drape/vertex_array_buffer.cpp @@ -180,7 +180,7 @@ void VertexArrayBuffer::Render(ref_ptr context, bool drawAsLine void VertexArrayBuffer::RenderRange(ref_ptr context, bool drawAsLine, IndicesRange const & range) { - if (!(m_staticBuffers.empty() && m_dynamicBuffers.empty()) && GetIndexCount() > 0) + if (HasBuffers() && GetIndexCount() > 0) { // If OES_vertex_array_object is supported than all bindings have already saved in VAO // and we need only bind VAO. @@ -202,6 +202,9 @@ void VertexArrayBuffer::Build(ref_ptr context, ref_ptrGetApiVersion(); @@ -217,11 +220,8 @@ void VertexArrayBuffer::Build(ref_ptr context, ref_ptr context, ref_ptrBuild(program)) return; @@ -411,13 +409,17 @@ void VertexArrayBuffer::ApplyMutation(ref_ptr context, bool VertexArrayBuffer::Bind() const { - CHECK(m_impl != nullptr, ()); + if (m_impl == nullptr) + return false; + return m_impl->Bind(); } void VertexArrayBuffer::Unbind() const { - CHECK(m_impl != nullptr, ()); + if (m_impl == nullptr) + return; + m_impl->Unbind(); } diff --git a/drape/vulkan/vulkan_vertex_array_buffer_impl.cpp b/drape/vulkan/vulkan_vertex_array_buffer_impl.cpp index 581ed6cb89..324ff29f99 100644 --- a/drape/vulkan/vulkan_vertex_array_buffer_impl.cpp +++ b/drape/vulkan/vulkan_vertex_array_buffer_impl.cpp @@ -53,8 +53,7 @@ public: void RenderRange(ref_ptr context, bool drawAsLine, IndicesRange const & range) override { - if (!m_vertexArrayBuffer->HasBuffers()) - return; + CHECK(m_vertexArrayBuffer->HasBuffers(), ()); ref_ptr vulkanContext = context; VkCommandBuffer commandBuffer = vulkanContext->GetCurrentRenderingCommandBuffer(); diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 5d14a9d793..8e8bd28c3c 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -646,7 +646,7 @@ void FrontendRenderer::AcceptMessage(ref_ptr message) { ref_ptr msg = message; m_routeRenderer->CacheRouteArrows(m_userEventStream.GetCurrentScreen(), - msg->GetSubrouteId(), msg->MoveBorders(), + msg->GetSubrouteId(), msg->AcceptBorders(), std::bind(&FrontendRenderer::OnCacheRouteArrows, this, _1, _2)); break; } diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index a50e9fe921..874733974f 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -572,7 +572,7 @@ public: Type GetType() const override { return Type::PrepareSubrouteArrows; } dp::DrapeID GetSubrouteId() const { return m_subrouteId; } - std::vector && MoveBorders() { return std::move(m_borders); } + std::vector && AcceptBorders() { return std::move(m_borders); } private: dp::DrapeID m_subrouteId; diff --git a/drape_frontend/route_renderer.cpp b/drape_frontend/route_renderer.cpp index 9171c3e95c..5ce4ee29c8 100644 --- a/drape_frontend/route_renderer.cpp +++ b/drape_frontend/route_renderer.cpp @@ -273,11 +273,11 @@ void RouteRenderer::PrepareRouteArrows(ScreenBase const & screen, dist = m_distanceFromBegin - subrouteInfo.m_subroute->m_baseDistance; // We run asynchronous task to calculate new positions of route arrows. - auto subrouteId = subrouteInfo.m_subrouteId; - auto screenRect = screen.ClipRect(); - auto screenScale = screen.GetScale(); + auto const subrouteId = subrouteInfo.m_subrouteId; + auto const screenRect = screen.ClipRect(); + auto const screenScale = screen.GetScale(); + auto const subrouteLength = subrouteInfo.m_length; auto subroute = subrouteInfo.m_subroute; - auto subrouteLength = subrouteInfo.m_length; dp::DrapeRoutine::RunSequential([subrouteId, screenRect, screenScale, halfWidth, subroute = std::move(subroute), subrouteLength, dist, prepareCallback]() diff --git a/drape_frontend/route_shape.cpp b/drape_frontend/route_shape.cpp index c356f165e5..847b89594a 100644 --- a/drape_frontend/route_shape.cpp +++ b/drape_frontend/route_shape.cpp @@ -128,9 +128,9 @@ void GenerateJoinsTriangles(glsl::vec3 const & pivot, std::vector co glsl::vec3 const len2 = glsl::vec3(length.x, length.y, SideByNormal(normals[3 * j + 1], isLeft)); glsl::vec3 const len3 = glsl::vec3(length.x, length.y, SideByNormal(normals[3 * j + 2], isLeft)); - joinsGeometry.emplace_back(RouteShape::RV(pivot, normals[3 * j], len1, color)); - joinsGeometry.emplace_back(RouteShape::RV(pivot, normals[3 * j + 1], len2, color)); - joinsGeometry.emplace_back(RouteShape::RV(pivot, normals[3 * j + 2], len3, color)); + joinsGeometry.emplace_back(pivot, normals[3 * j], len1, color); + joinsGeometry.emplace_back(pivot, normals[3 * j + 1], len2, color); + joinsGeometry.emplace_back(pivot, normals[3 * j + 2], len3, color); } } @@ -152,12 +152,12 @@ void GenerateArrowsTriangles(glsl::vec4 const & pivot, std::vector c size_t const trianglesCount = normals.size() / 3; for (size_t j = 0; j < trianglesCount; j++) { - joinsGeometry.emplace_back(RouteShape::AV(pivot, normals[3 * j], - normalizedUV ? GetUV(texRect, uv[3 * j]) : uv[3 * j])); - joinsGeometry.emplace_back(RouteShape::AV(pivot, normals[3 * j + 1], - normalizedUV ? GetUV(texRect, uv[3 * j + 1]) : uv[3 * j + 1])); - joinsGeometry.emplace_back(RouteShape::AV(pivot, normals[3 * j + 2], - normalizedUV ? GetUV(texRect, uv[3 * j + 2]) : uv[3 * j + 2])); + joinsGeometry.emplace_back(pivot, normals[3 * j], + normalizedUV ? GetUV(texRect, uv[3 * j]) : uv[3 * j]); + joinsGeometry.emplace_back(pivot, normals[3 * j + 1], + normalizedUV ? GetUV(texRect, uv[3 * j + 1]) : uv[3 * j + 1]); + joinsGeometry.emplace_back(pivot, normals[3 * j + 2], + normalizedUV ? GetUV(texRect, uv[3 * j + 2]) : uv[3 * j + 2]); } } @@ -238,23 +238,23 @@ void RouteShape::PrepareGeometry(std::vector const & path, m2::Point float const projRightStart = -segments[i].m_rightWidthScalar[StartPoint].y; float const projRightEnd = segments[i].m_rightWidthScalar[EndPoint].y; - geometry.emplace_back(RV(startPivot, glsl::vec2(0, 0), - glsl::vec3(startLength, 0, kCenter), segments[i].m_color)); - geometry.emplace_back(RV(startPivot, leftNormalStart, - glsl::vec3(startLength, projLeftStart, kLeftSide), segments[i].m_color)); - geometry.emplace_back(RV(endPivot, glsl::vec2(0, 0), - glsl::vec3(length, 0, kCenter), segments[i].m_color)); - geometry.emplace_back(RV(endPivot, leftNormalEnd, - glsl::vec3(length, projLeftEnd, kLeftSide), segments[i].m_color)); + geometry.emplace_back(startPivot, glsl::vec2(0, 0), + glsl::vec3(startLength, 0, kCenter), segments[i].m_color); + geometry.emplace_back(startPivot, leftNormalStart, + glsl::vec3(startLength, projLeftStart, kLeftSide), segments[i].m_color); + geometry.emplace_back(endPivot, glsl::vec2(0, 0), + glsl::vec3(length, 0, kCenter), segments[i].m_color); + geometry.emplace_back(endPivot, leftNormalEnd, + glsl::vec3(length, projLeftEnd, kLeftSide), segments[i].m_color); - geometry.emplace_back(RV(startPivot, rightNormalStart, - glsl::vec3(startLength, projRightStart, kRightSide), segments[i].m_color)); - geometry.emplace_back(RV(startPivot, glsl::vec2(0, 0), - glsl::vec3(startLength, 0, kCenter), segments[i].m_color)); - geometry.emplace_back(RV(endPivot, rightNormalEnd, - glsl::vec3(length, projRightEnd, kRightSide), segments[i].m_color)); - geometry.emplace_back(RV(endPivot, glsl::vec2(0, 0), - glsl::vec3(length, 0, kCenter), segments[i].m_color)); + geometry.emplace_back(startPivot, rightNormalStart, + glsl::vec3(startLength, projRightStart, kRightSide), segments[i].m_color); + geometry.emplace_back(startPivot, glsl::vec2(0, 0), + glsl::vec3(startLength, 0, kCenter), segments[i].m_color); + geometry.emplace_back(endPivot, rightNormalEnd, + glsl::vec3(length, projRightEnd, kRightSide), segments[i].m_color); + geometry.emplace_back(endPivot, glsl::vec2(0, 0), + glsl::vec3(length, 0, kCenter), segments[i].m_color); auto & joinsGeometry = geomBufferData.m_joinsGeometry; @@ -358,15 +358,15 @@ void RouteShape::PrepareArrowGeometry(std::vector const & path, m2:: glsl::vec2 const uvLeft = GetUV(tr, 0.5f, 0.0f); glsl::vec2 const uvRight = GetUV(tr, 0.5f, 1.0f); - geometry.emplace_back(AV(startPivot, glsl::vec2(0, 0), uvCenter)); - geometry.emplace_back(AV(startPivot, leftNormalStart, uvLeft)); - geometry.emplace_back(AV(endPivot, glsl::vec2(0, 0), uvCenter)); - geometry.emplace_back(AV(endPivot, leftNormalEnd, uvLeft)); + geometry.emplace_back(startPivot, glsl::vec2(0, 0), uvCenter); + geometry.emplace_back(startPivot, leftNormalStart, uvLeft); + geometry.emplace_back(endPivot, glsl::vec2(0, 0), uvCenter); + geometry.emplace_back(endPivot, leftNormalEnd, uvLeft); - geometry.emplace_back(AV(startPivot, rightNormalStart, uvRight)); - geometry.emplace_back(AV(startPivot, glsl::vec2(0, 0), uvCenter)); - geometry.emplace_back(AV(endPivot, rightNormalEnd, uvRight)); - geometry.emplace_back(AV(endPivot, glsl::vec2(0, 0), uvCenter)); + geometry.emplace_back(startPivot, rightNormalStart, uvRight); + geometry.emplace_back(startPivot, glsl::vec2(0, 0), uvCenter); + geometry.emplace_back(endPivot, rightNormalEnd, uvRight); + geometry.emplace_back(endPivot, glsl::vec2(0, 0), uvCenter); auto & joinsGeometry = geometryBufferData.m_joinsGeometry;