This asset represents the base class for POT (Power Of Two) and NPOT (Non-Power Of Two) textures.
A derived class must delete any underlying resources and the associated texture, unless those resources are shared.
#include <asset/YiAssetTextureBase.h>

Classes | |
| struct | YI_TEXTURE_CONFIG |
Public Types | |
| enum | YI_MIN_MAG_FILTER { YI_LINEAR, YI_NEAREST } |
| enum | YI_TEXTURE_WRAP { YI_CLAMP_TO_EDGE, YI_MIRROR, YI_REPEAT } |
| enum | USAGE { USAGE_STATIC, USAGE_DYNAMIC, USAGE_RENDER_TARGET } |
Public Types inherited from CYIAssetHardware | |
| enum | RETENTION_POLICY { RETAIN = 0, UNLOAD } |
| The YI_HW_ASSET_RETENTION_POLICY enum specifies the retention policy of static hardware assets from the CPU memory once they are loaded onto the GPU. It is globally configurable, where new CYIAssetHardware will be making use of it and the can also change directly per assets. Be aware that on some platform, it is best to leave the assets retained on the CPU side when the platform lifecycle has the ability to destroy the graphic context while the app still runs, giving You.i Engine the ability to re-load every assets back onto GPU memory really fast. A good example of such platform would be Android. More... | |
Public Types inherited from CYIAsset | |
| enum | PATH_TYPE { PATH_ABSOLUTE = 0, PATH_RELATIVE } |
Protected Member Functions | |
| virtual std::shared_ptr< IYIGPUObject > | CreateGPUObject () const override=0 |
| virtual void | OnUnload () override=0 |
| virtual void | DirtyEntireTexture () |
| void | SetWidth (int32_t nWidth) |
| void | SetHeight (int32_t nHeight) |
| void | SetColorSpace (IYIMaterialFactory::YI_COLORSPACE eColorSpace) |
| virtual void | ApplyRetainmentPolicy () override |
Protected Member Functions inherited from CYIAssetHardware | |
| virtual void | OnLoad () override |
Protected Member Functions inherited from CYIAsset | |
| CYIAsset () | |
| ssize_t | GetID () const |
| void | SetPath (const CYIString &path, PATH_TYPE ePathType) |
| void | SetApproximateSize (uint32_t nSize) |
| void | SetLoaded (bool bAssetLoaded) |
| void | SetLoadParameters (std::unique_ptr< CYIAssetLoadParams > pParams) |
Protected Member Functions inherited from CYIScriptableRTTIObject | |
| virtual std::pair< const CYIRuntimeTypeInfo *, const void * > | GetRuntimeTypeInfoWithObject () const =0 |
Additional Inherited Members | |
Protected Attributes inherited from CYIAssetHardware | |
| bool | m_bHardwareLoadRequested |
| std::shared_ptr< IYIGPUObject > | m_pGPUObject |
| RETENTION_POLICY | m_eRetentionPolicy |
Static Protected Attributes inherited from CYIAsset | |
| static ssize_t | INVALID_ID |
Texture wrapping rules.
| CYIAssetTextureBase::CYIAssetTextureBase | ( | USAGE | usage = USAGE_STATIC | ) |
|
virtual |
| void CYIAssetTextureBase::AddDirtyRegion | ( | const YI_RECT_REL & | dirtyRectangle | ) |
Dirty a specific sub-image of the data. This function allows for users writing performance-critical applications to update the texture asset without requiring a copy of the entirety of the bitmap information.
Multiple calls to this function will result in multiple regions being updated, there is no overwrite. This object will not check for intersection of dirty rectangles, it is up to the user to provide the most efficient series of rectangles to be updated.
|
overrideprotectedvirtual |
Unloads CPU-side data buffer memory if the retainment policy is configured to unload instead of retaining it.
This function should only be used internally by the GPU object after the data has been uploaded onto the GPU. that some asset may chose to retain/unload cpu assets with additional conditions. For example, CYIAssetTextureBase won't unload the cpu asset if the asset is marked as being dynamic.
Reimplemented from CYIAssetHardware.
| void CYIAssetTextureBase::ClearDirtyRegions | ( | ) |
Clear the dirty regions.
|
overrideprotectedpure virtual |
Each sub-type must implement this function and returns an IYIGPUObject representing the hardware type.
Implements CYIAssetHardware.
Implemented in CYIAssetTextureRaw, CYIAssetTexture, and CYIAssetTextureFramebuffer.
|
protectedvirtual |
Marks the texture as dirty, meaning the associated texture resource needs to be updated.
| IYIMaterialFactory::YI_COLORSPACE CYIAssetTextureBase::GetColorSpace | ( | ) | const |
Returns the color space used by this texture.
| const YI_TEXTURE_CONFIG& CYIAssetTextureBase::GetConfiguration | ( | ) | const |
Returns a reference to the YI_TEXTURE_CONFIG structure of this asset. This structure contains all of the texture configuration properties.
| const std::vector<YI_RECT_REL>& CYIAssetTextureBase::GetDirtyRegions | ( | ) | const |
Returns the dirty regions added using AddDirtyRegion().
|
virtual |
Returns the height of the textured region. In the case of POT textures, this must return the height of the actual textured region and not the actual height of the texture.
Reimplemented in CYIAssetTexture.
| USAGE CYIAssetTextureBase::GetUsage | ( | ) | const |
Returns the usage for this texture. This value is immutable and is set in the CYIAssetTextureBase constructor.
|
virtual |
Returns the width of the textured region. In the case of POT textures, this must return the width of the actual textured region and not the actual width of the texture.
Reimplemented in CYIAssetTexture.
|
virtual |
Returns true if the texture's dimensions are different than the source dimensions. For example, if the texture is required to be power-of-two but the originating asset size is different, then this should return true.
| bool CYIAssetTextureBase::IsMipmappingEnabled | ( | ) | const |
|
overrideprotectedpure virtual |
Reimplemented from CYIAsset.
Implemented in CYIAssetTextureRaw, CYIAssetTexture, and CYIAssetTextureFramebuffer.
|
protected |
Sets the color space of this texture. This does not perform color space conversions on the underlying data. Calling this function is used to instruct the renderer on how this texture should be loaded onto the GPU.
| void CYIAssetTextureBase::SetConfiguration | ( | const YI_TEXTURE_CONFIG & | config | ) |
Convenience function for setting the texture configuration all at once
|
protected |
Sets the height of the textured region. In POT texture implmentations, this should be the height of the textured sub-region and not necessarily the actual height.
| void CYIAssetTextureBase::SetMinificationFilter | ( | YI_MIN_MAG_FILTER | minFilter = YI_LINEAR, |
| YI_MIN_MAG_FILTER | magFilter = YI_LINEAR |
||
| ) |
Sets the rules for how the texture should be scaled. Magnification applies scaling to a texel when the size is caculated to be larger than a pixel. When a texel is calculated to be smaller than a pixel, the process is called minification. minFilter determines the rule to use for minifying the texture, and magFilter determines the rule to use for magnifying the texture. Both parameters default to YI_LINEAR.
| void CYIAssetTextureBase::SetMipmappingEnabled | ( | bool | bEnable | ) |
Enables or disables the generation and usage of mipmaps. Mipmapping is disabled by default.
Mipmapping is a technique in graphics rendering that improves the quality of textures when they are displayed on screen at a size significantly smaller than their original resolution. The texture is internally duplicated multiple times at smaller and smaller resolutions until a texture size of 1x1 is reached. This causes the texture to use approximately 1/3 more space than the original texture. Non power-of-two textures may use significantly more memory. The GPU will then choose the texture with the size that is closest to what will be displayed on screen.
Mipmapping should be used on textures that look pixelated and jagged due to being drawn at a smaller size than the original texture.
This will adjust the minification filter setting internally to allow the use of the generated mipmaps.
Disabling mipmapping on a texture which is already loaded with mipmapping enabled will have no effect.
| void CYIAssetTextureBase::SetTextureWrap | ( | YI_TEXTURE_WRAP | wrapS = YI_CLAMP_TO_EDGE, |
| YI_TEXTURE_WRAP | wrapT = YI_CLAMP_TO_EDGE |
||
| ) |
Sets the rules for how the texture coordinates should be wrapped if they extend past the bounds (< 0 or > 1). wrapS determines how to wrap on the s axis (horizontal axis), wrapT determines how to wrap on the t axis (vertical axis). Both parameters default to YI_CLAMP_TO_EDGE.
|
protected |
Sets the width of the textured region. In POT texture implmentations, this should be the width of the textured sub-region and not necessarily the actual width.