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: ea98ac636f819355e11db05a743136901979de67 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
#pragma once

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

#include "../drape/utils/vertex_decl.hpp"
#include "../drape/glsl_types.hpp"
#include "../drape/pointers.hpp"
#include "../drape/texture_manager.hpp"

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

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

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

namespace dp
{
  class OverlayHandle;
}

namespace df
{

class TextLayout
{

public:
  enum class LayoutType
  {
    StraightLayout,
    PathLayout
  };

  dp::RefPointer<dp::Texture> GetMaskTexture() const;

  uint32_t GetGlyphCount() const;

  float GetPixelLength() const;
  float GetPixelHeight() const;
  LayoutType GetType() const { return m_type; }

protected:
  TextLayout(LayoutType type);
  void Init(strings::UniString const & text,
            float fontSize,
            dp::RefPointer<dp::TextureManager> textures);


protected:
  typedef dp::TextureManager::GlyphRegion GlyphRegion;

  dp::TextureManager::TGlyphsBuffer m_metrics;
  float m_textSizeRatio = 0.0;

private:
  LayoutType m_type;
};

class StraightTextLayout : public TextLayout
{
  typedef TextLayout TBase;
public:
  StraightTextLayout(strings::UniString const & text,
                     float fontSize,
                     dp::RefPointer<dp::TextureManager> textures,
                     dp::Anchor anchor);

  void Cache(glm::vec3 const & pivot, glsl::vec2 const & pixelOffset,
                   dp::TextureManager::ColorRegion const & colorRegion,
                   dp::TextureManager::ColorRegion const & outlineRegion,
                   gpu::TTextStaticVertexBuffer & staticBuffer,
                   gpu::TTextDynamicVertexBuffer & dynamicBuffer) const;

  m2::PointU const & GetPixelSize() const { return m_pixelSize; }

private:
  buffer_vector<pair<size_t, glsl::vec2>, 2> m_offsets;
  m2::PointU m_pixelSize;
};

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;
};

}