• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    if (a.type != b.type)
49    {
50        return false;
51    }
52    switch (a.type)
53    {
54        default:
55        case ColorGeneric::Type::Float:
56            return a.colorF == b.colorF;
57        case ColorGeneric::Type::Int:
58            return a.colorI == b.colorI;
59        case ColorGeneric::Type::UInt:
60            return a.colorUI == b.colorUI;
61    }
62}
63
64bool operator!=(const ColorGeneric &a, const ColorGeneric &b)
65{
66    return !(a == b);
67}
68
69}  // namespace angle
70