Welcome to mirror list, hosted at ThFree Co, Russian Federation.

text_layout.hpp « drape_frontend - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5079e899a05bccd5dc066fcdba9c10c83904915a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once

#include "common_structures.hpp"
#include "shape_view_params.hpp"
#include "intrusive_vector.hpp"

#include "../drape/pointers.hpp"
#include "../drape/texture_set_holder.hpp"
#include "../drape/overlay_handle.hpp"

#include "../geometry/spline.hpp"

#include "../base/string_utils.hpp"
#include "../base/buffer_vector.hpp"

#include "../std/vector.hpp"
#include "../std/shared_ptr.hpp"

namespace df
{

class TextLayout
{
  typedef dp::TextureSetHolder::GlyphRegion GlyphRegion;
public:
  TextLayout(strings::UniString const & string,
             df::FontDecl const & font,
             dp::RefPointer<dp::TextureSetHolder> textures);

  void InitPathText(float depth,
                    vector<glsl_types::Quad4> & texCoord,
                    vector<glsl_types::Quad4> & fontColor,
                    vector<glsl_types::Quad1> & index,
                    dp::RefPointer<dp::TextureSetHolder> textures) const;
  void LayoutPathText(m2::Spline::iterator const & iterator,
                      float const scalePtoG,
                      IntrusiveVector<glsl_types::vec2> & positions,
                      bool isForwardDirection,
                      vector<m2::RectF> & rects,
                      ScreenBase const & screen) const;

  uint32_t GetGlyphCount() const;
  uint32_t GetTextureSet() const;
  float GetPixelLength() const;
  float GetPixelHeight() const;

private:
  float AccumulateAdvance(double const & currentValue, GlyphRegion const & reg2) const;
  void InitMetric(strings::UniChar const & unicodePoint, dp::RefPointer<dp::TextureSetHolder> textures);
  void GetTextureQuad(GlyphRegion const & region, float depth, glsl_types::Quad4 & quad) const;
  void GetMetrics(int32_t const index, float & xOffset, float & yOffset, float & advance,
                  float & halfWidth, float & halfHeight) const;

private:
  buffer_vector<GlyphRegion, 32> m_metrics;
  df::FontDecl m_font;
  float m_textSizeRatio;

  friend dp::OverlayHandle * LayoutText(const FeatureID & featureID,
                                        m2::PointF const & pivot,
                                        vector<TextLayout>::iterator & layoutIter,
                                        vector<m2::PointF>::iterator & pixelOffsetIter,
                                        float depth,
                                        vector<glsl_types::Quad4> & positions,
                                        vector<glsl_types::Quad4> & texCoord,
                                        vector<glsl_types::Quad4> & color,
                                        vector<glsl_types::Quad1> & index,
                                        dp::RefPointer<dp::TextureSetHolder> textures,
                                        int count);
};

class SharedTextLayout
{
public:
  SharedTextLayout(TextLayout * layout);

  bool IsNull() const;
  void Reset(TextLayout * layout);

  TextLayout * operator->();
  TextLayout const * operator->() const;

private:
  shared_ptr<TextLayout> m_layout;
};

}