Rose
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rose::sdl::TextureData Class Reference

A Texture with associated meta data. More...

#include <Texture.h>

Inheritance diagram for rose::sdl::TextureData:
Inheritance graph
[legend]
Collaboration diagram for rose::sdl::TextureData:
Collaboration graph
[legend]

Public Member Functions

 TextureData ()=default
 Default constructor. More...
 
 TextureData (const TextureData &)=delete
 Deleted copy constructor.
 
TextureDataoperator= (const TextureData &)=delete
 Deleted const copy constructor.
 
 TextureData (Renderer &renderer, SDL_PixelFormatEnum format, SDL_TextureAccess access, int width, int height)
 Constructor More...
 
 TextureData (Renderer &renderer, Size size)
 Constructor. More...
 
 TextureData (Texture &&texture) noexcept
 Move constructor. More...
 
 TextureData (SDL_Texture *texture) noexcept
 Construct a new TextureData from an SDL_Texture pointer. More...
 
 TextureData (TextureData &&other) noexcept=default
 Move constructor. More...
 
TextureDataoperator= (TextureData &&other) noexcept=default
 Move assignment. More...
 
TextureDataoperator= (SDL_Texture *texture)
 Assign an SDL_Texture pointer to this object. More...
 
bool expired () const noexcept
 Determine if the texture has expired. More...
 
bool dirty () const noexcept
 Determine if the texture is dirty. More...
 
void setDirty (bool dirty)
 Set the texture dirty status. More...
 
std::string_view getPath ()
 Get the path member. More...
 
std::string_view getPath () const
 Get the path member from a const TextureData object. More...
 
template<typename StringType >
void setPath (const StringType path)
 Assign a new value to the path member. More...
 
std::string_view getURI ()
 Get the URI member. More...
 
std::string_view getURI () const
 Get the URI member from a const TextureData object. More...
 
template<typename StringType >
void setURI (const StringType URI)
 Assign a new value to the URI member. More...
 
std::string_view getName ()
 Get the Name member. More...
 
std::string_view getName () const
 Get the Name member from a const TextureData object. More...
 
template<typename StringType >
void setName (const StringType Name)
 Assign a new value to the Name member. More...
 
void setLoadedTime (const std::chrono::time_point< std::chrono::system_clock > loaded)
 Set the time the texture was loaded. More...
 
void setScale (int scale)
 Set the scale value associated with the texture. More...
 
int getScale () const
 Get the scale value associate with the texture. More...
 
Size getSize () const
 Get the icon size. More...
 
void getRectangle (SDL_Rect &rect) const
 Populate an SDL_Rect with size of the texture with a Zero position. More...
 
Rectangle getRectangle () const
 Return a Rectangle with the size of the texture and Zero position. More...
 
void setSize (Size size)
 Set the size of the Texture. More...
 
- Public Member Functions inherited from rose::sdl::Texture
 Texture (const Texture &)=delete
 
 Texture (Texture &&)=default
 
Textureoperator= (const Texture &)=delete
 
Textureoperator= (Texture &&texture)=default
 
 Texture (SDL_Texture *texture)
 
 Texture (Renderer &renderer, SDL_PixelFormatEnum format, SDL_TextureAccess access, int width, int height)
 Constructor More...
 
 Texture (Renderer &renderer, Size size)
 Constructor. More...
 
int setBlendMOde (SDL_BlendMode blendMode)
 
std::tuple< int, int > getSize () const noexcept
 

Protected Member Functions

void setMetaData ()
 Set the class meta data from the texture.
 

Protected Attributes

Size mSize
 The size of the texture.
 
int mScale
 Store a scale value for use by library or application programs. The Sprite class uses this field. More...
 
uint32_t mFormat {}
 The Format of the texture.
 
int mAccess {}
 The Access mode of the texture.
 
std::string mPath
 The path name to the source of the texture on the local file system.
 
std::string mURI
 The URI of the source of the texture.
 
std::string mName
 A name this image may be known by. More...
 
bool mDirty {true}
 A flag indicating the image needs to be regenerated or reloaded.
 
std::chrono::time_point< std::chrono::system_clock > mLoaded {}
 The time the texture was generated or loaded.
 
std::chrono::time_point< std::chrono::system_clock > mLife {}
 The time when the texture should be regenerated or reloaded.
 

Detailed Description

A Texture with associated meta data.

Constructor & Destructor Documentation

◆ TextureData() [1/6]

rose::sdl::TextureData::TextureData ( )
default

Default constructor.

Constructs an empty, expired, dirty objects.

◆ TextureData() [2/6]

rose::sdl::TextureData::TextureData ( Renderer renderer,
SDL_PixelFormatEnum  format,
SDL_TextureAccess  access,
int  width,
int  height 
)
inline

Constructor

Parameters
rendererThe Renderer to use.
formatThe pixel format from SDL_PixelFormatEnum.
accessThe Texture access from SDL_TextureAccess.
widthThe width of the texture.
heightThe height of the texture.

◆ TextureData() [3/6]

rose::sdl::TextureData::TextureData ( Renderer renderer,
Size  size 
)
inline

Constructor.

Builds a TextureData object compatible with building up textures within Rose . The pixel format is SDL_PIXELFORMAT_RGBA8888, the texture access is SDL_TEXTUREACCESS_TARGET.

