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:
authorExMix <rahuba.youri@mapswithme.com>2013-09-17 18:13:39 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:02:43 +0300
commit879046aadd167c3963ec76f4b1c6e9c533267bbc (patch)
treeb1d3f59cd1833eebdb6ca527fede8eb01dadf22a /drape/attribute_provider.cpp
parent5bb03b18ebc30b14287ae101e12dd02f1fdc686c (diff)
drape basics
Diffstat (limited to 'drape/attribute_provider.cpp')
-rw-r--r--drape/attribute_provider.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/drape/attribute_provider.cpp b/drape/attribute_provider.cpp
new file mode 100644
index 0000000000..cdb2256e3c
--- /dev/null
+++ b/drape/attribute_provider.cpp
@@ -0,0 +1,92 @@
+#include "attribute_provider.hpp"
+#include "../base/assert.hpp"
+
+#ifdef DEBUG
+ #define INIT_CHECK_INFO(x) m_checkInfo = vector<bool>((vector<bool>::size_type)(x), false);
+ #define CHECK_STREAMS CheckStreams()
+ #define INIT_STREAM(x) InitStream((x))
+#else
+ #include "macros.hpp"
+ #define INIT_CHECK_INFO(x) UNUSED_VALUE((x))
+ #define CHECK_STREAMS
+ #define INIT_STREAM(x) UNUSED_VALUE((x))
+#endif
+
+AttributeProvider::AttributeProvider(uint8_t streamCount, uint16_t vertexCount)
+ : m_vertexCount(vertexCount)
+{
+ m_streams.resize(streamCount);
+ INIT_CHECK_INFO(streamCount);
+}
+
+/// interface for batcher
+bool AttributeProvider::IsDataExists() const
+{
+ CHECK_STREAMS;
+ return m_vertexCount > 0;
+}
+
+uint16_t AttributeProvider::GetVertexCount() const
+{
+ CHECK_STREAMS;
+ return m_vertexCount;
+}
+
+uint8_t AttributeProvider::GetStreamCount() const
+{
+ return m_streams.size();
+}
+
+const void * AttributeProvider::GetRawPointer(uint8_t streamIndex)
+{
+ ASSERT(streamIndex < GetStreamCount(), ("Stream index = ", streamIndex, " out of range [0 : ", GetStreamCount(), ")"));
+ CHECK_STREAMS;
+ return m_streams[streamIndex].m_data.GetRaw();
+}
+
+const BindingInfo & AttributeProvider::GetBindingInfo(uint8_t streamIndex) const
+{
+ ASSERT(streamIndex < GetStreamCount(), ("Stream index = ", streamIndex, " out of range [0 : ", GetStreamCount(), ")"));
+ CHECK_STREAMS;
+ return m_streams[streamIndex].m_binding;
+}
+
+void AttributeProvider::Advance(uint16_t vertexCount)
+{
+ assert(m_vertexCount >= vertexCount);
+ CHECK_STREAMS;
+ for (size_t i = 0; i < GetStreamCount(); ++i)
+ {
+ const BindingInfo & info = m_streams[i].m_binding;
+ uint32_t offset = vertexCount * info.GetElementSize();
+ void * rawPointer = m_streams[i].m_data.GetRaw();
+ m_streams[i].m_data = WeakPointer<void>((void *)(((uint8_t *)rawPointer) + offset));
+ }
+
+ m_vertexCount -= vertexCount;
+}
+
+void AttributeProvider::InitStream(uint8_t streamIndex,
+ const BindingInfo &bindingInfo,
+ WeakPointer<void> data)
+{
+ ASSERT(streamIndex < GetStreamCount(), ("Stream index = ", streamIndex, " out of range [0 : ", GetStreamCount(), ")"));
+ AttributeStream s;
+ s.m_binding = bindingInfo;
+ s.m_data = data;
+ m_streams[streamIndex] = s;
+ INIT_STREAM(streamIndex);
+}
+
+#ifdef DEBUG
+void AttributeProvider::CheckStreams() const
+{
+ ASSERT(std::find(m_checkInfo.begin(), m_checkInfo.end(), false) == m_checkInfo.end(),
+ ("Not all streams initialized"));
+}
+
+void AttributeProvider::InitStream(uint8_t streamIndex)
+{
+ m_checkInfo[streamIndex] = true;
+}
+#endif