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

render_policy.cpp « map - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b182e8a44292c2ec375fef5876c1b65ad1806221 (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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#include "../base/SRC_FIRST.hpp"

#include "render_policy.hpp"
#include "window_handle.hpp"
#include "test_render_policy.hpp"
#include "basic_render_policy.hpp"
#include "simple_render_policy.hpp"
#include "render_policy_st.hpp"
#include "render_policy_mt.hpp"
#include "tiling_render_policy_st.hpp"
#include "tiling_render_policy_mt.hpp"

#include "../anim/controller.hpp"
#include "../anim/task.hpp"

#include "../yg/internal/opengl.hpp"

#include "../indexer/scales.hpp"
#include "../indexer/drawing_rules.hpp"

#include "../platform/video_timer.hpp"
#include "../platform/settings.hpp"
#include "../platform/platform.hpp"

RenderPolicy::~RenderPolicy()
{
  LOG(LDEBUG, ("clearing cached drawing rules"));
  drule::rules().ClearCaches();
  yg::gl::FinalizeThread();
}

RenderPolicy::RenderPolicy(Params const & p,
                           bool doSupportRotation,
                           size_t idCacheSize)
  : m_bgColor(0xEE, 0xEE, 0xDD, 0xFF),
    m_primaryRC(p.m_primaryRC),
    m_doSupportRotation(doSupportRotation),
    m_doForceUpdate(false),
    m_visualScale(p.m_visualScale),
    m_skinName(p.m_skinName)
{
  LOG(LDEBUG, ("each BaseRule will hold up to", idCacheSize, "cached values"));
  drule::rules().ResizeCaches(idCacheSize);
  yg::gl::InitExtensions();
  yg::gl::InitializeThread();
  yg::gl::CheckExtensionSupport();
}

m2::RectI const RenderPolicy::OnSize(int w, int h)
{
  m_drawer->onSize(w, h);
  return m2::RectI(0, 0, w, h);
}

void RenderPolicy::StartDrag()
{
  m_windowHandle->invalidate();
}

void RenderPolicy::DoDrag()
{
  m_windowHandle->invalidate();
}

void RenderPolicy::StopDrag()
{
  m_windowHandle->invalidate();
}

void RenderPolicy::StartScale()
{
  m_windowHandle->invalidate();
}

void RenderPolicy::DoScale()
{
  m_windowHandle->invalidate();
}

void RenderPolicy::StopScale()
{
  m_windowHandle->invalidate();
}

void RenderPolicy::StartRotate(double a, double)
{
  m_windowHandle->invalidate();
}

void RenderPolicy::DoRotate(double a, double)
{
  m_windowHandle->invalidate();
}

void RenderPolicy::StopRotate(double a, double)
{
  m_windowHandle->invalidate();
}

void RenderPolicy::BeginFrame(shared_ptr<PaintEvent> const & e, ScreenBase const & s)
{
}

void RenderPolicy::EndFrame(shared_ptr<PaintEvent> const & e, ScreenBase const & s)
{
  /// processing animations at the end of the frame
  m_controller->PerformStep();
}

bool RenderPolicy::DoSupportRotation() const
{
  return m_doSupportRotation;
}

bool RenderPolicy::NeedRedraw() const
{
  return m_windowHandle->needRedraw()
      || IsAnimating();
}

bool RenderPolicy::IsAnimating() const
{
  return (m_controller->HasTasks()
      || (m_controller->LockCount() > 0)
      || (m_controller->IsPreWarmed()));
}

bool RenderPolicy::IsTiling() const
{
  return false;
}

shared_ptr<DrawerYG> const & RenderPolicy::GetDrawer() const
{
  return m_drawer;
}

shared_ptr<WindowHandle> const & RenderPolicy::GetWindowHandle() const
{
  return m_windowHandle;
}

yg::GlyphCache * RenderPolicy::GetGlyphCache() const
{
  return m_resourceManager->glyphCache(m_resourceManager->guiThreadGlyphCacheID());
}

void RenderPolicy::SetRenderFn(TRenderFn renderFn)
{
  m_renderFn = renderFn;
}

void RenderPolicy::SetCountryNameFn(TCountryNameFn countryNameFn)
{
  m_countryNameFn = countryNameFn;
}

bool RenderPolicy::DoForceUpdate() const
{
  return m_doForceUpdate;
}

void RenderPolicy::SetForceUpdate(bool flag)
{
  m_doForceUpdate = flag;
}

void RenderPolicy::SetInvalidRect(m2::AnyRectD const & glbRect)
{
  m_invalidRect = glbRect;
}

m2::AnyRectD const & RenderPolicy::GetInvalidRect() const
{
  return m_invalidRect;
}

bool RenderPolicy::IsEmptyModel() const
{
  return false;
}

string const RenderPolicy::GetCountryName() const
{
  return string();
}

int RenderPolicy::GetDrawScale(ScreenBase const & s) const
{
  m2::PointD textureCenter(s.PixelRect().Center());
  m2::RectD glbRect;

  unsigned scaleEtalonSize = GetPlatform().ScaleEtalonSize();
  s.PtoG(m2::RectD(textureCenter - m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2),
                   textureCenter + m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2)),
                   glbRect);
  return scales::GetScaleLevel(glbRect);
}

size_t RenderPolicy::ScaleEtalonSize() const
{
  return GetPlatform().ScaleEtalonSize();
}

double RenderPolicy::VisualScale() const
{
  return m_visualScale;
}

string const & RenderPolicy::SkinName() const
{
  return m_skinName;
}

int RenderPolicy::InsertBenchmarkFence()
{
  return 0;
}

void RenderPolicy::JoinBenchmarkFence(int fenceID)
{
}

void RenderPolicy::SetAnimController(anim::Controller * controller)
{
  m_controller = controller;
}

void RenderPolicy::SetOverlay(shared_ptr<yg::Overlay> const & overlay)
{
  m_overlay = overlay;
}

shared_ptr<yg::Overlay> const RenderPolicy::GetOverlay() const
{
  return m_overlay;
}

RenderPolicy * CreateRenderPolicy(RenderPolicy::Params const & params)
{
#ifdef OMIM_OS_ANDROID
    return new TilingRenderPolicyST(params);
#endif
#ifdef OMIM_OS_IPHONE
    return new RenderPolicyMT(params);
#endif
#ifdef OMIM_OS_DESKTOP
    return new TilingRenderPolicyST(params);
#endif
}