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

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

#include "render/drawer.hpp"

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

#include "geometry/screenbase.hpp"

#include "platform/platform.hpp"


using namespace graphics;

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

  rmp.checkDeviceCaps();
  bool useNpot = rmp.canUseNPOTextures();

  rmp.m_textureParams[ELargeTexture]        = GetTextureParam(GetLargeTextureSize(useNpot), 10, rmp.m_texFormat, ELargeTexture);
  rmp.m_textureParams[EMediumTexture]       = GetTextureParam(GetMediumTextureSize(useNpot), 5, rmp.m_texFormat, EMediumTexture);
  rmp.m_textureParams[ESmallTexture]        = GetTextureParam(GetSmallTextureSize(useNpot), 4, rmp.m_texFormat, ESmallTexture);

  rmp.m_storageParams[ELargeStorage]        = GetStorageParam(50000, 100000, 15, ELargeStorage);
  rmp.m_storageParams[EMediumStorage]       = GetStorageParam(5000, 10000, 100, EMediumStorage);
  rmp.m_storageParams[ESmallStorage]        = GetStorageParam(2000, 6000, 10, ESmallStorage);
  rmp.m_storageParams[ETinyStorage]         = GetStorageParam(100, 200, 1, ETinyStorage);

  rmp.m_glyphCacheParams = GetResourceGlyphCacheParams(Density());

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

  rmp.m_useSingleThreadedOGL = false;

  m_resourceManager.reset(new graphics::ResourceManager(rmp, SkinName(), Density()));

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

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

  m_drawer.reset(CreateDrawer(p.m_useDefaultFB, p.m_primaryRC, ELargeStorage, ELargeTexture));
  InitCacheScreen();
  InitWindowsHandle(p.m_videoTimer, p.m_primaryRC);

  m_overlay.reset(new graphics::Overlay());
}

void SimpleRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e,
                               ScreenBase const & s)
{
#ifndef USE_DRAPE
  shared_ptr<graphics::OverlayStorage> storage(new graphics::OverlayStorage());

  graphics::Screen * pScreen = GPUDrawer::GetScreen(e->drawer());

  pScreen->setOverlay(storage);
  pScreen->beginFrame();
  pScreen->clear(m_bgColor);

  m_renderFn(e, s, s.PixelRect(), ScalesProcessor().GetTileScaleBase(s));

  pScreen->resetOverlay();
  pScreen->clear(graphics::Color::White(), false, 1.0, true);

  m_overlay->merge(storage);

  math::Matrix<double, 3, 3> const m = math::Identity<double, 3>();
  m_overlay->forEach([&pScreen, &m](shared_ptr<graphics::OverlayElement> const & e)
  {
    e->draw(pScreen, m);
  });

  pScreen->endFrame();
#endif // USE_DRAPE
}

graphics::Overlay * SimpleRenderPolicy::FrameOverlay() const
{
  return m_overlay.get();
}