Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Unified Diff: webrtc/modules/desktop_capture/rgba_color.cc

Issue 2334853002: Use RgbaColor in DesktopFrameGenerator and add RgbaColorTest (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698