LCOV - code coverage report
Current view: top level - source/gui - CGUISprite.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 28 0.0 %
Date: 2026-12-03 01:19:39 Functions: 0 9 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2025 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       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.
       8             :  *
       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.
      13             :  *
      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/>.
      16             :  */
      17             : 
      18             : #include "precompiled.h"
      19             : 
      20             : #include "CGUISprite.h"
      21             : 
      22             : #include <utility>
      23             : 
      24           0 : CGUISprite::~CGUISprite() = default;
      25             : 
      26           0 : void CGUISprite::AddImage(std::unique_ptr<SGUIImage> image)
      27             : {
      28           0 :     m_Images.emplace_back(std::move(image));
      29           0 : }
      30             : 
      31           0 : void CGUISpriteInstance::Draw(CGUI& pGUI, CCanvas2D& canvas, const CRect& Size, std::map<CStr, std::unique_ptr<const CGUISprite>>& Sprites) const
      32             : {
      33           0 :     if (m_CachedSize != Size)
      34             :     {
      35           0 :         GUIRenderer::UpdateDrawCallCache(pGUI, m_DrawCallCache, m_SpriteName, Size, m_RoundCoordinates, Sprites);
      36           0 :         m_CachedSize = Size;
      37             :     }
      38           0 :     GUIRenderer::Draw(m_DrawCallCache, canvas);
      39           0 : }
      40             : 
      41             : // Plus a load of constructors / assignment operators, which don't copy the
      42             : // DrawCall cache (to avoid losing track of who has allocated various bits
      43             : // of data):
      44             : 
      45           0 : CGUISpriteInstance::CGUISpriteInstance()
      46             : {
      47           0 : }
      48             : 
      49           0 : CGUISpriteInstance::CGUISpriteInstance(const CStr& SpriteName)
      50           0 :     : m_SpriteName(SpriteName), m_RoundCoordinates(true)
      51             : {
      52           0 : }
      53             : 
      54           0 : CGUISpriteInstance::CGUISpriteInstance(const CStr& SpriteName, const bool RoundCoordinates)
      55           0 :     : m_SpriteName(SpriteName), m_RoundCoordinates(RoundCoordinates)
      56             : {
      57           0 : }
      58             : 
      59           0 : void CGUISpriteInstance::SetName(const CStr& SpriteName)
      60             : {
      61           0 :     m_SpriteName = SpriteName;
      62           0 :     m_CachedSize = CRect();
      63           0 :     m_DrawCallCache.clear();
      64           0 : }
      65             : 
      66           0 : void CGUISpriteInstance::SetRoundCoordinates(const bool RoundCoordinates)
      67             : {
      68           0 :     m_RoundCoordinates = RoundCoordinates;
      69           0 :     m_CachedSize = CRect();
      70           0 :     m_DrawCallCache.clear();
      71           0 : }

Generated by: LCOV version 1.16