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

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

Issue 2334853002: Use RgbaColor in DesktopFrameGenerator and add RgbaColorTest (Closed)
Patch Set: Resolve review comments 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
« no previous file with comments | « webrtc/modules/desktop_capture/rgba_color.h ('k') | webrtc/modules/desktop_capture/rgba_color_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6d91de4275cd6b00c8c1c6e2c23dca55e7ef1397 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,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 +50,12 @@ bool RgbaColor::operator!=(const RgbaColor& right) const {
return !(*this == right);
}
+uint32_t RgbaColor::ToUInt32() const {
+#if defined(WEBRTC_ARCH_LITTLE_ENDIAN)
+ return blue | (green << 8) | (red << 16) | (alpha << 24);
+#else
+ return (blue << 24) | (green << 16) | (red << 8) | alpha;
+#endif
+}
+
} // namespace webrtc
« no previous file with comments | « webrtc/modules/desktop_capture/rgba_color.h ('k') | webrtc/modules/desktop_capture/rgba_color_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698