1// 2// Copyright 2016 The ANGLE Project Authors. All rights reserved. 3// Use of this source code is governed by a BSD-style license that can be 4// found in the LICENSE file. 5// 6 7// Color.inc : Inline definitions of some functions from Color.h 8 9namespace angle 10{ 11 12template <typename T> 13Color<T>::Color() : Color(0, 0, 0, 0) 14{ 15} 16 17template <typename T> 18constexpr Color<T>::Color(T r, T g, T b, T a) : red(r), green(g), blue(b), alpha(a) 19{ 20} 21 22template <typename T> 23bool operator==(const Color<T> &a, const Color<T> &b) 24{ 25 return a.red == b.red && 26 a.green == b.green && 27 a.blue == b.blue && 28 a.alpha == b.alpha; 29} 30 31template <typename T> 32bool operator!=(const Color<T> &a, const Color<T> &b) 33{ 34 return !(a == b); 35} 36 37 38ColorGeneric::ColorGeneric() : colorF(), type(Type::Float) {} 39 40ColorGeneric::ColorGeneric(const ColorF &color) : colorF(color), type(Type::Float) {} 41 42ColorGeneric::ColorGeneric(const ColorI &color) : colorI(color), type(Type::Int) {} 43 44ColorGeneric::ColorGeneric(const ColorUI &color) : colorUI(color), type(Type::UInt) {} 45 46bool operator==(const ColorGeneric &a, const ColorGeneric &b) 47{ 48 // Switching on the type and comparing individual 49 // channels yield much less efficient code. 50 return memcmp(&a, &b, sizeof(ColorGeneric)) == 0; 51} 52 53bool operator!=(const ColorGeneric &a, const ColorGeneric &b) 54{ 55 return !(a == b); 56} 57 58} // namespace angle 59