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..a5acba9c55af7abf4690a015117ea47e33adc604 100644 |
| --- a/webrtc/modules/desktop_capture/rgba_color.cc |
| +++ b/webrtc/modules/desktop_capture/rgba_color.cc |
| @@ -10,6 +10,8 @@ |
| #include "webrtc/modules/desktop_capture/rgba_color.h" |
| +#include "webrtc/typedefs.h" |
| + |
| namespace webrtc { |
| namespace { |
| @@ -36,6 +38,15 @@ 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]) {} |
| +// Converting from or to uint32 in big-endian system has not been supported. |
| +#if defined(WEBRTC_ARCH_LITTLE_ENDIAN) |
| +RgbaColor::RgbaColor(uint32_t bgra) |
| + : RgbaColor((bgra & 0xff000000) >> 24, |
|
Sergey Ulanov
2016/09/20 21:06:41
nit: the old version of this constructor with rein
Hzj_jie
2016/09/20 23:50:12
Then I think we do not need to add big-endian or l
|
| + (bgra & 0x00ff0000) >> 16, |
| + (bgra & 0x0000ff00) >> 8, |
| + (bgra & 0x000000ff)) {} |
| +#endif |
| + |
| bool RgbaColor::operator==(const RgbaColor& right) const { |
| return blue == right.blue && green == right.green && red == right.red && |
| AlphaEquals(alpha, right.alpha); |
| @@ -45,4 +56,11 @@ bool RgbaColor::operator!=(const RgbaColor& right) const { |
| return !(*this == right); |
| } |
| +// Converting from or to uint32 in big-endian system has not been supported. |
| +#if defined(WEBRTC_ARCH_LITTLE_ENDIAN) |
|
Sergey Ulanov
2016/09/20 21:06:41
It's better to put this inside the body of this fu
Hzj_jie
2016/09/20 23:50:12
Since supporting big-endian is pretty simple, inst
|
| +uint32_t RgbaColor::ToUInt32() const { |
| + return (blue << 24) | (green << 16) | (red << 8) | alpha; |
| +} |
| +#endif |
| + |
| } // namespace webrtc |