You.i Engine
YiAssetTextureBase.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_ASSET_TEXTURE_BASE_H_
3 #define _YI_ASSET_TEXTURE_BASE_H_
4 
10 #include "asset/YiAssetHardware.h"
11 #include "framework/YiPredef.h"
12 #include "graphics/YiBitmap.h"
14 #include "utility/YiRtti.h"
15 
25 {
26 public:
30  enum class Filtering
31  {
32  Linear,
33  Nearest
34  };
35 
45  enum class WrapMode
46  {
47  ClampToEdge,
48  Mirror,
49  Repeat
50  };
51 
55  enum class Usage
56  {
57  Static,
58  Dynamic,
59  RenderTarget
60  };
61 
66  {
67  TextureConfig();
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:65
void SetMinificationFilter(Filtering minFilter=Filtering::Linear, Filtering magFilter=Filtering::Linear)
Definition: YiPredef.h:291
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:30
bool IsMipmappingEnabled() const
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:20
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:24
Usage
Definition: YiAssetTextureBase.h:55
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:257
const std::vector< YI_RECT_REL > & GetDirtyRegions() const
void AddDirtyRegion(const YI_RECT_REL &dirtyRectangle)
This file contains the classes and macros used to implement RTTI in You.i Engine. ...
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:45
virtual int32_t GetHeight() const
virtual void DirtyEntireTexture()
bool useMipmaps
Definition: YiAssetTextureBase.h:70