From 357e37d33e223c9fa4b88fccb1dc47b1ef72d8df Mon Sep 17 00:00:00 2001 From: ExMix Date: Fri, 10 Jan 2014 12:47:48 +0300 Subject: [PATCH] [drape] correct operator Less --- drape/binding_info.cpp | 35 +++++++++++++++++++++++++++++++- drape/binding_info.hpp | 3 +++ drape/glstate.hpp | 10 +++++---- drape/uniform_value.hpp | 12 +++++++---- drape_frontend/read_mwm_task.cpp | 19 ++++++++++------- drape_frontend/read_mwm_task.hpp | 8 ++++++++ drape_frontend/tile_info.hpp | 12 ++++++++--- 7 files changed, 80 insertions(+), 19 deletions(-) diff --git a/drape/binding_info.cpp b/drape/binding_info.cpp index f80face487..65030c7613 100644 --- a/drape/binding_info.cpp +++ b/drape/binding_info.cpp @@ -23,6 +23,28 @@ namespace } } +bool BindingDecl::operator !=(const BindingDecl & other) const +{ + return m_attributeName != other.m_attributeName || + m_componentCount != other.m_componentCount || + m_componentType != other.m_componentType || + m_stride != other.m_stride || + m_offset != other.m_offset; +} + +bool BindingDecl::operator <(const BindingDecl & other) const +{ + if (m_attributeName != other.m_attributeName) + return m_attributeName < other.m_attributeName; + if (m_componentCount != other.m_componentCount) + return m_componentCount < other.m_componentCount; + if (m_componentType != other.m_componentType) + return m_componentType < other.m_componentType; + if (m_stride != other.m_stride) + return m_stride < other.m_stride; + return m_offset < other.m_offset; +} + BindingInfo::BindingInfo() { m_size = 0; @@ -73,5 +95,16 @@ uint16_t BindingInfo::GetElementSize() const bool BindingInfo::operator< (const BindingInfo & other) const { - return this < &other; + if (m_size != other.m_size) + return m_size < other.m_size; + + for (uint16_t i = 0; i < m_size; ++i) + { + BindingDecl & thisDecl = m_bindings[i]; + BindingDecl & otherDecl = other.m_bindings[i]; + if (thisDecl != otherDecl) + return thisDecl < otherDecl; + } + + return false; } diff --git a/drape/binding_info.hpp b/drape/binding_info.hpp index c9a1f8ff8f..a2b447ba0c 100644 --- a/drape/binding_info.hpp +++ b/drape/binding_info.hpp @@ -12,6 +12,9 @@ struct BindingDecl glConst m_componentType; uint8_t m_stride; uint16_t m_offset; + + bool operator != (const BindingDecl & other) const; + bool operator < (const BindingDecl & other) const; }; class BindingInfo diff --git a/drape/glstate.hpp b/drape/glstate.hpp index ecaaab7676..244c284c50 100644 --- a/drape/glstate.hpp +++ b/drape/glstate.hpp @@ -18,10 +18,12 @@ public: bool operator<(const GLState & other) const { - return m_depthLayer < other.m_depthLayer - || m_gpuProgramIndex < other.m_gpuProgramIndex - //|| m_texture < other.m_texture - || m_uniforms < other.m_uniforms; + if (m_depthLayer != other.m_depthLayer) + return m_depthLayer < other.m_depthLayer; + if (m_gpuProgramIndex != other.m_gpuProgramIndex) + return m_gpuProgramIndex < other.m_gpuProgramIndex; + + return m_uniforms < other.m_uniforms; } private: diff --git a/drape/uniform_value.hpp b/drape/uniform_value.hpp index 9796c02554..c1e626b56e 100644 --- a/drape/uniform_value.hpp +++ b/drape/uniform_value.hpp @@ -49,11 +49,15 @@ public: bool operator<(const UniformValue & other) const { + if (m_name != other.m_name) + return m_name < other.m_name; + if (m_type != other.m_type) + return m_type < other.m_type; + if (m_componentCount != other.m_componentCount) + return m_componentCount < other.m_componentCount; + size_t s = ((m_type == Int) ? sizeof(int32_t) : sizeof(float)) * m_componentCount; - return m_name < other.m_name - || m_type < other.m_type - || m_componentCount < other.m_componentCount - || memcmp(m_values.get(), other.m_values.get(), s); + return memcmp(m_values.get(), other.m_values.get(), s) < 0; } private: diff --git a/drape_frontend/read_mwm_task.cpp b/drape_frontend/read_mwm_task.cpp index dbf5aa9db0..8061a841f4 100644 --- a/drape_frontend/read_mwm_task.cpp +++ b/drape_frontend/read_mwm_task.cpp @@ -9,6 +9,7 @@ namespace df::AreaShape * CreateFakeShape1() { df::AreaShape * shape = new df::AreaShape(Extract(0xFFEEAABB)); + shape->SetDepth(0.3f); shape->AddTriangle(m2::PointF(0.0f, 0.0f), m2::PointF(1.0f, 0.0f), m2::PointF(0.0f, 1.0f)); @@ -22,11 +23,11 @@ namespace df::AreaShape * CreateFakeShape2() { df::AreaShape * shape = new df::AreaShape(Extract(0xFF66AAFF)); - shape->AddTriangle(m2::PointF(0.0f, 0.5f), + shape->AddTriangle(m2::PointF(-0.5f, 0.5f), m2::PointF(0.5f, 1.5f), - m2::PointF(0.5f, 0.0f)); + m2::PointF(0.5f, -0.5f)); - shape->AddTriangle(m2::PointF(0.5f, 0.0f), + shape->AddTriangle(m2::PointF(0.5f, -0.5f), m2::PointF(0.5f, 1.5f), m2::PointF(1.5f, 0.5f)); return shape; @@ -90,16 +91,20 @@ namespace df void ReadMWMTask::ReadTileIndex() { - m_tileInfo.m_featureInfo.push_back(FeatureInfo(FeatureID(0, 1))); - m_tileInfo.m_featureInfo.push_back(FeatureInfo(FeatureID(0, 2))); + if (m_tileInfo.m_key == TileKey(-2, -1, 3)) + m_tileInfo.m_featureInfo.push_back(FeatureInfo(FeatureID(0, 1))); + else if (m_tileInfo.m_key == TileKey(0, 1, 3)) + m_tileInfo.m_featureInfo.push_back(FeatureInfo(FeatureID(0, 2))); /// TODO read index specified by m_tileInfo(m_x & m_y & m_zoomLevel) /// TODO insert readed FeatureIDs into m_tileInfo.m_featureInfo; } void ReadMWMTask::ReadGeometry(const FeatureID & id) { - m_context.InsertShape(m_tileInfo.m_key, MovePointer(CreateFakeShape1())); - m_context.InsertShape(m_tileInfo.m_key, MovePointer(CreateFakeShape2())); + if (id == FeatureID(0, 1)) + m_context.InsertShape(m_tileInfo.m_key, MovePointer(CreateFakeShape1())); + else if (id == FeatureID(0, 2)) + m_context.InsertShape(m_tileInfo.m_key, MovePointer(CreateFakeShape2())); ///TODO read geometry ///TODO proccess geometry by styles ///foreach shape in shapes diff --git a/drape_frontend/read_mwm_task.hpp b/drape_frontend/read_mwm_task.hpp index 260378b959..c870825ba3 100644 --- a/drape_frontend/read_mwm_task.hpp +++ b/drape_frontend/read_mwm_task.hpp @@ -38,4 +38,12 @@ namespace df dbg::ObjectTracker m_objTracker; #endif }; + + struct ReadMWMTaskLess + { + bool operator()( const ReadMWMTask * l, const ReadMWMTask * r ) const + { + return l->GetTileInfo().m_key < r->GetTileInfo().m_key; + } + }; } diff --git a/drape_frontend/tile_info.hpp b/drape_frontend/tile_info.hpp index 3ec981507d..4dc06f0087 100644 --- a/drape_frontend/tile_info.hpp +++ b/drape_frontend/tile_info.hpp @@ -29,9 +29,15 @@ namespace df return m_zoomLevel < other.m_zoomLevel; if (m_y != other.m_y) return m_y < other.m_y; - if (m_x != other.m_x) - return m_x < other.m_x; - return false; + + return m_x < other.m_x; + } + + bool operator == (const TileKey & other) const + { + return m_x == other.m_x && + m_y == other.m_y && + m_zoomLevel == other.m_zoomLevel; } int m_x;