Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/CGUISprite.cpp
Show All 24 Lines | for (SGUIImage* const& img : m_Images) | ||||
delete img; | delete img; | ||||
} | } | ||||
void CGUISprite::AddImage(SGUIImage* image) | void CGUISprite::AddImage(SGUIImage* image) | ||||
{ | { | ||||
m_Images.push_back(image); | m_Images.push_back(image); | ||||
} | } | ||||
void CGUISpriteInstance::Draw(CRect Size, int CellID, std::map<CStr, CGUISprite*>& Sprites, float Z) const | void CGUISpriteInstance::Draw(const CRect& Size, int CellID, std::map<CStr, CGUISprite*>& Sprites, float Z) const | ||||
{ | { | ||||
if (m_CachedSize != Size || m_CachedCellID != CellID) | if (m_CachedSize != Size || m_CachedCellID != CellID) | ||||
{ | { | ||||
GUIRenderer::UpdateDrawCallCache(m_DrawCallCache, m_SpriteName, Size, CellID, Sprites); | GUIRenderer::UpdateDrawCallCache(m_DrawCallCache, m_SpriteName, Size, CellID, Sprites); | ||||
m_CachedSize = Size; | m_CachedSize = Size; | ||||
m_CachedCellID = CellID; | m_CachedCellID = CellID; | ||||
} | } | ||||
GUIRenderer::Draw(m_DrawCallCache, Z); | GUIRenderer::Draw(m_DrawCallCache, Z); | ||||
} | } | ||||
void CGUISpriteInstance::Invalidate() | |||||
{ | |||||
m_CachedSize = CRect(); | |||||
m_CachedCellID = -1; | |||||
} | |||||
bool CGUISpriteInstance::IsEmpty() const | bool CGUISpriteInstance::IsEmpty() const | ||||
{ | { | ||||
return m_SpriteName.empty(); | return m_SpriteName.empty(); | ||||
} | } | ||||
// Plus a load of constructors / assignment operators, which don't copy the | // Plus a load of constructors / assignment operators, which don't copy the | ||||
// DrawCall cache (to avoid losing track of who has allocated various bits | // DrawCall cache (to avoid losing track of who has allocated various bits | ||||
// of data): | // of data): | ||||
CGUISpriteInstance::CGUISpriteInstance() | CGUISpriteInstance::CGUISpriteInstance() | ||||
: m_CachedCellID(-1) | : m_CachedCellID(-1) | ||||
{ | { | ||||
} | } | ||||
CGUISpriteInstance::CGUISpriteInstance(const CStr& SpriteName) | CGUISpriteInstance::CGUISpriteInstance(const CStr& SpriteName) | ||||
: m_SpriteName(SpriteName), m_CachedCellID(-1) | : m_SpriteName(SpriteName), m_CachedCellID(-1) | ||||
{ | { | ||||
} | } | ||||
CGUISpriteInstance::CGUISpriteInstance(const CGUISpriteInstance& Sprite) | void CGUISpriteInstance::SetName(const CStr& SpriteName) | ||||
: m_SpriteName(Sprite.m_SpriteName), m_CachedCellID(-1) | |||||
{ | |||||
} | |||||
CGUISpriteInstance& CGUISpriteInstance::operator=(const CGUISpriteInstance& Sprite) | |||||
{ | |||||
return this->operator=(Sprite.m_SpriteName); | |||||
} | |||||
CGUISpriteInstance& CGUISpriteInstance::operator=(const CStr& SpriteName) | |||||
{ | { | ||||
m_SpriteName = SpriteName; | m_SpriteName = SpriteName; | ||||
m_CachedSize = CRect(); | |||||
m_DrawCallCache.clear(); | m_DrawCallCache.clear(); | ||||
Invalidate(); | m_CachedCellID = -1; | ||||
return *this; | |||||
} | } | ||||
Wildfire Games · Phabricator