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 | TextureConfig |
Public Types | |
enum | Filtering { Filtering::Linear, Filtering::Nearest } |
enum | WrapMode { WrapMode::ClampToEdge, WrapMode::Mirror, WrapMode::Repeat } |
enum | Usage { Usage::Static, Usage::Dynamic, Usage::RenderTarget } |
![]() | |
enum | RetentionPolicy { RetentionPolicy::Retain = 0, RetentionPolicy::Unload } |
The CYIAssetHardware::RetentionPolicy enum specifies the retention policy of static hardware assets from the CPU memory once they are loaded into the GPU memory. More... | |
![]() | |
enum | PathType { PathType::Absolute = 0, PathType::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 width) |
void | SetHeight (int32_t height) |
void | SetColorSpace (IYIMaterialFactory::ColorSpace colorSpace) |
![]() | |
virtual void | OnLoad () override |
![]() | |
CYIAsset () | |
ssize_t | GetID () const |
void | SetPath (const CYIString &path, PathType pathType) |
void | SetApproximateSize (size_t size) |
void | SetLoaded (bool assetLoaded) |
void | SetLoadParameters (std::unique_ptr< CYIAssetLoadParams > pParams) |
Additional Inherited Members | |
![]() | |
bool | m_hardwareLoadRequested |
std::shared_ptr< IYIGPUObject > | m_pGPUObject |
RetentionPolicy | m_retentionPolicy |
![]() | |
static ssize_t | INVALID_ID |
|
strong |
|
strong |
|
strong |
Texture wrapping rules.
CYIAssetTextureBase::CYIAssetTextureBase | ( | Usage | usage = Usage::Static | ) |
|
overridevirtual |
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.
|
overridevirtual |
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::ColorSpace CYIAssetTextureBase::GetColorSpace | ( | ) | const |
Returns the color space used by this texture.
const TextureConfig& CYIAssetTextureBase::GetConfiguration | ( | ) | const |
Returns a reference to the TextureConfig 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.
void CYIAssetTextureBase::GrowDirtyRegion | ( | const YI_RECT_REL & | dirtyRectangle | ) |
Dirty a specific sub-image of the data. If at least one dirty region already exists, it is expanded to include both the original dirty region and dirtyRectangle.
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.
|
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 TextureConfig & | 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 | ( | Filtering | minFilter = Filtering::Linear , |
Filtering | magFilter = Filtering::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.
CYIAssetTextureBase::Filtering::Linear means that adjacent pixels will be bilinearly filtered. CYIAssetTextureBase::Filtering::Nearest means that the nearest pixel will be selected.
void CYIAssetTextureBase::SetMipmappingEnabled | ( | bool | enable | ) |
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 | ( | WrapMode | wrapS = WrapMode::ClampToEdge , |
WrapMode | wrapT = WrapMode::ClampToEdge |
||
) |
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 WrapMode::ClampToEdge.
|
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.