OpenBarnyard
 
Loading...
Searching...
No Matches
TTextureFactory Class Referenceabstract

#include <TTextureFactory.h>

Inheritance diagram for TTextureFactory:
TResource TObject TNodeTree< T >::TNode TTextureFactoryHAL

Classes

class  NameEntry
 

Public Member Functions

 TDECLARE_CLASS (TTextureFactory, TResource)
 
 TTextureFactory ()=default
 
 ~TTextureFactory ()
 
virtual void Dump () const
 
virtual TTextureCreateTextureFromFile (const TCHAR *a_szFilePath, TUINT32 a_eTextureFlags)=0
 
virtual TTextureCreateTextureFromMemory (void *a_pData, TUINT a_uiDataSize, TUINT a_eTextureFlags, TUINT a_uiWidth, TUINT a_uiHeight)=0
 
virtual TTextureCreateEx (void *a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels, TTEXTURERESOURCEFORMAT a_eFormat, TUINT a_uiMipMapFlags)=0
 
virtual TTextureCreateFromT2Texture (T2Texture *a_pTexture)=0
 
TNodeList< NameEntry > * GetList (TUINT a_uiList)
 
TTextureFindTexture (const TCHAR *a_szName) const
 
NameEntryRegisterTexture (const TCHAR *a_szName, TTexture *a_pTexture)
 
void DeregisterTexture (TTexture *a_pTexture)
 
- Public Member Functions inherited from TResource
 TDECLARE_CLASS (TResource, TObject)
 
 TResource ()
 
 ~TResource ()
 
virtual TBOOL Create ()
 
virtual TBOOL Validate ()
 
virtual void Invalidate ()
 
virtual void DestroyResource ()
 
virtual TBOOL TryInvalidate ()
 
virtual TBOOL TryValidate ()
 
virtual void OnDestroy ()
 
TBOOL IsDead () const
 
TBOOL IsDying () const
 
TBOOL IsValid () const
 
TBOOL IsExternal () const
 
TBOOL IsCreated () const
 
TBOOL IsSceneObject () const
 
TBOOL IsInvalid () const
 
void SetState (TResourceState newState)
 
void AddState (TResourceState state)
 
void SetParent (TResource *a_pParent)
 
const TCHARGetName () const
 
void SetName (const TCHAR *name)
 
TBOOL RecurseSimple (t_RecurseCb a_pCallback, TResource *a_pResource, void *a_pUserData)
 
TRenderInterfaceGetRenderer () const
 
void SetRenderer (TRenderInterface *pRenderer)
 
TUINT32 GetUId () const
 
void SetUId (TUINT32 uid)
 
- Public Member Functions inherited from TObject
virtual Toshi::TClass * GetClass ()
 
virtual void Delete ()
 
virtual ~TObject ()
 
TBOOL IsExactly (TClass *a_pClass)
 
TBOOL IsA (TClass *a_pClass)
 
- Public Member Functions inherited from TNodeTree< T >::TNode
TBOOL IsChildOfDefaultRoot () const
 
TBOOL IsLinked () const
 
T * Parent () const
 
T * Next () const
 
T * Prev () const
 
TNodeTree< T > * Tree () const
 
T * Child () const
 

Static Public Member Functions

static TUINT32 HashName (const TCHAR *a_szName)
 
- Static Public Member Functions inherited from TResource
static TBOOL Recurse (t_RecurseCb a_pCallback, TResource *a_pResource, TBOOL a_bFlag, void *a_pUserData)
 
- Static Public Member Functions inherited from TObject
static Toshi::TObject * CreateTObject ()
 
static Toshi::TObject * CreateTObjectInPlace (void *a_pPtr)
 
static void InitialiseClass ()
 
static void DeinitialiseClass ()
 
static TFORCEINLINE TClassGetClassStatic ()
 

Static Public Attributes

static constexpr TUINT32 NUM_LISTS = 1024
 
- Static Public Attributes inherited from TResource
static constexpr size_t MAXNAMELEN = 14
 
- Static Public Attributes inherited from TObject
static constexpr Toshi::TClass * PARENTCLASS = TNULL
 
static constinit Toshi::TClass ms_oClass = Toshi::TClass( "TObject", TObject::CreateTObject, TObject::CreateTObjectInPlace, TObject::InitialiseClass, TObject::DeinitialiseClass, 0, 2, sizeof( TObject ), alignof( TObject ) )
 

Additional Inherited Members

- Public Types inherited from TResource
using t_RecurseCb = TBOOL ( * )( TResource* a_pResource, void* a_pUserData )
 
- Public Types inherited from TObject
enum  { IsTObject = TTRUE }
 
- Public Attributes inherited from TResource
friend TRenderInterface
 
- Public Attributes inherited from TNodeTree< T >::TNode
friend TNodeTree
 
- Protected Member Functions inherited from TNodeTree< T >::TNode
 TNode ()
 
- Protected Attributes inherited from TNodeTree< T >::TNode
TNodeTree< T > * m_Tree
 
T * m_Next
 
T * m_Prev
 
T * m_Parent
 
T * m_Child
 

Detailed Description

Definition at line 12 of file TTextureFactory.h.

Constructor & Destructor Documentation

◆ TTextureFactory()

TTextureFactory::TTextureFactory ( )
default

◆ ~TTextureFactory()

TTextureFactory::~TTextureFactory ( )

Definition at line 29 of file TTextureFactory.cpp.

