Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
texturemanager.h
Go to the documentation of this file.
1 
18 #ifndef ION_GFX_TEXTUREMANAGER_H_
19 #define ION_GFX_TEXTUREMANAGER_H_
20 
21 #include <set>
22 #include <vector>
23 
24 #include "base/macros.h"
25 #include "ion/base/allocatable.h"
26 #include "ion/math/range.h"
27 
28 namespace ion {
29 namespace gfx {
30 
39  public:
40  typedef const void* TextureType;
41 
43  explicit TextureManager(int max_texture_units);
44  ~TextureManager() override;
45 
49  int GetUnit(TextureType texture, int current_unit);
50 
52  int GetBackIndex() const { return back_; }
54  int GetFrontIndex() const { return front_; }
56  TextureType GetTexture(int unit) const;
57 
62  void SetUnitRange(const math::Range1i& units);
63 
64  private:
66  static const int kEnd;
67 
68  struct Item {
70  int prev;
71  int next;
72  };
73 
75  void Touch(int unit);
76 
78  std::vector<Item> items_;
80  int back_;
82  int front_;
83 
84  DISALLOW_IMPLICIT_CONSTRUCTORS(TextureManager);
85 };
86 
87 } // namespace gfx
88 } // namespace ion
89 
90 #endif // ION_GFX_TEXTUREMANAGER_H_
int GetBackIndex() const
Returns the back unit.
int GetUnit(TextureType texture, int current_unit)
Returns the unit associated with the data pointer.
TextureType GetTexture(int unit) const
Returns the data at index unit.
Range< 1, int32 > Range1i
Definition: range.h:363
TextureManager(int max_texture_units)
A TextureManager must be initialized with a size of at least 1.
void SetUnitRange(const math::Range1i &units)
Sets the inclusive range of units that the TextureManager uses.
Allocatable is an abstract base class for classes whose memory is managed by an Allocator.
Definition: allocatable.h:60
TexturePtr texture
The Texture to add sub-image data to.
Definition: fontimage.cc:107
TextureManager is an internal Ion class, and is not exported for public use.
int GetFrontIndex() const
Returns the front unit.