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 : #ifndef INCLUDED_GUIRENDERER 19 : #define INCLUDED_GUIRENDERER 20 : 21 : #include "graphics/Color.h" 22 : #include "graphics/Texture.h" 23 : #include "maths/Rect.h" 24 : 25 : #include <map> 26 : #include <memory> 27 : #include <vector> 28 : 29 : class CCanvas2D; 30 : class CGUI; 31 : class CGUISprite; 32 : class CStr8; 33 : struct CGUIColor; 34 : struct SGUIImage; 35 : 36 : namespace GUIRenderer 37 : { 38 0 : struct SDrawCall 39 : { 40 0 : SDrawCall(const SGUIImage* image) : m_Image(image) {} 41 : CRect ComputeTexCoords() const; 42 : 43 : const SGUIImage* m_Image; 44 : 45 : CTexturePtr m_Texture; 46 : 47 : CRect m_ObjectSize; 48 : CRect m_Vertices; 49 : 50 : CGUIColor* m_BackColor; 51 : 52 : CColor m_ColorAdd; 53 : CColor m_ColorMultiply; 54 : float m_GrayscaleFactor; 55 : }; 56 : 57 0 : class DrawCalls : public std::vector<SDrawCall> 58 : { 59 : public: 60 : DrawCalls(); 61 : // Copy/assignment results in an empty list, not an actual copy 62 : DrawCalls(const DrawCalls&); 63 : DrawCalls& operator=(const DrawCalls&); 64 : }; 65 : 66 : void UpdateDrawCallCache(const CGUI& pGUI, DrawCalls& Calls, const CStr8& SpriteName, const CRect& Size, const bool RoundCoordinates, std::map<CStr8, std::unique_ptr<const CGUISprite>>& Sprites); 67 : 68 : void Draw(DrawCalls& Calls, CCanvas2D& canvas); 69 : } 70 : 71 : #endif // INCLUDED_GUIRENDERER