mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 14:23:56 -07:00
Avoid color copies for rendering Draw calls in GUIRenderer::UpdateDrawCallCache, CButton::Draw, CChart::DrawAxes, CDropDown::Draw, CList::DrawList, COList::DrawList, refs #1984,8f4f8e240f,3028551b91,a905fbbc98. Avoid color copies during XML loading in CGUI::Xeromyces_ReadImage, CGUI::Xeromyces_ReadEffects, COList::HandleAdditionalChildren. Add CGUI::HasPreDefinedColor and mark m_PreDefinedColors, CGUI::GetPreDefinedColor, IGUIButtonBehavior::ChooseColor() as const for consistency with the other "databases", refs3028551b91. Mark CGUIColor as NONCOPYABLE to add compiler errors if there is an unexplicit copy, refs3028551b91. Explicit ugly copy in CGUI::Xeromyces_ReadColor and CGUIColor::ParseString. Deregister copying <CGUIColor>GetSetting functions, refs8f4f8e240f. Uses the const ref GetSetting from3dfa23cd25. This was SVN commit r22694.
39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
/* Copyright (C) 2019 Wildfire Games.
|
|
* This file is part of 0 A.D.
|
|
*
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "precompiled.h"
|
|
|
|
#include "CGUIColor.h"
|
|
#include "ps/CStr.h"
|
|
#include "gui/CGUI.h"
|
|
|
|
bool CGUIColor::ParseString(const CGUI* pGUI, const CStr& value, int defaultAlpha)
|
|
{
|
|
if (pGUI != nullptr && pGUI->HasPreDefinedColor(value))
|
|
{
|
|
const CGUIColor& color = pGUI->GetPreDefinedColor(value);
|
|
|
|
// Explicit copy assignment
|
|
r = color.r;
|
|
g = color.g;
|
|
b = color.b;
|
|
a = color.a;
|
|
return true;
|
|
}
|
|
|
|
return CColor::ParseString(value, defaultAlpha);
|
|
}
|