tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Color.inc (1599B)


      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 
      9 namespace angle
     10 {
     11 
     12 template <typename T>
     13 Color<T>::Color() : Color(0, 0, 0, 0)
     14 {
     15 }
     16 
     17 template <typename T>
     18 constexpr Color<T>::Color(T r, T g, T b, T a) : red(r), green(g), blue(b), alpha(a)
     19 {
     20 }
     21 
     22 template <typename T>
     23 bool 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 
     31 template <typename T>
     32 bool operator!=(const Color<T> &a, const Color<T> &b)
     33 {
     34    return !(a == b);
     35 }
     36 
     37 
     38 ColorGeneric::ColorGeneric() : colorF(), type(Type::Float) {}
     39 
     40 ColorGeneric::ColorGeneric(const ColorF &color) : colorF(color), type(Type::Float) {}
     41 
     42 ColorGeneric::ColorGeneric(const ColorI &color) : colorI(color), type(Type::Int) {}
     43 
     44 ColorGeneric::ColorGeneric(const ColorUI &color) : colorUI(color), type(Type::UInt) {}
     45 
     46 bool 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 
     64 bool operator!=(const ColorGeneric &a, const ColorGeneric &b)
     65 {
     66    return !(a == b);
     67 }
     68 
     69 }  // namespace angle