30{
31 for ( TUINT32 i = 0; i < NUM_LISTS; i++ )
32 {
33 m_aLists[ i ].DeleteAll();
34 }
35}
uint32_t TUINT32
Definition Typedefs.h:13
static constexpr TUINT32 NUM_LISTS

Member Function Documentation

◆ CreateEx()

virtual TTexture * TTextureFactory::CreateEx ( void * a_pData,
TUINT a_uiDataSize,
TUINT a_uiWidth,
TUINT a_uiHeight,
TUINT a_uiMipLevels,
TTEXTURERESOURCEFORMAT a_eFormat,
TUINT a_uiMipMapFlags )
pure virtual

Implemented in TTextureFactoryHAL.

◆ CreateFromT2Texture()

virtual TTexture * TTextureFactory::CreateFromT2Texture ( T2Texture * a_pTexture)
pure virtual

Implemented in TTextureFactoryHAL.

◆ CreateTextureFromFile()

virtual TTexture * TTextureFactory::CreateTextureFromFile ( const TCHAR * a_szFilePath,
TUINT32 a_eTextureFlags )
pure virtual

Implemented in TTextureFactoryHAL.

◆ CreateTextureFromMemory()

virtual TTexture * TTextureFactory::CreateTextureFromMemory ( void * a_pData,
TUINT a_uiDataSize,
TUINT a_eTextureFlags,
TUINT a_uiWidth,
TUINT a_uiHeight )
pure virtual

Implemented in TTextureFactoryHAL.

◆ DeregisterTexture()

void TTextureFactory::DeregisterTexture ( TTexture * a_pTexture)

Definition at line 82 of file TTextureFactory.cpp.

83{
84 TVALIDPTR( a_pTexture );
85
86 auto pNameEntry = a_pTexture->m_pNameEntry;
87
88 if ( pNameEntry )
89 {
90 pNameEntry->Remove();
91 delete pNameEntry;
92 }
93}
#define TVALIDPTR(PTR)
Definition Defines.h:139
TTextureFactory::NameEntry * m_pNameEntry
Definition TTexture.h:78

◆ Dump()

void TTextureFactory::Dump ( ) const
virtual

Definition at line 37 of file TTextureFactory.cpp.

38{
39 TUINT uiTexIndex = 0;
40
41 for ( TUINT32 i = 0; i < NUM_LISTS; i++ )
42 {
43 for ( auto it = m_aLists[ i ].Begin(); it != m_aLists[ i ].End(); it++ )
44 {
45 TTRACE( "[%d] Texture [%s]: W=%d , H=%d\n", uiTexIndex++, it->GetName(), it->GetTexture()->GetWidth(), it->GetTexture()->GetHeight() );
46 }
47 }
48}
#define TTRACE(...)
Definition Defines.h:155
unsigned int TUINT
Definition Typedefs.h:8

◆ FindTexture()

TTexture * TTextureFactory::FindTexture ( const TCHAR * a_szName) const

Definition at line 56 of file TTextureFactory.cpp.

57{
58 auto pList = &m_aLists[ HashName( a_szName ) ];
59
60 for ( auto it = pList->Begin(); it != pList->End(); it++ )
61 {
62 if ( 0 == TStringManager::String8CompareNoCase( it->GetName(), a_szName ) )
63 {
64 return it->GetTexture();
65 }
66 }
67
68 return TNULL;
69}
#define TNULL
Definition Typedefs.h:23
static TUINT32 HashName(const TCHAR *a_szName)
static TINT String8CompareNoCase(const TCHAR *str1, const TCHAR *str2, TSIZE size=-1)

◆ GetList()

TNodeList< TTextureFactory::NameEntry > * TTextureFactory::GetList ( TUINT a_uiList)

Definition at line 50 of file TTextureFactory.cpp.

51{
52 TASSERT( a_uiList < NUM_LISTS );
53 return &m_aLists[ a_uiList ];
54}
#define TASSERT(X,...)
Definition Defines.h:138

◆ HashName()

TUINT32 TTextureFactory::HashName ( const TCHAR * a_szName)
static

Definition at line 95 of file TTextureFactory.cpp.

96{
97 TUINT32 iHash = 0;
98
99 for ( TSIZE i = 0; i < TStringManager::String8Length( a_szName ); i++ )
100 {
101 iHash += a_szName[ i ];
102 }
103
104 return iHash % NUM_LISTS;
105}
size_t TSIZE
Definition Typedefs.h:9
static TSIZE String8Length(const TCHAR *str)

◆ RegisterTexture()

TTextureFactory::NameEntry * TTextureFactory::RegisterTexture ( const TCHAR * a_szName,
TTexture * a_pTexture )

Definition at line 71 of file TTextureFactory.cpp.

72{
73 auto pList = &m_aLists[ HashName( a_szName ) ];
74 auto pEntry = new TTextureFactory::NameEntry( a_szName, a_pTexture );
75
76 a_pTexture->m_pNameEntry = pEntry;
77 pList->InsertHead( pEntry );
78
79 return a_pTexture->m_pNameEntry;
80}

◆ TDECLARE_CLASS()

TTextureFactory::TDECLARE_CLASS ( TTextureFactory ,
TResource  )

Member Data Documentation

◆ NUM_LISTS

TUINT32 TTextureFactory::NUM_LISTS = 1024
staticconstexpr

Definition at line 35 of file TTextureFactory.h.


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