1 /* Copyright (C) 2021 Wildfire Games.
2 * This file is part of 0 A.D.
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
18 #include "precompiled.h"
20 #include "CGUISprite.h"
22 CGUISprite::~CGUISprite() = default;
24 void CGUISprite::AddImage(std::unique_ptr
<SGUIImage
> image
)
26 m_Images
.emplace_back(std::move(image
));
29 void CGUISpriteInstance::Draw(CGUI
& pGUI
, CCanvas2D
& canvas
, const CRect
& Size
, std::map
<CStr
, std::unique_ptr
<const CGUISprite
>>& Sprites
) const
31 if (m_CachedSize
!= Size
)
33 GUIRenderer::UpdateDrawCallCache(pGUI
, m_DrawCallCache
, m_SpriteName
, Size
, Sprites
);
36 GUIRenderer::Draw(m_DrawCallCache
, canvas
);
39 // Plus a load of constructors / assignment operators, which don't copy the
40 // DrawCall cache (to avoid losing track of who has allocated various bits
43 CGUISpriteInstance::CGUISpriteInstance()
47 CGUISpriteInstance::CGUISpriteInstance(const CStr
& SpriteName
)
48 : m_SpriteName(SpriteName
)
52 void CGUISpriteInstance::SetName(const CStr
& SpriteName
)
54 m_SpriteName
= SpriteName
;
55 m_CachedSize
= CRect();
56 m_DrawCallCache
.clear();