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

simple_render_policy.cpp « map - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e65d387175bf09f6967698221de2c328406d6b9c (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
#include "simple_render_policy.hpp"
#include "events.hpp"
#include "drawer.hpp"
#include "window_handle.hpp"

#include "../graphics/overlay.hpp"
#include "../graphics/opengl/opengl.hpp"
#include "../graphics/skin.hpp"
#include "../graphics/render_context.hpp"

#include "../indexer/scales.hpp"
#include "../geometry/screenbase.hpp"

#include "../platform/platform.hpp"

SimpleRenderPolicy::SimpleRenderPolicy(Params const & p)
  : RenderPolicy(p, false, 1)
{
  graphics::ResourceManager::Params rmp = p.m_rmParams;

  rmp.checkDeviceCaps();

  graphics::ResourceManager::TexturePoolParams tpp;
  graphics::ResourceManager::StoragePoolParams spp;

  spp = graphics::ResourceManager::StoragePoolParams(50000 * sizeof(graphics::gl::Vertex),
                                                     sizeof(graphics::gl::Vertex),
                                                     10000 * sizeof(unsigned short),
                                                     sizeof(unsigned short),
                                                     15,
                                                     graphics::ELargeStorage,
                                                     false);

  rmp.m_storageParams[spp.m_storageType] = spp;

  spp = graphics::ResourceManager::StoragePoolParams(5000 * sizeof(graphics::gl::Vertex),
                                                     sizeof(graphics::gl::Vertex),
                                                     10000 * sizeof(unsigned short),
                                                     sizeof(unsigned short),
                                                     100,
                                                     graphics::EMediumStorage,
                                                     false);

  rmp.m_storageParams[spp.m_storageType] = spp;

  spp = graphics::ResourceManager::StoragePoolParams(2000 * sizeof(graphics::gl::Vertex),
                                                     sizeof(graphics::gl::Vertex),
                                                     6000 * sizeof(unsigned short),
                                                     sizeof(unsigned short),
                                                     10,
                                                     graphics::ESmallStorage,
                                                     false);

  rmp.m_storageParams[spp.m_storageType] = spp;


  tpp = graphics::ResourceManager::TexturePoolParams(512,
                                                     256,
                                                     10,
                                                     rmp.m_texFormat,
                                                     graphics::ELargeTexture,
                                                     false);

  rmp.m_textureParams[tpp.m_textureType] = tpp;

  tpp = graphics::ResourceManager::TexturePoolParams(512,
                                                     256,
                                                     5,
                                                     rmp.m_texFormat,
                                                     graphics::EMediumTexture,
                                                     false);

  rmp.m_textureParams[tpp.m_textureType] = tpp;

  rmp.m_glyphCacheParams = graphics::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
                                                                 "fonts_whitelist.txt",
                                                                 "fonts_blacklist.txt",
                                                                 2 * 1024 * 1024);

  rmp.m_renderThreadsCount = 0;
  rmp.m_threadSlotsCount = 1;

  rmp.m_useSingleThreadedOGL = false;

  m_resourceManager.reset(new graphics::ResourceManager(rmp));

  m_primaryRC->setResourceManager(m_resourceManager);
  m_primaryRC->startThreadDrawing(m_resourceManager->guiThreadSlot());

  Platform::FilesList fonts;
  GetPlatform().GetFontNames(fonts);
  m_resourceManager->addFonts(fonts);

  Drawer::Params dp;

  dp.m_frameBuffer = make_shared_ptr(new graphics::gl::FrameBuffer(p.m_useDefaultFB));
  dp.m_resourceManager = m_resourceManager;
  dp.m_threadSlot = m_resourceManager->guiThreadSlot();
  dp.m_skin = make_shared_ptr(graphics::loadSkin(m_resourceManager, SkinName()));
  dp.m_visualScale = VisualScale();
  dp.m_isSynchronized = true;
  dp.m_fastSolidPath = false;

  m_drawer.reset(new Drawer(dp));

  m_windowHandle.reset(new WindowHandle());

  m_windowHandle->setUpdatesEnabled(false);
  m_windowHandle->setRenderPolicy(this);
  m_windowHandle->setVideoTimer(p.m_videoTimer);
  m_windowHandle->setRenderContext(p.m_primaryRC);
}

void SimpleRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e,
                               ScreenBase const & s)
{
  int scaleEtalonSize = GetPlatform().ScaleEtalonSize();

  m2::RectD glbRect;
  m2::PointD const pxCenter = s.PixelRect().Center();
  s.PtoG(m2::RectD(pxCenter - m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2),
                   pxCenter + m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2)),
         glbRect);

  shared_ptr<graphics::Overlay> overlay(new graphics::Overlay());

  Drawer * pDrawer = e->drawer();

  pDrawer->screen()->setOverlay(overlay);
  pDrawer->screen()->beginFrame();
  pDrawer->screen()->clear(m_bgColor);

  m_renderFn(e, s, s.ClipRect(), s.ClipRect(), scales::GetScaleLevel(glbRect), false);

  overlay->draw(pDrawer->screen().get(), math::Identity<double, 3>());
  pDrawer->screen()->resetOverlay();

  pDrawer->screen()->endFrame();
}