Parameters
rendererThe renderer to use.
sizeThe size of the texture.

◆ TextureData() [4/6]

rose::sdl::TextureData::TextureData ( Texture &&  texture)
inlineexplicitnoexcept

Move constructor.

The Texture meta data is set from the new texture.

Parameters
texturethe texture to move into the TextureData object

◆ TextureData() [5/6]

rose::sdl::TextureData::TextureData ( SDL_Texture *  texture)
inlineexplicitnoexcept

Construct a new TextureData from an SDL_Texture pointer.

The SDL_Texture pointer is used to reset the std::unique_ptr and the texture meta data is set from the texture.

Parameters
textureSDL_Texture*

◆ TextureData() [6/6]

rose::sdl::TextureData::TextureData ( TextureData &&  other)
defaultnoexcept

Move constructor.

Parameters
otherthe object to move.

Member Function Documentation

◆ dirty()

bool rose::sdl::TextureData::dirty ( ) const
inlinenoexcept

Determine if the texture is dirty.

Returns
return the internal dirty flag.

◆ expired()

bool rose::sdl::TextureData::expired ( ) const
inlinenoexcept

Determine if the texture has expired.

Returns
true if mLife is in the past.

◆ getName() [1/2]

std::string_view rose::sdl::TextureData::getName ( )
inline

Get the Name member.

Returns
a view of the Name member variable.

◆ getName() [2/2]

std::string_view rose::sdl::TextureData::getName ( ) const
inline

Get the Name member from a const TextureData object.

Returns
a const view of the Name member variable.

◆ getPath() [1/2]

std::string_view rose::sdl::TextureData::getPath ( )
inline

Get the path member.

Returns
a view of the path member variable.

◆ getPath() [2/2]

std::string_view rose::sdl::TextureData::getPath ( ) const
inline

Get the path member from a const TextureData object.

Returns
a const view of the path member varialbe.

◆ getRectangle() [1/2]

void rose::sdl::TextureData::getRectangle ( SDL_Rect &  rect) const
inline

Populate an SDL_Rect with size of the texture with a Zero position.

Parameters
rectA reference to an SDL_Rect.

◆ getRectangle() [2/2]

Rectangle rose::sdl::TextureData::getRectangle ( ) const
inline

Return a Rectangle with the size of the texture and Zero position.

Returns
The Rectangle.

◆ getScale()

int rose::sdl::TextureData::getScale ( ) const
inline

Get the scale value associate with the texture.

Returns
the scale factor

◆ getSize()

Size rose::sdl::TextureData::getSize ( ) const
inline

Get the icon size.

Returns
a SizeInt.

◆ getURI() [1/2]

std::string_view rose::sdl::TextureData::getURI ( )
inline

Get the URI member.

Returns
a view of the URI member variable.

◆ getURI() [2/2]

std::string_view rose::sdl::TextureData::getURI ( ) const
inline

Get the URI member from a const TextureData object.

Returns
a const view of the URI member variable.

◆ operator=() [1/2]

TextureData& rose::sdl::TextureData::operator= ( TextureData &&  other)
defaultnoexcept

Move assignment.

Parameters
otherthe object to assign.
Returns
A reference to this object.

◆ operator=() [2/2]

TextureData& rose::sdl::TextureData::operator= ( SDL_Texture *  texture)
inline

Assign an SDL_Texture pointer to this object.

The Texture meta data is set from the new texture.

Parameters
texturethe pointer to the texture.
Returns
A reference to this object.

◆ setDirty()

void rose::sdl::TextureData::setDirty ( bool  dirty)
inline

Set the texture dirty status.

Parameters
dirtythe value to copy into the internal dirty flag.

◆ setLoadedTime()

void rose::sdl::TextureData::setLoadedTime ( const std::chrono::time_point< std::chrono::system_clock >  loaded)
inline

Set the time the texture was loaded.

Parameters
loadedthe time point of loading.

◆ setName()

template<typename StringType >
void rose::sdl::TextureData::setName ( const StringType  Name)
inline

Assign a new value to the Name member.

Template Parameters
StringTypeany type which may be assigned to a std::string
Parameters
Namethe new value.

◆ setPath()

template<typename StringType >
void rose::sdl::TextureData::setPath ( const StringType  path)
inline

Assign a new value to the path member.

Template Parameters
StringTypeany type which may be assigned to a std::string
Parameters
paththe new value.

◆ setScale()

void rose::sdl::TextureData::setScale ( int  scale)
inline

Set the scale value associated with the texture.

Parameters
scalethe scale factor

◆ setSize()

void rose::sdl::TextureData::setSize ( Size  size)
inline

Set the size of the Texture.

Not recommended to be used by application. The size is set when a Texture is assigned to the object.

Parameters
sizeThe Texture SizeInt.

◆ setURI()

template<typename StringType >
void rose::sdl::TextureData::setURI ( const StringType  URI)
inline

Assign a new value to the URI member.

Template Parameters
StringTypeany type which may be assigned to a std::string
Parameters
URIthe new value.

Member Data Documentation

◆ mName

std::string rose::sdl::TextureData::mName
protected

A name this image may be known by.

Use of this field is at the discretion of the user application.

◆ mScale

int rose::sdl::TextureData::mScale
protected
Initial value:
{
1}

Store a scale value for use by library or application programs. The Sprite class uses this field.


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