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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#pragma once
#include "draw_info.hpp"
#include "../graphics/color.hpp"
#include "../graphics/screen.hpp"
#include "../std/list.hpp"
#include "../std/string.hpp"
#include "../std/shared_ptr.hpp"
#include "../std/map.hpp"
class ScreenBase;
namespace drule { class BaseRule; }
namespace graphics
{
namespace gl
{
class Screen;
class FrameBuffer;
class BaseTexture;
}
class ResourceManager;
class Skin;
}
namespace di
{
class DrawInfo
{
public:
DrawInfo(string const & name,
string const & secondaryName,
string const & road,
double rank);
list<di::PathInfo> m_pathes;
list<di::AreaInfo> m_areas;
m2::PointD m_point;
string m_name;
string m_secondaryName;
string m_road;
double m_rank;
string const GetPathName() const;
};
struct DrawRule
{
typedef drule::BaseRule const * rule_ptr_t;
rule_ptr_t m_rule;
int m_depth;
bool m_transparent;
DrawRule() : m_rule(0) {}
DrawRule(rule_ptr_t p, int d, bool tr) : m_rule(p), m_depth(d), m_transparent(tr) {}
uint32_t GetID(size_t threadSlot) const;
void SetID(size_t threadSlot, uint32_t id) const;
};
}
class Drawer
{
typedef di::DrawRule::rule_ptr_t rule_ptr_t;
double m_visualScale;
int m_level;
shared_ptr<graphics::Screen> m_pScreen;
shared_ptr<graphics::Skin> m_pSkin;
static void ClearResourceCache(size_t threadSlot, uint8_t pipelineID);
typedef pair<size_t, uint32_t> FeatureID;
protected:
void drawSymbol(m2::PointD const & pt, rule_ptr_t pRule,
graphics::EPosition pos, int depth, FeatureID const & id);
void drawCircle(m2::PointD const & pt, rule_ptr_t pRule,
graphics::EPosition pos, int depth, FeatureID const & id);
void drawPath(di::PathInfo const & info, di::DrawRule const * rules, size_t count);
void drawArea(vector<m2::PointD> const & pts, rule_ptr_t pRule, int depth);
void drawText(m2::PointD const & pt, di::DrawInfo const * pInfo, rule_ptr_t pRule,
graphics::EPosition pos, int depth, FeatureID const & id);
bool drawPathText(di::PathInfo const & info, di::DrawInfo const * pInfo, rule_ptr_t pRule, int depth);
void drawPathNumber(di::PathInfo const & path, di::DrawInfo const * pInfo);
typedef shared_ptr<graphics::gl::BaseTexture> texture_t;
typedef shared_ptr<graphics::gl::FrameBuffer> frame_buffer_t;
public:
struct Params : graphics::Screen::Params
{
double m_visualScale;
Params();
};
Drawer(Params const & params = Params());
void drawSymbol(m2::PointD const & pt, string const & symbolName, graphics::EPosition pos, int depth);
void beginFrame();
void endFrame();
void clear(graphics::Color const & c = graphics::Color(187, 187, 187, 255), bool clearRT = true, float depth = 1.0f, bool clearDepth = true);
void onSize(int w, int h);
shared_ptr<graphics::Screen> screen() const;
double VisualScale() const;
void SetScale(int level);
int ThreadSlot() const;
void Draw(di::DrawInfo const * pInfo,
di::DrawRule const * rules, size_t count,
FeatureID const & id);
bool filter_text_size(rule_ptr_t pRule) const;
uint8_t get_text_font_size(rule_ptr_t pRule) const;
};
|