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>2014-11-03 14:28:50 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:27:56 +0300
commit28585566bb2eaf56915833a188015bcc98587cbb (patch)
tree935f2286436059961dff6cbb8ca74a7a5edd75cb
parent7287f1391f3c4ab1d03fa3fd5cb45f3a9d0ad11c (diff)
[drape] area shape optimization and glm integration
-rw-r--r--drape_frontend/apply_feature_functors.cpp7
-rw-r--r--drape_frontend/area_shape.cpp52
-rw-r--r--drape_frontend/area_shape.hpp10
-rw-r--r--std/utility.hpp1
4 files changed, 35 insertions, 35 deletions
diff --git a/drape_frontend/apply_feature_functors.cpp b/drape_frontend/apply_feature_functors.cpp
index 431535842a..67c8865c85 100644
--- a/drape_frontend/apply_feature_functors.cpp
+++ b/drape_frontend/apply_feature_functors.cpp
@@ -13,13 +13,15 @@
#include "../indexer/drawing_rules.hpp"
#include "../indexer/drules_include.hpp"
-#include "../std/algorithm.hpp"
#include "../drape/color.hpp"
#include "../drape/stipple_pen_resource.hpp"
#include "../graphics/defines.hpp"
+#include "../std/algorithm.hpp"
+#include "../std/utility.hpp"
+
namespace df
{
@@ -262,11 +264,12 @@ void ApplyAreaFeature::ProcessRule(Stylist::rule_wrapper_t const & rule)
AreaRuleProto const * areaRule = pRule->GetArea();
if (areaRule)
{
+ ASSERT(!m_triangles.empty(), ());
AreaViewParams params;
params.m_depth = depth;
params.m_color = ToDrapeColor(areaRule->color());
- AreaShape * shape = new AreaShape(m_triangles, params);
+ AreaShape * shape = new AreaShape(move(m_triangles), params);
m_context.InsertShape(m_tileKey, dp::MovePointer<MapShape>(shape));
}
else
diff --git a/drape_frontend/area_shape.cpp b/drape_frontend/area_shape.cpp
index e2c321f76f..d00bbda7fc 100644
--- a/drape_frontend/area_shape.cpp
+++ b/drape_frontend/area_shape.cpp
@@ -1,49 +1,47 @@
#include "area_shape.hpp"
-#include "common_structures.hpp"
+#include "../drape/glsl_types.hpp"
#include "../drape/shader_def.hpp"
+#include "../drape/glstate.hpp"
+#include "../drape/batcher.hpp"
#include "../drape/attribute_provider.hpp"
-#include "../drape/texture_of_colors.hpp"
#include "../drape/texture_set_holder.hpp"
-#include "../std/bind.hpp"
+#include "../base/buffer_vector.hpp"
+#include "../base/logging.hpp"
+
+#include "../std/algorithm.hpp"
namespace df
{
-using glsl_types::vec2;
-using glsl_types::vec3;
-using glsl_types::vec4;
-
-AreaShape::AreaShape(vector<m2::PointF> const & triangleList, AreaViewParams const & params)
- : m_params(params)
+AreaShape::AreaShape(vector<m2::PointF> && triangleList, AreaViewParams const & params)
+ : m_vertexes(triangleList)
+ , m_params(params)
{
- m_vertexes.reserve(triangleList.size());
-
-#if (__cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__)
- void (vector<Point3D>::* fn)(Point3D &&) =
-#else
- void (vector<Point3D>::* fn)(Point3D const &) =
-#endif
- &vector<Point3D>::push_back;
-
- for_each(triangleList.begin(), triangleList.end(),
- bind(fn, &m_vertexes, bind(&Point3D::From2D, _1, params.m_depth)));
}
void AreaShape::Draw(dp::RefPointer<dp::Batcher> batcher, dp::RefPointer<dp::TextureSetHolder> textures) const
{
- dp::GLState state(gpu::SOLID_AREA_PROGRAM, dp::GLState::GeometryLayer);
-
dp::ColorKey key(m_params.m_color.GetColorInInt());
dp::TextureSetHolder::ColorRegion region;
textures->GetColorRegion(key, region);
- m2::RectF const & rect = region.GetTexRect();
- float texIndex = static_cast<float>(region.GetTextureNode().m_textureOffset);
+ m2::PointF const colorPoint = region.GetTexRect().Center();
+
+ dp::TextureSetHolder::TextureNode const & texNode = region.GetTextureNode();
- vector<vec3> colors(m_vertexes.size(), vec3(rect.RightTop(), texIndex));
+ buffer_vector<glsl::vec3, 128> colors;
+ colors.resize(m_vertexes.size(), glsl::vec3(colorPoint.x, colorPoint.y, texNode.GetOffset()));
- state.SetTextureSet(region.GetTextureNode().m_textureSet);
+ buffer_vector<glsl::vec3, 128> geom;
+ colors.reserve(m_vertexes.size());
+ for_each(m_vertexes.begin(), m_vertexes.end(), [&geom, this] (m2::PointF const & vertex)
+ {
+ geom.push_back(glsl::vec3(vertex.x, vertex.y, m_params.m_depth));
+ });
+
+ dp::GLState state(gpu::SOLID_AREA_PROGRAM, dp::GLState::GeometryLayer);
+ state.SetTextureSet(texNode.m_textureSet);
dp::AttributeProvider provider(2, m_vertexes.size());
{
@@ -54,7 +52,7 @@ void AreaShape::Draw(dp::RefPointer<dp::Batcher> batcher, dp::RefPointer<dp::Tex
decl.m_componentType = gl_const::GLFloatType;
decl.m_offset = 0;
decl.m_stride = 0;
- provider.InitStream(0, info, dp::MakeStackRefPointer((void *)&m_vertexes[0]));
+ provider.InitStream(0, info, dp::MakeStackRefPointer((void *)&geom[0]));
}
{
diff --git a/drape_frontend/area_shape.hpp b/drape_frontend/area_shape.hpp
index bae7ec5a6c..202150fb1b 100644
--- a/drape_frontend/area_shape.hpp
+++ b/drape_frontend/area_shape.hpp
@@ -1,11 +1,9 @@
#pragma once
-#include "shape_view_params.hpp"
#include "map_shape.hpp"
+#include "shape_view_params.hpp"
-#include "../drape/batcher.hpp"
#include "../drape/pointers.hpp"
-#include "../drape/color.hpp"
#include "../geometry/point2d.hpp"
#include "../std/vector.hpp"
@@ -16,12 +14,12 @@ namespace df
class AreaShape : public MapShape
{
public:
- AreaShape(vector<m2::PointF> const & triangleList, AreaViewParams const & params);
+ AreaShape(vector<m2::PointF> && triangleList, AreaViewParams const & params);
- virtual void Draw(dp::RefPointer<dp::Batcher> batcher, dp::RefPointer<dp::TextureSetHolder> /*textures*/) const;
+ virtual void Draw(dp::RefPointer<dp::Batcher> batcher, dp::RefPointer<dp::TextureSetHolder> textures) const;
private:
- vector<Point3D> m_vertexes;
+ vector<m2::PointF> m_vertexes;
AreaViewParams m_params;
};
diff --git a/std/utility.hpp b/std/utility.hpp
index f258363769..0b140c2ad9 100644
--- a/std/utility.hpp
+++ b/std/utility.hpp
@@ -8,6 +8,7 @@
#include <utility>
using std::pair;
using std::make_pair;
+using std::move;
#ifdef DEBUG_NEW
#define new DEBUG_NEW