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

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

#include "render_policy.hpp"

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

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

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


class TileRenderer;
class CoverageGenerator;
class QueuedRenderer;

/// This is a base class for a single-threaded and multi-threaded versions of render policies
/// which uses tiles to present a scene.
/// This policies use ScreenCoverage objects to hold all the information, need to render the model
/// at the specified ScreenBase(tiles, texts, symbols, e.t.c)
/// At any moment of time there are a currentCoverage that are drawn in DrawFrame method.
/// There are threads that are responsible for composing new ScreenCoverage from already drawn tiles,
/// and drawing tiles if needed.
/// Once the more recent ScreenCoverage are composed it became a currentCoverage.
class BasicTilingRenderPolicy : public RenderPolicy
{
private:

  size_t CalculateTileSize(size_t screenWidth, size_t screenHeight);

protected:

  shared_ptr<QueuedRenderer> m_QueuedRenderer;
  shared_ptr<TileRenderer> m_TileRenderer;
  shared_ptr<CoverageGenerator> m_CoverageGenerator;

  ScreenBase m_CurrentScreen;
  int  m_DrawScale;
  bool m_IsEmptyModel;
  storage::TIndex m_countryIndex;
  bool m_DoRecreateCoverage;
  bool m_IsNavigating;
  bool m_WasAnimatingLastFrame;
  size_t m_TileSize;

protected:

  TileRenderer & GetTileRenderer();

  void StartNavigation();
  void StopNavigation();

  void PauseBackgroundRendering();
  void ResumeBackgroundRendering();
  void CheckAnimationTransition();

public:

  BasicTilingRenderPolicy(Params const & p,
                          bool doUseQueuedRenderer);

  void BeginFrame(shared_ptr<PaintEvent> const & ev, ScreenBase const & s);
  void DrawFrame(shared_ptr<PaintEvent> const & ev, ScreenBase const & s);
  void EndFrame(shared_ptr<PaintEvent> const & ev, ScreenBase const & s);

  virtual void StartScale();
  virtual void StopScale();

  virtual void StartDrag();
  virtual void StopDrag();

  virtual void StartRotate(double a, double timeInSec);
  virtual void StopRotate(double a, double timeInSec);

  bool NeedRedraw() const;
  bool IsTiling() const;
  bool IsEmptyModel() const;
  storage::TIndex GetCountryIndex() const;
  int GetDrawScale(ScreenBase const & s) const;
  size_t ScaleEtalonSize() const;
  size_t TileSize() const;

  /// benchmarking protocol
  int InsertBenchmarkFence();
  void JoinBenchmarkFence(int fenceID);
};