Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/Color.cpp
Show All 14 Lines | |||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "graphics/Color.h" | #include "graphics/Color.h" | ||||
#include "graphics/SColor.h" | #include "graphics/SColor.h" | ||||
#include "lib/sse.h" | |||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/CStr.h" | #include "ps/CStr.h" | ||||
#if HAVE_SSE | #if HAVE_SSE | ||||
# include <xmmintrin.h> | # include <xmmintrin.h> | ||||
# include "lib/sysdep/arch/x86_x64/x86_x64.h" | |||||
#endif | #endif | ||||
wraitii: Probably better to include lib/sse always, and only include the intrinsic if HAVE_SSE. | |||||
static SColor4ub fallback_ConvertRGBColorTo4ub(const RGBColor& src) | static SColor4ub fallback_ConvertRGBColorTo4ub(const RGBColor& src) | ||||
{ | { | ||||
SColor4ub result; | SColor4ub result; | ||||
result.R = Clamp(static_cast<int>(src.X * 255), 0, 255); | result.R = Clamp(static_cast<int>(src.X * 255), 0, 255); | ||||
result.G = Clamp(static_cast<int>(src.Y * 255), 0, 255); | result.G = Clamp(static_cast<int>(src.Y * 255), 0, 255); | ||||
result.B = Clamp(static_cast<int>(src.Z * 255), 0, 255); | result.B = Clamp(static_cast<int>(src.Z * 255), 0, 255); | ||||
result.A = 255; | result.A = 255; | ||||
Show All 34 Lines | static SColor4ub sse_ConvertRGBColorTo4ub(const RGBColor& src) | ||||
return SColor4ub(ri, gi, bi, 0xFF); | return SColor4ub(ri, gi, bi, 0xFF); | ||||
} | } | ||||
#endif | #endif | ||||
void ColorActivateFastImpl() | void ColorActivateFastImpl() | ||||
{ | { | ||||
#if HAVE_SSE | #if HAVE_SSE | ||||
if (x86_x64::Cap(x86_x64::CAP_SSE)) | if (HasSSE()) | ||||
{ | |||||
ConvertRGBColorTo4ub = sse_ConvertRGBColorTo4ub; | ConvertRGBColorTo4ub = sse_ConvertRGBColorTo4ub; | ||||
return; | |||||
} | |||||
#endif | #endif | ||||
debug_printf("No SSE available. Slow fallback routines will be used.\n"); | |||||
} | } | ||||
/** | /** | ||||
* Important: This function does not modify the value if parsing fails. | * Important: This function does not modify the value if parsing fails. | ||||
*/ | */ | ||||
bool CColor::ParseString(const CStr8& value, int defaultAlpha) | bool CColor::ParseString(const CStr8& value, int defaultAlpha) | ||||
{ | { | ||||
const size_t NUM_VALS = 4; | const size_t NUM_VALS = 4; | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Probably better to include lib/sse always, and only include the intrinsic if HAVE_SSE.