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

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

#include "drape/texture.hpp"

#include <map>
#include <string>
#include <vector>

namespace dp
{
class SymbolsTexture : public Texture
{
public:
  class SymbolKey : public Key
  {
  public:
    explicit SymbolKey(std::string const & symbolName);
    ResourceType GetType() const override;
    std::string const & GetSymbolName() const;

  private:
    std::string m_symbolName;
  };

  class SymbolInfo : public ResourceInfo
  {
  public:
    explicit SymbolInfo(m2::RectF const & texRect);
    ResourceType GetType() const override;
  };

  SymbolsTexture(ref_ptr<dp::GraphicsContext> context, std::string const & skinPathName,
                 std::string const & textureName, ref_ptr<HWTextureAllocator> allocator);

  ref_ptr<ResourceInfo> FindResource(Key const & key, bool & newResource) override;

  void Invalidate(ref_ptr<dp::GraphicsContext> context, std::string const & skinPathName,
                  ref_ptr<HWTextureAllocator> allocator);

  bool IsSymbolContained(std::string const & symbolName) const;

  static bool DecodeToMemory(std::string const & skinPathName, std::string const & textureName,
                             std::vector<uint8_t> & symbolsSkin,
                             std::map<std::string, m2::RectU> & symbolsIndex,
                             uint32_t & skinWidth, uint32_t & skinHeight);
private:
  void Fail(ref_ptr<dp::GraphicsContext> context);
  void Load(ref_ptr<dp::GraphicsContext> context, std::string const & skinPathName,
            ref_ptr<HWTextureAllocator> allocator);

  using TSymDefinition = std::map<std::string, SymbolInfo>;
  std::string m_name;
  mutable TSymDefinition m_definition;
};
}  // namespace dp