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/overlay_handle.cpp23
-rw-r--r--drape/overlay_handle.hpp13
-rw-r--r--drape_frontend/path_symbol_shape.cpp11
-rw-r--r--drape_frontend/path_text_shape.cpp11
-rw-r--r--drape_frontend/text_layout.cpp48
-rw-r--r--drape_frontend/text_layout.hpp5
-rw-r--r--drape_head/testing_engine.cpp25
7 files changed, 110 insertions, 26 deletions
diff --git a/drape/overlay_handle.cpp b/drape/overlay_handle.cpp
index 18549ce18b..f0be332c7c 100644
--- a/drape/overlay_handle.cpp
+++ b/drape/overlay_handle.cpp
@@ -44,6 +44,19 @@ void OverlayHandle::SetIsVisible(bool isVisible)
m_isVisible = isVisible;
}
+bool OverlayHandle::IsIntersect(ScreenBase const & screen, OverlayHandle & h)
+{
+ vector<m2::RectF> const & ar1 = GetPixelShape(screen);
+ vector<m2::RectF> const & ar2 = h.GetPixelShape(screen);
+
+ for (int i = 0; i < ar1.size(); ++i)
+ for (int j = 0; j < ar2.size(); ++j)
+ if (ar1[i].IsIntersect(ar2[j]))
+ return true;
+
+ return false;
+}
+
uint16_t * OverlayHandle::IndexStorage(uint16_t size)
{
m_indexes.resize(size);
@@ -61,7 +74,7 @@ void OverlayHandle::GetElementIndexes(RefPointer<IndexBufferMutator> mutator) co
mutator->AppendIndexes(&m_indexes[0], m_indexes.size());
}
-void OverlayHandle::GetAttributeMutation(RefPointer<AttributeBufferMutator> mutator) const
+void OverlayHandle::GetAttributeMutation(RefPointer<AttributeBufferMutator> mutator, const ScreenBase & screen) const
{
UNUSED_VALUE(mutator);
}
@@ -103,6 +116,7 @@ SquareHandle::SquareHandle(FeatureID const & id, dp::Anchor anchor,
: base_t(id, anchor, priority)
, m_gbPivot(gbPivot)
, m_pxHalfSize(pxSize.x / 2.0, pxSize.y / 2.0)
+ , m_bbox(1)
{
}
@@ -126,4 +140,11 @@ m2::RectD SquareHandle::GetPixelRect(ScreenBase const & screen) const
return result;
}
+vector<m2::RectF> & SquareHandle::GetPixelShape(ScreenBase const & screen)
+{
+ m2::RectD rd = GetPixelRect(screen);
+ m_bbox[0] = m2::RectF(rd.minX(), rd.minY(), rd.maxX(), rd.maxY());
+ return m_bbox;
+}
+
} // namespace dp
diff --git a/drape/overlay_handle.hpp b/drape/overlay_handle.hpp
index 4d46a6a1fa..841c77f0ba 100644
--- a/drape/overlay_handle.hpp
+++ b/drape/overlay_handle.hpp
@@ -11,6 +11,8 @@
#include "../geometry/point2d.hpp"
#include "../geometry/rect2d.hpp"
+#include "../base/buffer_vector.hpp"
+
namespace dp
{
@@ -30,10 +32,15 @@ public:
virtual void Update(ScreenBase const & /*screen*/) {}
virtual m2::RectD GetPixelRect(ScreenBase const & screen) const = 0;
+
+ virtual vector<m2::RectF> & GetPixelShape(ScreenBase const & screen) = 0;
+
+ bool IsIntersect(ScreenBase const & screen, OverlayHandle & h);
+
uint16_t * IndexStorage(uint16_t size);
size_t GetIndexCount() const;
void GetElementIndexes(RefPointer<IndexBufferMutator> mutator) const;
- virtual void GetAttributeMutation(RefPointer<AttributeBufferMutator> mutator) const;
+ virtual void GetAttributeMutation(RefPointer<AttributeBufferMutator> mutator, ScreenBase const & screen) const;
bool HasDynamicAttributes() const;
void AddDynamicAttribute(BindingInfo const & binding, uint16_t offset, uint16_t count);
@@ -80,11 +87,13 @@ public:
m2::PointD const & pxSize,
double priority);
- m2::RectD GetPixelRect(ScreenBase const & screen) const;
+ virtual m2::RectD GetPixelRect(ScreenBase const & screen) const;
+ virtual vector<m2::RectF> & GetPixelShape(ScreenBase const & screen);
private:
m2::PointD m_gbPivot;
m2::PointD m_pxHalfSize;
+ vector<m2::RectF> m_bbox;
};
} // namespace dp
diff --git a/drape_frontend/path_symbol_shape.cpp b/drape_frontend/path_symbol_shape.cpp
index 4ba14bea85..bd4313ed7e 100644
--- a/drape_frontend/path_symbol_shape.cpp
+++ b/drape_frontend/path_symbol_shape.cpp
@@ -26,7 +26,8 @@ public:
: OverlayHandle(FeatureID(), dp::Center, 0.0f),
m_params(params), m_spline(spl), m_scaleFactor(1.0f),
m_positions(maxCount * VertexPerQuad), m_maxCount(maxCount),
- m_symbolHalfWidth(hw), m_symbolHalfHeight(hh)
+ m_symbolHalfWidth(hw), m_symbolHalfHeight(hh),
+ m_bbox(1, m2::RectF(0, 0, 0, 0))
{
SetIsVisible(true);
}
@@ -58,12 +59,17 @@ public:
}
}
+ vector<m2::RectF> & GetPixelShape(ScreenBase const & screen)
+ {
+ return m_bbox;
+ }
+
virtual m2::RectD GetPixelRect(ScreenBase const & screen) const
{
return m2::RectD(0, 0, 0, 0);
}
- virtual void GetAttributeMutation(dp::RefPointer<dp::AttributeBufferMutator> mutator) const
+ virtual void GetAttributeMutation(dp::RefPointer<dp::AttributeBufferMutator> mutator, ScreenBase const & screen) const
{
TOffsetNode const & node = GetOffsetNode(PositionAttributeID);
dp::MutateNode mutateNode;
@@ -80,6 +86,7 @@ private:
int const m_maxCount;
float m_symbolHalfWidth;
float m_symbolHalfHeight;
+ vector<m2::RectF> m_bbox;
};
PathSymbolShape::PathSymbolShape(m2::SharedSpline const & spline,
diff --git a/drape_frontend/path_text_shape.cpp b/drape_frontend/path_text_shape.cpp
index 1079fdffbe..f4e7dc6a30 100644
--- a/drape_frontend/path_text_shape.cpp
+++ b/drape_frontend/path_text_shape.cpp
@@ -86,7 +86,13 @@ namespace
return f.m_pixelRect;
}
- void GetAttributeMutation(dp::RefPointer<dp::AttributeBufferMutator> mutator) const
+
+ vector<m2::RectF> & GetPixelShape(ScreenBase const & screen)
+ {
+ return m_bboxes;
+ }
+
+ void GetAttributeMutation(dp::RefPointer<dp::AttributeBufferMutator> mutator, ScreenBase const & screen) const
{
ASSERT(IsValid(), ());
uint32_t byteCount = 4 * m_layout->GetGlyphCount() * sizeof(glsl_types::vec2);
@@ -94,7 +100,7 @@ namespace
df::IntrusiveVector<glsl_types::vec2> positions(buffer, byteCount);
// m_splineOffset set offset to Center of text.
// By this we calc offset for start of text in mercator
- m_layout->LayoutPathText(m_begin, m_scalePtoG, positions, m_isForward);
+ m_layout->LayoutPathText(m_begin, m_scalePtoG, positions, m_isForward, m_bboxes, screen);
TOffsetNode const & node = GetOffsetNode(PathGlyphPositionID);
dp::MutateNode mutateNode;
@@ -119,6 +125,7 @@ namespace
m2::SharedSpline m_spline;
m2::Spline::iterator m_begin;
m2::Spline::iterator m_end;
+ mutable vector<m2::RectF> m_bboxes;
df::SharedTextLayout m_layout;
float m_scalePtoG;
diff --git a/drape_frontend/text_layout.cpp b/drape_frontend/text_layout.cpp
index bf3b3f9169..7aef6d6887 100644
--- a/drape_frontend/text_layout.cpp
+++ b/drape_frontend/text_layout.cpp
@@ -3,6 +3,7 @@
#include "../std/numeric.hpp"
#include "../std/algorithm.hpp"
#include "../std/bind.hpp"
+#include "../std/algorithm.hpp"
using glsl_types::vec4;
using glsl_types::Quad4;
@@ -30,6 +31,7 @@ public:
, m_pivot(pivot)
, m_offset(offset)
, m_size(pxSize)
+ , m_bbox(1)
{
}
@@ -39,10 +41,17 @@ public:
return m2::RectD(pivot, pivot + m_size);
}
+ vector<m2::RectF> & GetPixelShape(ScreenBase const & screen)
+ {
+ m2::RectD rd = GetPixelRect(screen);
+ m_bbox[0] = m2::RectF(rd.minX(), rd.minY(), rd.maxX(), rd.maxY());
+ return m_bbox;
+ }
private:
m2::PointD m_pivot;
m2::PointD m_offset;
m2::PointD m_size;
+ vector<m2::RectF> m_bbox;
};
namespace
@@ -102,6 +111,9 @@ dp::OverlayHandle * TextLayout::LayoutText(const FeatureID & featureID,
FillColor(fontColor, m_font.m_color);
FillColor(outlineColor, m_font.m_outlineColor);
+ float maxHeight = 0.0f;
+ float minHeight = 10000.0f;
+
float glyphOffset = 0.0;
for (size_t i = 0; i < glyphCount; ++i)
{
@@ -120,6 +132,8 @@ dp::OverlayHandle * TextLayout::LayoutText(const FeatureID & featureID,
region.GetPixelSize(size);
double const h = size.y * m_textSizeRatio;
double const w = size.x * m_textSizeRatio;
+ maxHeight = max((float)h, maxHeight);
+ minHeight = min(yOffset, minHeight);
Quad4 & position = positions[i];
position.v[0] = vec4(pivot, m2::PointF(glyphOffset + xOffset, yOffset) + pixelOffset);
@@ -129,8 +143,14 @@ dp::OverlayHandle * TextLayout::LayoutText(const FeatureID & featureID,
glyphOffset += advance;
}
- return new StraightTextHandle(featureID, pivot, m2::PointD(glyphOffset, m_font.m_size),
- pixelOffset, depth);
+ GlyphRegion const & region = m_metrics[0];
+ m2::PointU size;
+ region.GetPixelSize(size);
+ double const w = size.x * m_textSizeRatio;
+ glyphOffset += w/2.0f;
+
+ return new StraightTextHandle(featureID, pivot, m2::PointD(glyphOffset, maxHeight),
+ m2::PointF(pixelOffset.x, pixelOffset.y + minHeight), depth);
}
void TextLayout::InitPathText(float depth,
@@ -156,7 +176,9 @@ void TextLayout::InitPathText(float depth,
void TextLayout::LayoutPathText(m2::Spline::iterator const & iterator,
float const scalePtoG,
IntrusiveVector<glsl_types::vec2> & positions,
- bool isForwardDirection) const
+ bool isForwardDirection,
+ vector<m2::RectF> & rects,
+ ScreenBase const & screen) const
{
if (!isForwardDirection)
positions.SetFillDirection(df::Backward);
@@ -168,6 +190,11 @@ void TextLayout::LayoutPathText(m2::Spline::iterator const & iterator,
int32_t endIndex = isForwardDirection ? glyphCount : -1;
int32_t incSign = isForwardDirection ? 1 : -1;
+ m2::PointF accum = itr.m_dir;
+ float const koef = 0.7f;
+
+ rects.resize(GetGlyphCount());
+
for (int32_t i = startIndex; i != endIndex; i += incSign)
{
float xOffset, yOffset, advance;
@@ -176,26 +203,29 @@ void TextLayout::LayoutPathText(m2::Spline::iterator const & iterator,
advance *= scalePtoG;
ASSERT_NOT_EQUAL(advance, 0.0, ());
- m2::PointF const pos = itr.m_pos;
+ m2::PointF pos = itr.m_pos;
itr.Step(advance);
ASSERT(!itr.BeginAgain(), ());
- m2::PointF dir = itr.m_avrDir.Normalize();
+ m2::PointF dir = (itr.m_avrDir.Normalize() * koef + accum * (1.0f - koef)).Normalize();
+ accum = dir;
m2::PointF norm(-dir.y, dir.x);
- m2::PointF norm2 = norm;
dir *= halfWidth * scalePtoG;
norm *= halfHeight * scalePtoG;
- float const halfFontSize = m_textSizeRatio * scalePtoG / 2.0f;
m2::PointF const dirComponent = dir * xOffset / halfWidth;
m2::PointF const normalComponent = -norm * incSign * yOffset / halfHeight;
- m2::PointF const fontSizeComponent = norm2 * incSign * halfFontSize;
- m2::PointF const pivot = dirComponent + normalComponent + pos - fontSizeComponent;
+ m2::PointF const pivot = dirComponent + normalComponent + pos;
positions.PushBack(glsl_types::vec2(pivot - dir + norm));
positions.PushBack(glsl_types::vec2(pivot - dir - norm));
positions.PushBack(glsl_types::vec2(pivot + dir + norm));
positions.PushBack(glsl_types::vec2(pivot + dir - norm));
+
+ pos = screen.GtoP(pivot);
+ float maxDim = max(halfWidth, halfHeight);
+ m2::PointF const maxDir(maxDim, maxDim);
+ rects[i] = m2::RectF(pos - maxDir, pos + maxDir);
}
}
diff --git a/drape_frontend/text_layout.hpp b/drape_frontend/text_layout.hpp
index f3f43b39c8..8fa1888e8c 100644
--- a/drape_frontend/text_layout.hpp
+++ b/drape_frontend/text_layout.hpp
@@ -43,7 +43,9 @@ public:
void LayoutPathText(m2::Spline::iterator const & iterator,
float const scalePtoG,
IntrusiveVector<glsl_types::vec2> & positions,
- bool isForwardDirection) const;
+ bool isForwardDirection,
+ vector<m2::RectF> & rects,
+ const ScreenBase & screen) const;
uint32_t GetGlyphCount() const;
uint32_t GetTextureSet() const;
@@ -55,6 +57,7 @@ private:
float AccumulateAdvance(double const & currentValue, GlyphRegion const & reg2) const;
void InitMetric(strings::UniChar const & unicodePoint, dp::RefPointer<dp::TextureSetHolder> textures);
+public:
void GetMetrics(int32_t const index, float & xOffset, float & yOffset, float & advance,
float & halfWidth, float & halfHeight) const;
diff --git a/drape_head/testing_engine.cpp b/drape_head/testing_engine.cpp
index 92c69dcbab..54786c66db 100644
--- a/drape_head/testing_engine.cpp
+++ b/drape_head/testing_engine.cpp
@@ -131,8 +131,14 @@ public:
}
virtual m2::RectD GetPixelRect(ScreenBase const & screen) const { return m2::RectD(); }
+ vector<m2::RectF> & GetPixelShape(ScreenBase const & screen)
+ {
+ m2::RectD rd = GetPixelRect(screen);
+ m_bbox[0] = m2::RectF(rd.minX(), rd.minY(), rd.maxX(), rd.maxY());
+ return m_bbox;
+ }
- virtual void GetAttributeMutation(dp::RefPointer<dp::AttributeBufferMutator> mutator) const
+ virtual void GetAttributeMutation(dp::RefPointer<dp::AttributeBufferMutator> mutator, ScreenBase const & screen) const
{
static const my::Timer timer;
double const angle = timer.ElapsedSeconds();
@@ -152,6 +158,7 @@ public:
private:
vector<m2::PointF> m_vectors;
+ vector<m2::RectF> m_bbox;
};
class SquareShape : public MapShape
@@ -401,7 +408,7 @@ void TestingEngine::Draw()
for (size_t i = 0; i < buckets.size(); ++i)
buckets[i]->CollectOverlayHandles(MakeStackRefPointer(&tree));
for (size_t i = 0; i < buckets.size(); ++i)
- buckets[i]->Render();
+ buckets[i]->Render(m_modelView);
tree.EndOverlayPlacing();
}
@@ -446,8 +453,8 @@ void TestingEngine::DrawImpl()
LOG(LCRITICAL, (e.Msg()));
}
- for (size_t i = 0; i < shapes.size(); ++i)
- shapes[i]->Draw(m_batcher.GetRefPointer(), m_textures.GetRefPointer());
+ //for (size_t i = 0; i < shapes.size(); ++i)
+ shapes[1]->Draw(m_batcher.GetRefPointer(), m_textures.GetRefPointer());
DeleteRange(shapes, DeleteFunctor());
@@ -472,7 +479,7 @@ void TestingEngine::DrawImpl()
params.m_secondaryTextFont = auxFd;
params.m_secondaryText = "Small fix bugs";
TextShape sh1(m2::PointF(200.0f, 300.0f), params);
- sh1.Draw(m_batcher.GetRefPointer(), m_textures.GetRefPointer());
+ //sh1.Draw(m_batcher.GetRefPointer(), m_textures.GetRefPointer());
params.m_featureID = FeatureID(23, 78);
params.m_depth = -10.0f;
@@ -496,10 +503,10 @@ void TestingEngine::DrawImpl()
PathTextViewParams params3;
params3.m_depth = -10.0f;
- params3.m_text = "√2+√3=?-fghjkfghjf---_________----+";
+ params3.m_text = "√2+√3=?----+";
params3.m_textFont = params.m_primaryTextFont;
PathTextShape sh3(path, params3, 1);
- sh3.Draw(m_batcher.GetRefPointer(), m_textures.GetRefPointer());
+ //sh3.Draw(m_batcher.GetRefPointer(), m_textures.GetRefPointer());
PathSymbolViewParams params4;
params4.m_featureID = FeatureID(23, 78);
@@ -508,10 +515,10 @@ void TestingEngine::DrawImpl()
params4.m_offset = 0.0f;
params4.m_symbolName = "arrow";
PathSymbolShape sh4(path, params4, 10);
- sh4.Draw(m_batcher.GetRefPointer(), m_textures.GetRefPointer());
+ //sh4.Draw(m_batcher.GetRefPointer(), m_textures.GetRefPointer());
DummyStippleElement e(m2::PointU(100, 900));
- e.Draw(m_batcher.GetRefPointer(), m_textures.GetRefPointer());
+ //e.Draw(m_batcher.GetRefPointer(), m_textures.GetRefPointer());
}
void TestingEngine::ModelViewInit()