Chromium Code Reviews| Index: webrtc/modules/desktop_capture/rgba_color.cc |
| diff --git a/webrtc/modules/desktop_capture/rgba_color.cc b/webrtc/modules/desktop_capture/rgba_color.cc |
| index 2342b46915061a62926149c8464f7ed0590eec44..89212ef3eb5f9d041273265dfe078ca8e680a70a 100644 |
| --- a/webrtc/modules/desktop_capture/rgba_color.cc |
| +++ b/webrtc/modules/desktop_capture/rgba_color.cc |
| @@ -36,6 +36,9 @@ RgbaColor::RgbaColor(uint8_t blue, uint8_t green, uint8_t red) |
| RgbaColor::RgbaColor(const uint8_t* bgra) |
| : RgbaColor(bgra[0], bgra[1], bgra[2], bgra[3]) {} |
| +RgbaColor::RgbaColor(uint32_t bgra) |
| + : RgbaColor(reinterpret_cast<uint8_t*>(&bgra)) {} |
| + |
| bool RgbaColor::operator==(const RgbaColor& right) const { |
| return blue == right.blue && green == right.green && red == right.red && |
| AlphaEquals(alpha, right.alpha); |
| @@ -45,4 +48,8 @@ bool RgbaColor::operator!=(const RgbaColor& right) const { |
| return !(*this == right); |
| } |
| +uint32_t RgbaColor::ToUInt32() const { |
| + 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.
|
| +} |
| + |
| } // namespace webrtc |