Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drape/attribute_provider.cpp12
-rw-r--r--drape/attribute_provider.hpp3
-rw-r--r--drape_frontend/rule_drawer.cpp2
-rw-r--r--drape_frontend/traffic_generator.cpp22
-rw-r--r--drape_frontend/traffic_generator.hpp5
5 files changed, 35 insertions, 9 deletions
diff --git a/drape/attribute_provider.cpp b/drape/attribute_provider.cpp
index 1271c8feb0..768bcee738 100644
--- a/drape/attribute_provider.cpp
+++ b/drape/attribute_provider.cpp
@@ -84,6 +84,18 @@ void AttributeProvider::InitStream(uint8_t streamIndex,
INIT_STREAM(streamIndex);
}
+void AttributeProvider::Reset(uint32_t vertexCount)
+{
+ m_vertexCount = vertexCount;
+}
+
+void AttributeProvider::UpdateStream(uint8_t streamIndex, ref_ptr<void> data)
+{
+ ASSERT_LESS(streamIndex, GetStreamCount(), ());
+ m_streams[streamIndex].m_data = data;
+ INIT_STREAM(streamIndex);
+}
+
#ifdef DEBUG
void AttributeProvider::CheckStreams() const
{
diff --git a/drape/attribute_provider.hpp b/drape/attribute_provider.hpp
index 05432e7484..6782358932 100644
--- a/drape/attribute_provider.hpp
+++ b/drape/attribute_provider.hpp
@@ -27,6 +27,9 @@ public:
BindingInfo const & bindingInfo,
ref_ptr<void> data);
+ void Reset(uint32_t vertexCount);
+ void UpdateStream(uint8_t streamIndex, ref_ptr<void> data);
+
private:
int32_t m_vertexCount;
diff --git a/drape_frontend/rule_drawer.cpp b/drape_frontend/rule_drawer.cpp
index f78fcb7086..32058ef6b6 100644
--- a/drape_frontend/rule_drawer.cpp
+++ b/drape_frontend/rule_drawer.cpp
@@ -69,7 +69,7 @@ void ExtractTrafficGeometry(FeatureType const & f, df::RoadClass const & roadCla
auto & segments = geometry[f.GetID().m_mwmId];
int const index = zoomLevel - 10; // 10 - the first zoom level in kAverageSegmentsCount.
- ASSERT_GREATER(index, 0, ());
+ ASSERT_GREATER_OR_EQUAL(index, 0, ());
ASSERT_LESS(index, kAverageSegmentsCount.size(), ());
segments.reserve(kAverageSegmentsCount[index]);
diff --git a/drape_frontend/traffic_generator.cpp b/drape_frontend/traffic_generator.cpp
index f6a4855197..819408bfa0 100644
--- a/drape_frontend/traffic_generator.cpp
+++ b/drape_frontend/traffic_generator.cpp
@@ -187,6 +187,12 @@ void TrafficGenerator::Init()
m_batchersPool = make_unique_dp<BatchersPool<TrafficBatcherKey, TrafficBatcherKeyComparator>>(
kBatchersCount, bind(&TrafficGenerator::FlushGeometry, this, _1, _2, _3),
kBatchSize, kBatchSize);
+
+ m_providerLines.InitStream(0 /* stream index */, GetTrafficLineStaticBindingInfo(), nullptr);
+ m_providerLines.InitStream(1 /* stream index */, GetTrafficDynamicBindingInfo(), nullptr);
+
+ m_providerTriangles.InitStream(0 /* stream index */, GetTrafficStaticBindingInfo(), nullptr);
+ m_providerTriangles.InitStream(1 /* stream index */, GetTrafficDynamicBindingInfo(), nullptr);
}
void TrafficGenerator::ClearGLDependentResources()
@@ -268,13 +274,13 @@ void TrafficGenerator::FlushSegmentsGeometry(TileKey const & tileKey, TrafficSeg
drape_ptr<dp::OverlayHandle> handle = make_unique_dp<TrafficHandle>(sid, g.m_roadClass, g.m_polyline.GetLimitRect(), uv,
staticGeometry.size());
- dp::AttributeProvider provider(2 /* stream count */, staticGeometry.size());
- provider.InitStream(0 /* stream index */, GetTrafficLineStaticBindingInfo(), make_ref(staticGeometry.data()));
- provider.InitStream(1 /* stream index */, GetTrafficDynamicBindingInfo(), make_ref(dynamicGeometry.data()));
+ m_providerLines.Reset(staticGeometry.size());
+ m_providerLines.UpdateStream(0 /* stream index */, make_ref(staticGeometry.data()));
+ m_providerLines.UpdateStream(1 /* stream index */, make_ref(dynamicGeometry.data()));
dp::GLState curLineState = lineState;
curLineState.SetLineWidth(w * df::VisualParams::Instance().GetVisualScale());
- batcher->InsertLineStrip(curLineState, make_ref(&provider), move(handle));
+ batcher->InsertLineStrip(curLineState, make_ref(&m_providerLines), move(handle));
generatedAsLine = true;
}
}
@@ -293,10 +299,10 @@ void TrafficGenerator::FlushSegmentsGeometry(TileKey const & tileKey, TrafficSeg
drape_ptr<dp::OverlayHandle> handle = make_unique_dp<TrafficHandle>(sid, g.m_roadClass, g.m_polyline.GetLimitRect(), uv,
staticGeometry.size());
- dp::AttributeProvider provider(2 /* stream count */, staticGeometry.size());
- provider.InitStream(0 /* stream index */, GetTrafficStaticBindingInfo(), make_ref(staticGeometry.data()));
- provider.InitStream(1 /* stream index */, GetTrafficDynamicBindingInfo(), make_ref(dynamicGeometry.data()));
- batcher->InsertTriangleList(state, make_ref(&provider), move(handle));
+ m_providerTriangles.Reset(staticGeometry.size());
+ m_providerTriangles.UpdateStream(0 /* stream index */, make_ref(staticGeometry.data()));
+ m_providerTriangles.UpdateStream(1 /* stream index */, make_ref(dynamicGeometry.data()));
+ batcher->InsertTriangleList(state, make_ref(&m_providerTriangles), move(handle));
}
}
}
diff --git a/drape_frontend/traffic_generator.hpp b/drape_frontend/traffic_generator.hpp
index 69c22c4e9a..ceacb32c19 100644
--- a/drape_frontend/traffic_generator.hpp
+++ b/drape_frontend/traffic_generator.hpp
@@ -169,6 +169,8 @@ public:
explicit TrafficGenerator(TFlushRenderDataFn flushFn)
: m_flushRenderDataFn(flushFn)
+ , m_providerTriangles(2 /* stream count */, 0 /* vertices count*/)
+ , m_providerLines(2 /* stream count */, 0 /* vertices count*/)
{}
void Init();
@@ -237,6 +239,9 @@ private:
drape_ptr<BatchersPool<TrafficBatcherKey, TrafficBatcherKeyComparator>> m_batchersPool;
TFlushRenderDataFn m_flushRenderDataFn;
+
+ dp::AttributeProvider m_providerTriangles;
+ dp::AttributeProvider m_providerLines;
};
} // namespace df