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
path: root/drape
diff options
context:
space:
mode:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2016-02-04 17:52:48 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:20:42 +0300
commita5a611ed612ac95778ec03debb930c6f0b87e813 (patch)
treec08b36fbe94dd6c974ce9ab172efa7323b058564 /drape
parentf4de5841f7bbfa1773ecd824d366a8bea49515a9 (diff)
Fixed geometry flickering
Diffstat (limited to 'drape')
-rw-r--r--drape/batcher.cpp31
-rw-r--r--drape/batcher.hpp7
-rw-r--r--drape/drape_common.pri1
-rw-r--r--drape/feature_geometry_decl.hpp28
-rw-r--r--drape/render_bucket.cpp18
-rw-r--r--drape/render_bucket.hpp31
6 files changed, 116 insertions, 0 deletions
diff --git a/drape/batcher.cpp b/drape/batcher.cpp
index 5a72a6ef7c..b407e3f076 100644
--- a/drape/batcher.cpp
+++ b/drape/batcher.cpp
@@ -171,6 +171,29 @@ void Batcher::EndSession()
m_flushInterface = TFlushFn();
}
+void Batcher::StartFeatureRecord(FeatureGeometryId feature, m2::RectD const & limitRect)
+{
+ m_currentFeature = feature;
+ m_featureLimitRect = limitRect;
+
+ if (!m_currentFeature.IsValid())
+ return;
+
+ for (auto it = m_buckets.begin(); it != m_buckets.end(); ++it)
+ it->second->StartFeatureRecord(feature, limitRect);
+}
+
+void Batcher::EndFeatureRecord()
+{
+ if (!m_currentFeature.IsValid())
+ return;
+
+ m_currentFeature = FeatureGeometryId();
+
+ for (auto it = m_buckets.begin(); it != m_buckets.end(); ++it)
+ it->second->EndFeatureRecord(true);
+}
+
void Batcher::ChangeBuffer(ref_ptr<CallbacksWrapper> wrapper)
{
GLState const & state = wrapper->GetState();
@@ -189,6 +212,9 @@ ref_ptr<RenderBucket> Batcher::GetBucket(GLState const & state)
drape_ptr<VertexArrayBuffer> vao = make_unique_dp<VertexArrayBuffer>(m_indexBufferSize, m_vertexBufferSize);
drape_ptr<RenderBucket> buffer = make_unique_dp<RenderBucket>(move(vao));
ref_ptr<RenderBucket> result = make_ref(buffer);
+ if (m_currentFeature.IsValid())
+ result->StartFeatureRecord(m_currentFeature, m_featureLimitRect);
+
m_buckets.emplace(state, move(buffer));
return result;
@@ -200,6 +226,9 @@ void Batcher::FinalizeBucket(GLState const & state)
ASSERT(it != m_buckets.end(), ("Have no bucket for finalize with given state"));
drape_ptr<RenderBucket> bucket = move(it->second);
m_buckets.erase(state);
+ if (m_currentFeature.IsValid())
+ bucket->EndFeatureRecord(false);
+
bucket->GetBuffer()->Preflush();
m_flushInterface(state, move(bucket));
}
@@ -210,6 +239,8 @@ void Batcher::Flush()
for_each(m_buckets.begin(), m_buckets.end(), [this](TBuckets::value_type & bucket)
{
ASSERT(bucket.second != nullptr, ());
+ if (m_currentFeature.IsValid())
+ bucket.second->EndFeatureRecord(true);
bucket.second->GetBuffer()->Preflush();
m_flushInterface(bucket.first, move(bucket.second));
});
diff --git a/drape/batcher.hpp b/drape/batcher.hpp
index edb224fa0a..81a5142d0c 100644
--- a/drape/batcher.hpp
+++ b/drape/batcher.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "drape/attribute_provider.hpp"
+#include "drape/feature_geometry_decl.hpp"
#include "drape/glstate.hpp"
#include "drape/overlay_handle.hpp"
#include "drape/pointers.hpp"
@@ -49,6 +50,9 @@ public:
void StartSession(TFlushFn const & flusher);
void EndSession();
+ void StartFeatureRecord(FeatureGeometryId feature, m2::RectD const & limitRect);
+ void EndFeatureRecord();
+
private:
template<typename TBacher>
IndicesRange InsertTriangles(GLState const & state, ref_ptr<AttributeProvider> params,
@@ -70,6 +74,9 @@ private:
uint32_t m_indexBufferSize;
uint32_t m_vertexBufferSize;
+
+ FeatureGeometryId m_currentFeature;
+ m2::RectD m_featureLimitRect;
};
class BatcherFactory
diff --git a/drape/drape_common.pri b/drape/drape_common.pri
index 7cb8e4da16..109e217fab 100644
--- a/drape/drape_common.pri
+++ b/drape/drape_common.pri
@@ -67,6 +67,7 @@ HEADERS += \
$$DRAPE_DIR/depth_constants.hpp \
$$DRAPE_DIR/drape_global.hpp \
$$DRAPE_DIR/dynamic_texture.hpp \
+ $$DRAPE_DIR/feature_geometry_decl.hpp \
$$DRAPE_DIR/font_texture.hpp \
$$DRAPE_DIR/fribidi.hpp \
$$DRAPE_DIR/glconstants.hpp \
diff --git a/drape/feature_geometry_decl.hpp b/drape/feature_geometry_decl.hpp
new file mode 100644
index 0000000000..80745fa22e
--- /dev/null
+++ b/drape/feature_geometry_decl.hpp
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "indexer/feature_decl.hpp"
+
+namespace dp
+{
+
+struct FeatureGeometryId
+{
+ FeatureID m_featureId;
+ uint32_t m_shapeInd = 0;
+
+ FeatureGeometryId() {}
+ FeatureGeometryId(FeatureID feature, uint32_t shapeInd)
+ : m_featureId(feature)
+ , m_shapeInd(shapeInd)
+ {}
+
+ bool IsValid() const { return m_featureId.IsValid(); }
+ inline bool operator<(FeatureGeometryId const & r) const
+ {
+ if (m_featureId == r.m_featureId)
+ return m_shapeInd < r.m_shapeInd;
+ return m_featureId < r.m_featureId;
+ }
+};
+
+} // namespace dp
diff --git a/drape/render_bucket.cpp b/drape/render_bucket.cpp
index 4c8a96af45..cbd7487570 100644
--- a/drape/render_bucket.cpp
+++ b/drape/render_bucket.cpp
@@ -102,6 +102,24 @@ void RenderBucket::Render(ScreenBase const & screen)
m_buffer->Render();
}
+void RenderBucket::StartFeatureRecord(FeatureGeometryId feature, const m2::RectD & limitRect)
+{
+ m_featureInfo = feature;
+ m_featureLimitRect = limitRect;
+ m_featureStartIndex = m_buffer->GetIndexCount();
+ m_featuresRanges.insert(make_pair(feature, FeatureGeometryInfo(limitRect)));
+}
+
+void RenderBucket::EndFeatureRecord(bool featureCompleted)
+{
+ auto it = m_featuresRanges.find(m_featureInfo);
+ ASSERT(it != m_featuresRanges.end(), ());
+ it->second.m_featureCompleted = featureCompleted;
+ if (m_featureStartIndex == m_buffer->GetIndexCount())
+ m_featuresRanges.erase(it);
+ m_featureInfo = FeatureGeometryId();
+}
+
void RenderBucket::RenderDebug(ScreenBase const & screen) const
{
#ifdef RENDER_DEBUG_RECTS
diff --git a/drape/render_bucket.hpp b/drape/render_bucket.hpp
index 003a7f1743..5412989bb3 100644
--- a/drape/render_bucket.hpp
+++ b/drape/render_bucket.hpp
@@ -1,7 +1,10 @@
#pragma once
+#include "drape/feature_geometry_decl.hpp"
#include "drape/pointers.hpp"
+#include "std/function.hpp"
+
class ScreenBase;
namespace df
@@ -46,7 +49,35 @@ public:
todo(make_ref(h));
}
+ void StartFeatureRecord(FeatureGeometryId feature, m2::RectD const & limitRect);
+ void EndFeatureRecord(bool featureCompleted);
+
+ using TCheckFeaturesWaiting = function<bool(m2::RectD const &)>;
+ bool IsFeaturesWaiting(TCheckFeaturesWaiting isFeaturesWaiting)
+ {
+ for (auto const & featureRange : m_featuresRanges)
+ if (isFeaturesWaiting(featureRange.second.m_limitRect))
+ return true;
+ return false;
+ }
+
private:
+ struct FeatureGeometryInfo
+ {
+ FeatureGeometryInfo(m2::RectD const & limitRect)
+ : m_limitRect(limitRect)
+ {}
+
+ m2::RectD m_limitRect;
+ bool m_featureCompleted = true;
+ };
+ using TFeaturesRanges = map<FeatureGeometryId, FeatureGeometryInfo>;
+
+ FeatureGeometryId m_featureInfo;
+ m2::RectD m_featureLimitRect;
+ uint32_t m_featureStartIndex;
+ TFeaturesRanges m_featuresRanges;
+
vector<drape_ptr<OverlayHandle> > m_overlay;
drape_ptr<VertexArrayBuffer> m_buffer;
};