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

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

#include "../geometry/rect2d.hpp"

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

namespace graphics
{
  struct Resource
  {
    enum Category
    {
      EBrush = 1,
      EPen,
      EGlyph,
      EIcon,
      ECircle,
      EImage,
      EUnknown
    };

    /// Base class for lighweight Resource description
    struct Info
    {
      Category m_category;

      Info(Category cat);

      virtual Info const & cacheKey() const = 0;
      /// returns the size of this resource info which will
      /// be occupied in texture cache.
      virtual m2::PointU const resourceSize() const = 0;
      /// factory method for Resource object
      virtual Resource * createResource(m2::RectU const & texRect,
                                        uint8_t pipelineID) const = 0;
      /// comparing for using Info as a key in map.
      virtual bool lessThan(Info const * r) const = 0;
    };

    Category m_cat;
    m2::RectU m_texRect;
    int m_pipelineID;

    virtual ~Resource();
    virtual void render(void * dst) = 0;
    /// get key for ResourceCache.
    virtual Info const * info() const = 0;

    struct LessThan
    {
       bool operator()(Info const * l,
                       Info const * r) const;
    };

  protected:
    Resource(Category cat,
             m2::RectU const & texRect,
             int pipelineID);
  };
}