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
101
102
103
104
105
106
107
108
|
#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:
virtual ~TextLayout() {}
dp::RefPointer<dp::Texture> GetMaskTexture() const;
uint32_t GetGlyphCount() const;
float GetPixelLength() const;
float GetPixelHeight() const;
protected:
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;
};
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(glsl::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 PathTextLayout : public TextLayout
{
typedef TextLayout TBase;
public:
PathTextLayout(strings::UniString const & text,
float fontSize, dp::RefPointer<dp::TextureManager> textures);
void CacheStaticGeometry(glsl::vec3 const & pivot,
dp::TextureManager::ColorRegion const & colorRegion,
dp::TextureManager::ColorRegion const & outlineRegion,
gpu::TTextStaticVertexBuffer & staticBuffer) const;
bool CacheDynamicGeometry(m2::Spline::iterator const & iter,
ScreenBase const & screen,
gpu::TTextDynamicVertexBuffer & buffer) const;
};
class SharedTextLayout
{
public:
SharedTextLayout(PathTextLayout * layout);
bool IsNull() const;
void Reset(PathTextLayout * layout);
PathTextLayout * GetRaw();
PathTextLayout * operator->();
PathTextLayout const * operator->() const;
private:
shared_ptr<PathTextLayout> m_layout;
};
}
|