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

coverage_generator.hpp « map - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 21caa4bd24c41b891ff050c0e41d71978d5d2a2b (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
#pragma once

#include "render_policy.hpp"
#include "tiler.hpp"
#include "tile.hpp"
#include "window_handle.hpp"

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

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

#include "../base/thread.hpp"
#include "../base/threaded_list.hpp"
#include "../base/mutex.hpp"
#include "../base/commands_queue.hpp"

#include "../std/vector.hpp"
#include "../std/shared_ptr.hpp"

class TileRenderer;
class TileCache;
class ScreenCoverage;

namespace graphics
{
  class Skin;

  namespace gl
  {
    class Screen;
  }
  class ResourceStyleCache;
}

/// Control class for TilingRenderPolicy. It processes request from the RenderPolicy
/// to draw a specific ScreenBase by splitting it in tiles that is not rendered now and
/// feeding them into TileRenderer. Each command to render a tile is enqueued with
/// a small command, which is feeding the CoverageGenerator with the command to process
/// newly rendered tile(p.e. merge it into current ScreenCoverage).
class CoverageGenerator
{
private:

  core::CommandsQueue m_queue;

  TileRenderer * m_tileRenderer;

  shared_ptr<graphics::ResourceManager> m_resourceManager;
  shared_ptr<graphics::RenderContext> m_renderContext;

  ScreenCoverage * m_workCoverage;
  ScreenCoverage * m_currentCoverage;

  ScreenBase m_currentScreen;
  int m_sequenceID;

  shared_ptr<WindowHandle> m_windowHandle;

  threads::Mutex m_mutex;

  RenderPolicy::TCountryNameFn m_countryNameFn;

  graphics::PacketsQueue * m_glQueue;
  string m_skinName;

  FenceManager m_fenceManager;
  int m_currentFenceID;

  bool m_doForceUpdate;
  bool m_isPaused;

  ScreenCoverage * CreateCoverage();

public:

  CoverageGenerator(string const & skinName,
                    TileRenderer * tileRenderer,
                    shared_ptr<WindowHandle> const & windowHandle,
                    shared_ptr<graphics::RenderContext> const & primaryRC,
                    shared_ptr<graphics::ResourceManager> const & rm,
                    graphics::PacketsQueue * glQueue,
                    RenderPolicy::TCountryNameFn countryNameFn);

  ~CoverageGenerator();

  void InitializeThreadGL();
  void FinalizeThreadGL();

  void InvalidateTiles(m2::AnyRectD const & rect, int startScale);
  void InvalidateTilesImpl(m2::AnyRectD const & rect, int startScale);

  void AddCoverScreenTask(ScreenBase const & screen, bool doForce);
  void AddMergeTileTask(Tiler::RectInfo const & rectInfo,
                        int sequenceID);

  void AddCheckEmptyModelTask(int sequenceID);
  void AddFinishSequenceTask(int sequenceID);

  void CoverScreen(core::CommandsQueue::Environment const & env,
                   ScreenBase const & screen,
                   int sequenceID);

  void MergeTile(core::CommandsQueue::Environment const & env,
                 Tiler::RectInfo const & rectInfo,
                 int sequenceID);

  void CheckEmptyModel(int sequenceID);

  void FinishSequence(int sequenceID);

  void Cancel();

  void WaitForEmptyAndFinished();

  string GetCountryName(m2::PointD const & pt) const;

  ScreenCoverage * CurrentCoverage();

  int InsertBenchmarkFence();
  void JoinBenchmarkFence(int fenceID);
  void SignalBenchmarkFence();

  bool DoForceUpdate() const;

  void SetSequenceID(int sequenceID);

  threads::Mutex & Mutex();

  shared_ptr<graphics::ResourceManager> const & resourceManager() const;

  void SetIsPaused(bool flag);
  void CancelCommands();
};