Review fixes

This commit is contained in:
r.kuznetsov 2015-11-02 16:47:13 +03:00
parent f3b2c7109d
commit 2b97e95a86
12 changed files with 44 additions and 38 deletions

View file

@ -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 <typename TBatcher>
IndicesRange Batcher::InsertTriangles(GLState const & state, ref_ptr<AttributeProvider> params,
drape_ptr<OverlayHandle> && transferHandle, uint8_t vertexStride)
{
ref_ptr<RenderBucket> bucket = GetBucket(state);
ref_ptr<VertexArrayBuffer> vao = bucket->GetBuffer();
ref_ptr<VertexArrayBuffer> vao = GetBucket(state)->GetBuffer();
IndicesRange range;
drape_ptr<OverlayHandle> handle = move(transferHandle);

View file

@ -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()

View file

@ -24,7 +24,7 @@ void EngineContext::BeginReadTile()
PostMessage(make_unique_dp<TileReadStartMessage>(m_tileKey));
}
void EngineContext::Flush(vector<drape_ptr<MapShape>> && shapes)
void EngineContext::Flush(TMapShapes && shapes)
{
PostMessage(make_unique_dp<MapShapeReadedMessage>(m_tileKey, move(shapes)));
}

View file

@ -27,7 +27,7 @@ public:
ref_ptr<dp::TextureManager> GetTextureManager() const;
void BeginReadTile();
void Flush(vector<drape_ptr<MapShape>> && shapes);
void Flush(TMapShapes && shapes);
void EndReadTile();
private:

View file

@ -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();

View file

@ -410,7 +410,7 @@ template <typename TBuilder>
void LineShape::Construct(TBuilder & builder) const
{
vector<m2::PointD> 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>(SolidLineBuilder & builder) const
{
vector<m2::PointD> 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<dp::TextureManager> 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<dp::TextureManager> textures) const
if (m_params.m_pattern.empty())
{
SolidLineBuilder::BuilderParams p;
commonParamsFiller(p);
commonParamsBuilder(p);
auto builder = make_unique<SolidLineBuilder>(p, m_spline->GetPath().size());
Construct<SolidLineBuilder>(*builder);
@ -548,7 +548,7 @@ void LineShape::Prepare(ref_ptr<dp::TextureManager> 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;

View file

@ -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,

View file

@ -33,11 +33,11 @@ public:
virtual MapShapePriority GetPriority() const { return MapShapePriority::AreaPriority; }
};
using TMapShapes = vector<drape_ptr<MapShape>>;
class MapShapeReadedMessage : public Message
{
public:
using TMapShapes = vector<drape_ptr<MapShape>>;
MapShapeReadedMessage(TileKey const & key, TMapShapes && shapes)
: m_key(key), m_shapes(move(shapes))
{}

View file

@ -15,7 +15,7 @@ MessageQueue::MessageQueue()
MessageQueue::~MessageQueue()
{
CancelWait();
CancelWaitImpl();
ClearQuery();
}
@ -57,7 +57,7 @@ void MessageQueue::PushMessage(drape_ptr<Message> && 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<mutex> lock(m_mutex);
CancelWaitImpl();
}
void MessageQueue::CancelWaitImpl()
{
if (m_isWaiting)
{

View file

@ -27,6 +27,8 @@ public:
bool IsEmpty();
private:
void CancelWaitImpl();
mutex m_mutex;
condition_variable m_condition;
bool m_isWaiting;

View file

@ -49,17 +49,15 @@ RuleDrawer::RuleDrawer(TDrawerCallback const & fn, ref_ptr<EngineContext> 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<drape_ptr<MapShape>> 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<drape_ptr<MapShape>> 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));
}
}

View file

@ -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<string> m_coastlines;
array<vector<drape_ptr<MapShape>>, df::PrioritiesCount> m_mapShapes;
array<TMapShapes, df::PrioritiesCount> m_mapShapes;
};
} // namespace dfo