You.i Engine
YiAssetTextureBase.h
Go to the documentation of this file.
1 // © You i Labs Inc. All rights reserved.
2 #ifndef _YI_ASSET_TEXTURE_BASE_H_
3 #define _YI_ASSET_TEXTURE_BASE_H_
4 
6 #include "graphics/YiRectangle.h"
8 
23 {
24 public:
28  enum class Filtering
29  {
30  Linear,
31  Nearest
32  };
33 
43  enum class WrapMode
44  {
45  ClampToEdge,
46  Mirror,
47  Repeat
48  };
49 
53  enum class Usage
54  {
55  Static,
56  Dynamic,
57  RenderTarget
58  };
59 
64  {
65  TextureConfig();
66  bool operator==(const CYIAssetTextureBase::TextureConfig &rhs) const;
67  bool operator!=(const CYIAssetTextureBase::TextureConfig &rhs) const;
68  WrapMode wrapS, wrapT;
69  Filtering minFilter, magFilter;
70  bool useMipmaps;
71  };
72 
74 
75  virtual ~CYIAssetTextureBase() override;
76 
88  void AddDirtyRegion(const YI_RECT_REL &dirtyRectangle);
89 
101  void GrowDirtyRegion(const YI_RECT_REL &dirtyRectangle);
102 
106  void ClearDirtyRegions();
107 
111  const std::vector<YI_RECT_REL> &GetDirtyRegions() const;
112 
116  const TextureConfig &GetConfiguration() const;
117 
121  virtual int32_t GetWidth() const;
122 
126  virtual int32_t GetHeight() const;
127 
132 
136  void SetConfiguration(const TextureConfig &config);
137 
145 
165  void SetMipmappingEnabled(bool enable);
166 
170  bool IsMipmappingEnabled() const;
171 
180 
184  virtual bool HasExtendedDimensions() const;
185 
189  Usage GetUsage() const;
190 
191  virtual void ApplyRetainmentPolicy() override;
192 
193 protected:
198  virtual std::shared_ptr<IYIGPUObject> CreateGPUObject() const override = 0;
199 
200  virtual void OnUnload() override = 0;
201 
205  virtual void DirtyEntireTexture();
206 
210  void SetWidth(int32_t width);
211 
215  void SetHeight(int32_t height);
216 
221 
222 private:
223  int32_t m_width;
224  int32_t m_height;
225  IYIMaterialFactory::ColorSpace m_colorSpace;
226 
227  TextureConfig m_textureConfiguration;
228  std::vector<YI_RECT_REL> m_dirtyRegions;
229  Usage m_usage;
230 
232 };
233 
236 #endif // _YI_ASSET_TEXTURE_BASE_H_
Usage GetUsage() const
Definition: YiAssetTextureBase.h:63
void SetMinificationFilter(Filtering minFilter=Filtering::Linear, Filtering magFilter=Filtering::Linear)
Definition: YiRectangle.h:38
void SetWidth(int32_t width)
ColorSpace
Definition: YiMaterialFactory.h:37
virtual void OnUnload() override=0
Filtering minFilter
Definition: YiAssetTextureBase.h:69
const TextureConfig & GetConfiguration() const
Filtering
Definition: YiAssetTextureBase.h:28
bool IsMipmappingEnabled() const
bool operator==(const CYIHTTPHeader &lhs, const CYIHTTPHeader &rhs)
void GrowDirtyRegion(const YI_RECT_REL &dirtyRectangle)
IYIMaterialFactory::ColorSpace GetColorSpace() const
CYIAssetTextureBase(Usage usage=Usage::Static)
void SetTextureWrap(WrapMode wrapS=WrapMode::ClampToEdge, WrapMode wrapT=WrapMode::ClampToEdge)
void SetHeight(int32_t height)
virtual bool HasExtendedDimensions() const
Hardware-mirrored asset. These assets contain IYIGPUObject counterparts.
Definition: YiAssetHardware.h:19
void SetColorSpace(IYIMaterialFactory::ColorSpace colorSpace)
void SetConfiguration(const TextureConfig &config)
virtual std::shared_ptr< IYIGPUObject > CreateGPUObject() const override=0
This asset represents the base class for POT (Power Of Two) and NPOT (Non-Power Of Two) textures...
Definition: YiAssetTextureBase.h:22
Usage
Definition: YiAssetTextureBase.h:53
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:259
bool operator!=(const CYIHTTPHeader &lhs, const CYIHTTPHeader &rhs)
const std::vector< YI_RECT_REL > & GetDirtyRegions() const
void AddDirtyRegion(const YI_RECT_REL &dirtyRectangle)
virtual void ApplyRetainmentPolicy() override
virtual ~CYIAssetTextureBase() override
void SetMipmappingEnabled(bool enable)
virtual int32_t GetWidth() const
WrapMode wrapT
Definition: YiAssetTextureBase.h:68
WrapMode
Definition: YiAssetTextureBase.h:43
virtual int32_t GetHeight() const
virtual void DirtyEntireTexture()
bool useMipmaps
Definition: YiAssetTextureBase.h:70