OLD | NEW |
---|---|
(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-byte structure to store a color in BGRA format. This structure also | |
21 // provides functions to compare with uint8_t array, say, DesktopFrame::data(). | |
22 // It always uses BGRA order for internal storage to match DesktopFrame::data(). | |
23 // | |
24 // This struct is for testing purpose only, and should not be used in production | |
25 // logic. | |
26 struct Color final { | |
27 // Creates a color with BGRA channels. | |
28 Color(uint8_t blue, uint8_t green, uint8_t red, uint8_t alpha); | |
29 | |
30 // Creates a color with BGR channels, and set alpha channel to 255 (opaque). | |
31 Color(uint8_t blue, uint8_t green, uint8_t red); | |
32 | |
33 // Returns true if |bgra| four-byte in BGRA order represents a same color as | |
34 // |this|. | |
35 bool operator==(const uint8_t* const bgra) const; | |
36 | |
37 // Returns true if |bgra| four-byte in BGRA order represents a different color | |
38 // as |this|. | |
39 bool operator!=(const uint8_t* const bgra) const; | |
40 | |
41 // Returns true if |this| and |right| is the same color. | |
42 bool operator==(const Color& right) const; | |
43 | |
44 // Returns true if |this| and |right| are different colors. | |
45 bool operator!=(const Color& right) const; | |
46 | |
47 uint8_t blue() const; | |
Sergey Ulanov
2016/09/01 19:26:38
since these are lower-case accessors they can be i
Hzj_jie
2016/09/01 23:25:09
Done.
| |
48 | |
49 uint8_t green() const; | |
50 | |
51 uint8_t red() const; | |
52 | |
53 uint8_t alpha() const; | |
54 | |
55 uint8_t bgra[DesktopFrame::kBytesPerPixel]; | |
Sergey Ulanov
2016/09/01 19:26:38
do you really need this as an array? why not just
Hzj_jie
2016/09/01 23:25:09
Done.
| |
56 }; | |
57 static_assert( | |
58 DesktopFrame::kBytesPerPixel == sizeof(uint32_t), | |
59 "A pixel in DesktopFrame should be safe to represent by a uint32_t"); | |
60 | |
61 } // namespace webrtc | |
62 | |
63 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_COLOR_H_ | |
OLD | NEW |