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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_COLOR_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_COLOR_H_
13
14 #include <stdint.h>
15
16 #include "webrtc/modules/desktop_capture/desktop_frame.h"
17
18 namespace webrtc {
19
20 // A four bytes strcture to store a color in BGRA format, which can be converted
Jamie 2016/08/26 22:29:09 s/four bytes/four-byte/ s/strcture/structure/
Hzj_jie 2016/08/29 21:57:27 Done.
21 // from and to uint32_t format. This structure also provides functions to
22 // compare with uint8_t array, say, DesktopFrame::data(). When converting from
23 // or to uint32_t format, it's big-ending and little-ending safe, but it always
Jamie 2016/08/26 22:29:09 s/ending/endian/
Hzj_jie 2016/08/29 21:57:27 Done.
24 // uses BGRA order for internal storage to match DesktopFrame::data().
25 //
26 // This struct is for testing purpose only, and should not be used in production
27 // logic.
28 struct Color final {
29 // Creates a color from a BGRA ordered uint.
30 static Color FromBGRA(uint32_t bgra);
31
32 // Creates an opaque color from a BGR ordered uint, only low 24 bits of
33 // |bgr| are used.
34 static Color FromBGR(uint32_t bgr);
35
36 // Creates a color with BGRA channels.
37 static Color FromBGRA(uint8_t blue,
38 uint8_t green,
39 uint8_t red,
40 uint8_t alpha);
Jamie 2016/08/26 22:29:09 I think it would be better to include only this ct
Hzj_jie 2016/08/29 21:57:27 Done.
41
42 // Creates a color with BGR channels, and set alpha channel to 255 (opaque).
43 static Color FromBGR(uint8_t blue, uint8_t green, uint8_t red);
44
45 // Returns true if |bgra| four bytes in BGRA order represents a same color
46 // as |this|.
47 bool operator==(const uint8_t* const bgra) const;
48
49 // Returns true if |bgra| four bytes in BGRA order represents a different
50 // color as |this|.
51 bool operator!=(const uint8_t* const bgra) const;
52
53 // Returns true if |this| and |right| is the same color.
54 bool operator==(const Color& right) const;
55
56 // Returns true if |this| and |right| are different colors.
57 bool operator!=(const Color& right) const;
58
59 // Converts current Color into its uint format in BGRA order for a quick
60 // assignment or compare.
61 uint32_t ToUInt32() const;
62
63 uint8_t blue() const;
64
65 uint8_t green() const;
66
67 uint8_t red() const;
68
69 uint8_t alpha() const;
70
71 uint8_t bgra[DesktopFrame::kBytesPerPixel];
72 };
73 static_assert(
74 DesktopFrame::kBytesPerPixel == sizeof(uint32_t),
75 "A pixel in DesktopFrame should be safe to represent by a uint32_t");
76
77 } // namespace webrtc
78
79 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_COLOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698