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

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

#include "../base/mutex.hpp"

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

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

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

class TileRenderer;

namespace graphics
{
  namespace gl
  {
    class Screen;
  }
}

class CoverageGenerator;

class ScreenCoverage
{
private:
  /// Unique ID of this screen coverage
  int m_sequenceID;
  /// Queue to put new rendering tasks in
  TileRenderer * m_tileRenderer;
  /// Coverage generator
  CoverageGenerator * m_coverageGenerator;
  /// Tiler to compute visible and predicted tiles
  Tiler m_tiler;
  /// Last covered screen
  ScreenBase  m_screen;
  /// Container for a rects, that forms a set of tiles in the m_screen
  typedef set<Tiler::RectInfo> TTileRectSet;
  /// This set contains all rects that was returned by Tiler.
  /// This includes already drawn rects, and rects which is not drawn yet.
  TTileRectSet m_tileRects;
  /// This set contains rects, which was send to TileRenderer to draw
  TTileRectSet m_newTileRects;
  /// Subset of newTileRects, only leaf rects that should be drawn
  /// For quick check for Partial/NonPartial coverage
  TTileRectSet m_newLeafTileRects;
  /// Typedef for a set of tiles, that are visible for the m_screen
  typedef set<Tile const *, LessRectInfo> TTileSet;
  /// This set contains all tiles that are found in the TileCache.
  /// Tiles in this set are locked to prevent their deletion
  /// from TileCache while drawing them
  TTileSet m_tiles;
  /// Overlay composed of overlays for visible tiles
  shared_ptr<graphics::Overlay> m_overlay;

  /// State flags

  /// Does the all leaf tiles in this coverage are empty?
  bool m_isEmptyDrawingCoverage;
  /// If the map model empty at the screen center?
  bool m_isEmptyModelAtCoverageCenter;
  /// Which country this coverage points to at its center?
  /// It's valid only if m_isEmptyModelAtCoverageCenter is true
  string m_countryNameAtCoverageCenter;
  /// How many "leaf" tiles we should render to cover the screen.
  /// This is efficiently the size of newLeafTileRects and is cached for
  /// quick check.
  int m_leafTilesToRender;
  /// Screen, which is used for caching of this ScreenCoverage into DisplayList
  shared_ptr<graphics::Screen> m_cacheScreen;
  /// DisplayList which holds cached ScreenCoverage
  shared_ptr<graphics::DisplayList> m_primaryDL;
  /// DisplayList to cache all straight texts.
  /// They are drawn with different shader.
  shared_ptr<graphics::DisplayList> m_sharpTextDL;

  /// Direct copying is prohibited.
  ScreenCoverage(ScreenCoverage const & src);
  ScreenCoverage const & operator=(ScreenCoverage const & src);

  /// For each tile in m_tiles merge it's overlay into the big one.
  void MergeOverlay();

public:

  /// Default Constructor
  ScreenCoverage();
  /// Constructor
  ScreenCoverage(TileRenderer * tileRenderer,
                 CoverageGenerator * coverageGenerator,
                 shared_ptr<graphics::Screen> const & cacheScreen);
  /// Destructor
  ~ScreenCoverage();
  /// Copy all needed information into specified ScreenCoverage
  void CopyInto(ScreenCoverage & cvg);
  /// Make screen coverage empty
  void Clear();
  /// set unique ID for all actions, used to compute this coverage
  void SetSequenceID(int id);
  /// get unique ID for all actions, used to compute this coverage
  int GetSequenceID() const;
  /// Is this screen coverage partial, which means that it contains non-drawn rects
  bool IsPartialCoverage() const;
  /// Is this screen coverage contains only empty tiles
  bool IsEmptyDrawingCoverage() const;
  /// Is the model empty at the screen center
  bool IsEmptyModelAtCoverageCenter() const;
  /// Reset IsEmptyModelAtCoverageCenter flag
  void ResetEmptyModelAtCoverageCenter();
  /// What country is at this coverage center.
  /// @warning check this flag only if IsEmptyModelAtCoverageCenter is true
  string GetCountryNameAtCoverageCenter() const;
  /// Check, whether the model is empty at the center of the coverage.
  void CheckEmptyModelAtCoverageCenter();
  /// Getter for Overlay
  shared_ptr<graphics::Overlay> const & GetOverlay() const;
  /// Cache coverage in display list
  /// @return true - if the coverage was cached successfully,
  ///         false - otherwise(p.e. the caching was cancelled)
  bool Cache(core::CommandsQueue::Environment const & env);
  /// add rendered tile to coverage. Tile is locked, so make sure to unlock it in case it's not needed.
  void Merge(Tiler::RectInfo const & ri);
  /// recalculate screen coverage, using as much info from prev coverage as possible
  void SetScreen(ScreenBase const & screen);
  /// draw screen coverage
  void Draw(graphics::Screen * s, ScreenBase const & currentScreen);
  /// get draw scale for the tiles in the current coverage
  /// Not all tiles in coverage could correspond to this value,
  /// as there could be tiles from lower and higher level in the
  /// coverage to provide a smooth scale transition experience
  int GetDrawScale() const;
  /// Unlock and remove tiles which intersect the specified rect
  /// and deeper or equal than specified scale
  void RemoveTiles(m2::AnyRectD const & r, int startScale);
};