Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 this->red = red; | 29 this->red = red; |
| 30 this->alpha = alpha; | 30 this->alpha = alpha; |
| 31 } | 31 } |
| 32 | 32 |
| 33 RgbaColor::RgbaColor(uint8_t blue, uint8_t green, uint8_t red) | 33 RgbaColor::RgbaColor(uint8_t blue, uint8_t green, uint8_t red) |
| 34 : RgbaColor(blue, green, red, 0xff) {} | 34 : RgbaColor(blue, green, red, 0xff) {} |
| 35 | 35 |
| 36 RgbaColor::RgbaColor(const uint8_t* bgra) | 36 RgbaColor::RgbaColor(const uint8_t* bgra) |
| 37 : RgbaColor(bgra[0], bgra[1], bgra[2], bgra[3]) {} | 37 : RgbaColor(bgra[0], bgra[1], bgra[2], bgra[3]) {} |
| 38 | 38 |
| 39 RgbaColor::RgbaColor(uint32_t bgra) | |
| 40 : RgbaColor(reinterpret_cast<uint8_t*>(&bgra)) {} | |
| 41 | |
| 39 bool RgbaColor::operator==(const RgbaColor& right) const { | 42 bool RgbaColor::operator==(const RgbaColor& right) const { |
| 40 return blue == right.blue && green == right.green && red == right.red && | 43 return blue == right.blue && green == right.green && red == right.red && |
| 41 AlphaEquals(alpha, right.alpha); | 44 AlphaEquals(alpha, right.alpha); |
| 42 } | 45 } |
| 43 | 46 |
| 44 bool RgbaColor::operator!=(const RgbaColor& right) const { | 47 bool RgbaColor::operator!=(const RgbaColor& right) const { |
| 45 return !(*this == right); | 48 return !(*this == right); |
| 46 } | 49 } |
| 47 | 50 |
| 51 uint32_t RgbaColor::ToUInt32() const { | |
| 52 return *(reinterpret_cast<const uint32_t*>(&blue)); | |
|
Sergey Ulanov
2016/09/13 00:47:48
I don't think you can use reinterpret_cast<> here
Hzj_jie
2016/09/13 18:48:10
I think the endian will be broken by using shift,
Sergey Ulanov
2016/09/19 20:35:28
All platforms we currently support are little-endi
Hzj_jie
2016/09/20 00:00:08
Done.
| |
| 53 } | |
| 54 | |
| 48 } // namespace webrtc | 55 } // namespace webrtc |
| OLD | NEW |