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

Unified Diff: webrtc/modules/desktop_capture/color.h

Issue 2268093002: [WebRTC] A real ScreenCapturer test (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
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/BUILD.gn ('k') | webrtc/modules/desktop_capture/color.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/desktop_capture/color.h
diff --git a/webrtc/modules/desktop_capture/color.h b/webrtc/modules/desktop_capture/color.h
new file mode 100644
index 0000000000000000000000000000000000000000..3cd9502966dcbe9e28664592ece465eef9a3afde
--- /dev/null
+++ b/webrtc/modules/desktop_capture/color.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_COLOR_H_
+#define WEBRTC_MODULES_DESKTOP_CAPTURE_COLOR_H_
+
+#include <stdint.h>
+
+#include "webrtc/modules/desktop_capture/desktop_frame.h"
+
+namespace webrtc {
+
+// A four-byte structure to store a color in BGRA format. This structure also
+// provides functions to compare with uint8_t array, say, DesktopFrame::data().
+// It always uses BGRA order for internal storage to match DesktopFrame::data().
+//
+// This struct is for testing purpose only, and should not be used in production
+// logic.
+struct Color final {
Sergey Ulanov 2016/09/02 19:35:00 Maybe call this RgbColor to avoid confusion as Web
Hzj_jie 2016/09/02 21:46:09 RgbaColor may be better.
+ // Creates a color with BGRA channels.
+ Color(uint8_t blue, uint8_t green, uint8_t red, uint8_t alpha);
+
+ // Creates a color with BGR channels, and set alpha channel to 255 (opaque).
+ Color(uint8_t blue, uint8_t green, uint8_t red);
+
+ // Returns true if |bgra| four-byte in BGRA order represents a same color as
+ // |this|.
+ bool operator==(const uint8_t* const bgra) const;
Sergey Ulanov 2016/09/02 19:35:00 Style guide requires overloaded operators behavior
Hzj_jie 2016/09/02 21:46:09 Done.
+
+ // Returns true if |bgra| four-byte in BGRA order represents a different color
+ // as |this|.
+ bool operator!=(const uint8_t* const bgra) const;
Sergey Ulanov 2016/09/02 19:35:00 I don't think you need the second const here. We n
Hzj_jie 2016/09/02 21:46:09 Done.
+
+ // Returns true if |this| and |right| is the same color.
+ bool operator==(const Color& right) const;
+
+ // Returns true if |this| and |right| are different colors.
+ bool operator!=(const Color& right) const;
+
+ uint8_t blue;
+ uint8_t green;
+ uint8_t red;
+ uint8_t alpha;
+};
+static_assert(
+ DesktopFrame::kBytesPerPixel == sizeof(uint32_t),
Sergey Ulanov 2016/09/02 19:35:00 What about sizeof(Color)?
Hzj_jie 2016/09/02 21:46:09 It used to be sizeof(Color), but Jamie has a diffe
+ "A pixel in DesktopFrame should be safe to represent by a uint32_t");
+
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_COLOR_H_
« no previous file with comments | « webrtc/modules/BUILD.gn ('k') | webrtc/modules/desktop_capture/color.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698