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

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

#include "drape_frontend/tile_key.hpp"
#include "drape_frontend/user_mark_shapes.hpp"

#include "drape/pointers.hpp"

#include <functional>
#include <map>
#include <set>
#include <string>
#include <vector>

namespace df
{
using MarksIDGroups = std::map<kml::MarkGroupId, drape_ptr<IDCollections>>;
using MarksIndex = std::map<TileKey, drape_ptr<MarksIDGroups>>;

class UserMarkGenerator
{
public:
  using TFlushFn = std::function<void(TUserMarksRenderData && renderData)>;

  explicit UserMarkGenerator(TFlushFn const & flushFn);

  void SetUserMarks(drape_ptr<UserMarksRenderCollection> && marks);
  void SetUserLines(drape_ptr<UserLinesRenderCollection> && lines);
  void SetRemovedUserMarks(drape_ptr<IDCollections> && ids);
  void SetCreatedUserMarks(drape_ptr<IDCollections> && ids);

  void SetGroup(kml::MarkGroupId groupId, drape_ptr<IDCollections> && ids);
  void RemoveGroup(kml::MarkGroupId groupId);
  void SetGroupVisibility(kml::MarkGroupId groupId, bool isVisible);

  void GenerateUserMarksGeometry(ref_ptr<dp::GraphicsContext> context, TileKey const & tileKey,
                                 ref_ptr<dp::TextureManager> textures);

private:
  void UpdateIndex(kml::MarkGroupId groupId);

  ref_ptr<IDCollections> GetIdCollection(TileKey const & tileKey, kml::MarkGroupId groupId);
  void CleanIndex();

  int GetNearestLineIndexZoom(int zoom) const;

  ref_ptr<MarksIDGroups> GetUserMarksGroups(TileKey const & tileKey);
  ref_ptr<MarksIDGroups> GetUserLinesGroups(TileKey const & tileKey);

  void CacheUserMarks(ref_ptr<dp::GraphicsContext> context, TileKey const & tileKey,
                      MarksIDGroups const & indexesGroups, ref_ptr<dp::TextureManager> textures,
                      dp::Batcher & batcher);
  void CacheUserLines(ref_ptr<dp::GraphicsContext> context, TileKey const & tileKey,
                      MarksIDGroups const & indexesGroups, ref_ptr<dp::TextureManager> textures,
                      dp::Batcher & batcher);

  std::unordered_set<kml::MarkGroupId> m_groupsVisibility;
  MarksIDGroups m_groups;

  UserMarksRenderCollection m_marks;
  UserLinesRenderCollection m_lines;

  MarksIndex m_index;

  TFlushFn m_flushFn;
};
}  // namespace df