Pyrogenesis trunk
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
CTexture Class Reference

Represents a texture object. More...

#include <TextureManager.h>

Collaboration diagram for CTexture:
Collaboration graph
[legend]

Public Member Functions

 ~CTexture ()
 
size_t GetWidth () const
 Returns the width (in pixels) of the current texture. More...
 
size_t GetHeight () const
 Returns the height (in pixels) of the current texture. More...
 
bool HasAlpha () const
 Returns whether the current texture has an alpha channel. More...
 
u32 GetBaseColor () const
 Returns the ARGB value of the lowest mipmap level (i.e. More...
 
size_t GetUploadedSize () const
 Returns total number of bytes uploaded for this texture. More...
 
void UploadBackendTextureIfNeeded (Renderer::Backend::IDeviceCommandContext *deviceCommandContext)
 Uploads a texture data to a backend texture if successfully loaded. More...
 
Renderer::Backend::ITextureGetBackendTexture ()
 Returns a backend texture if successfully uploaded, else fallback. More...
 
const Renderer::Backend::ITextureGetBackendTexture () const
 
bool TryLoad ()
 Attempt to load the texture data quickly, as with GetUploadedBackendTextureIfNeeded(). More...
 
bool IsLoaded () const
 Returns whether the texture data is currently loaded. More...
 
bool IsUploaded () const
 Returns whether the texture data is currently uploaded. More...
 
void Prefetch ()
 Activate the prefetching optimisation for this texture. More...
 

Private Types

enum  {
  UNLOADED , PREFETCH_NEEDS_LOADING , PREFETCH_NEEDS_CONVERTING , PREFETCH_IS_CONVERTING ,
  HIGH_NEEDS_CONVERTING , HIGH_IS_CONVERTING , LOADED , UPLOADED
}
 

Private Member Functions

 NONCOPYABLE (CTexture)
 
 CTexture (std::unique_ptr< Renderer::Backend::ITexture > texture, Renderer::Backend::ITexture *fallback, const CTextureProperties &props, CTextureManagerImpl *textureManager)
 
void ResetBackendTexture (std::unique_ptr< Renderer::Backend::ITexture > backendTexture, Renderer::Backend::ITexture *fallbackBackendTexture)
 

Private Attributes

const CTextureProperties m_Properties
 
std::unique_ptr< Renderer::Backend::ITexturem_BackendTexture
 
Renderer::Backend::ITexturem_FallbackBackendTexture = nullptr
 
u32 m_BaseColor
 
std::unique_ptr< Texm_TextureData
 
size_t m_UploadedSize = 0
 
uint32_t m_BaseLevelOffset = 0
 
enum CTexture:: { ... }  m_State
 
CTextureManagerImplm_TextureManager
 
std::weak_ptr< CTexturem_Self
 

Friends

class CTextureManagerImpl
 
class CPredefinedTexture
 
struct TextureCacheCmp
 
struct TPequal_to
 
struct TPhash
 

Detailed Description

Represents a texture object.

The texture data may or may not have been loaded yet. Before it has been loaded, all operations will act on a default 1x1-pixel grey texture instead.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
UNLOADED 
PREFETCH_NEEDS_LOADING 
PREFETCH_NEEDS_CONVERTING 
PREFETCH_IS_CONVERTING 
HIGH_NEEDS_CONVERTING 
HIGH_IS_CONVERTING 
LOADED 
UPLOADED 

Constructor & Destructor Documentation

◆ ~CTexture()

CTexture::~CTexture ( )
default

◆ CTexture()

CTexture::CTexture ( std::unique_ptr< Renderer::Backend::ITexture texture,
Renderer::Backend::ITexture fallback,
const CTextureProperties props,
CTextureManagerImpl textureManager 
)
explicitprivate

Member Function Documentation

◆ GetBackendTexture() [1/2]

Renderer::Backend::ITexture * CTexture::GetBackendTexture ( )

Returns a backend texture if successfully uploaded, else fallback.

◆ GetBackendTexture() [2/2]

const Renderer::Backend::ITexture * CTexture::GetBackendTexture ( ) const

◆ GetBaseColor()

u32 CTexture::GetBaseColor ( ) const

Returns the ARGB value of the lowest mipmap level (i.e.

the average of the whole texture). Returns 0 if the texture has no mipmaps.

◆ GetHeight()

size_t CTexture::GetHeight ( ) const

Returns the height (in pixels) of the current texture.

◆ GetUploadedSize()

size_t CTexture::GetUploadedSize ( ) const

Returns total number of bytes uploaded for this texture.

◆ GetWidth()

size_t CTexture::GetWidth ( ) const

Returns the width (in pixels) of the current texture.

◆ HasAlpha()

bool CTexture::HasAlpha ( ) const

Returns whether the current texture has an alpha channel.

◆ IsLoaded()

bool CTexture::IsLoaded ( ) const
inline

Returns whether the texture data is currently loaded.

◆ IsUploaded()

bool CTexture::IsUploaded ( ) const
inline

Returns whether the texture data is currently uploaded.

◆ NONCOPYABLE()

CTexture::NONCOPYABLE ( CTexture  )
private

◆ Prefetch()

void CTexture::Prefetch ( )

Activate the prefetching optimisation for this texture.

Use this if it is likely the texture will be needed in the near future. It will be loaded in the background so that it is likely to be ready when it is used by Bind().

◆ ResetBackendTexture()

void CTexture::ResetBackendTexture ( std::unique_ptr< Renderer::Backend::ITexture backendTexture,
Renderer::Backend::ITexture fallbackBackendTexture 
)
private

◆ TryLoad()

bool CTexture::TryLoad ( )

Attempt to load the texture data quickly, as with GetUploadedBackendTextureIfNeeded().

Returns whether the texture data is currently loaded (but not uploaded).

◆ UploadBackendTextureIfNeeded()

void CTexture::UploadBackendTextureIfNeeded ( Renderer::Backend::IDeviceCommandContext deviceCommandContext)

Uploads a texture data to a backend texture if successfully loaded.

If the texture data hasn't been loaded yet, this may wait a short while to load it. If loading takes too long then it will return sooner and the data will be loaded in a background thread, so this does not guarantee the texture really will be uploaded.

Friends And Related Function Documentation

◆ CPredefinedTexture

friend class CPredefinedTexture
friend

◆ CTextureManagerImpl

friend class CTextureManagerImpl
friend

◆ TextureCacheCmp

friend struct TextureCacheCmp
friend

◆ TPequal_to

friend struct TPequal_to
friend

◆ TPhash

friend struct TPhash
friend

Member Data Documentation

◆ m_BackendTexture

std::unique_ptr<Renderer::Backend::ITexture> CTexture::m_BackendTexture
private

◆ m_BaseColor

u32 CTexture::m_BaseColor
private

◆ m_BaseLevelOffset

uint32_t CTexture::m_BaseLevelOffset = 0
private

◆ m_FallbackBackendTexture

Renderer::Backend::ITexture* CTexture::m_FallbackBackendTexture = nullptr
private

◆ m_Properties

const CTextureProperties CTexture::m_Properties
private

◆ m_Self

std::weak_ptr<CTexture> CTexture::m_Self
private

◆ 

enum { ... } CTexture::m_State

◆ m_TextureData

std::unique_ptr<Tex> CTexture::m_TextureData
private

◆ m_TextureManager

CTextureManagerImpl* CTexture::m_TextureManager
private

◆ m_UploadedSize

size_t CTexture::m_UploadedSize = 0
private

The documentation for this class was generated from the following files: