OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 struct RgbaColor final { | 27 struct RgbaColor final { |
28 // Creates a color with BGRA channels. | 28 // Creates a color with BGRA channels. |
29 RgbaColor(uint8_t blue, uint8_t green, uint8_t red, uint8_t alpha); | 29 RgbaColor(uint8_t blue, uint8_t green, uint8_t red, uint8_t alpha); |
30 | 30 |
31 // Creates a color with BGR channels, and set alpha channel to 255 (opaque). | 31 // Creates a color with BGR channels, and set alpha channel to 255 (opaque). |
32 RgbaColor(uint8_t blue, uint8_t green, uint8_t red); | 32 RgbaColor(uint8_t blue, uint8_t green, uint8_t red); |
33 | 33 |
34 // Creates a color from four-byte in BGRA order, i.e. DesktopFrame::data(). | 34 // Creates a color from four-byte in BGRA order, i.e. DesktopFrame::data(). |
35 explicit RgbaColor(const uint8_t* bgra); | 35 explicit RgbaColor(const uint8_t* bgra); |
36 | 36 |
| 37 // Creates a color from BGRA channels in a uint format. This function creates |
| 38 // an equivalence RgbaColor instance from the ToUInt32() result of another |
| 39 // RgbaColor instance. |
| 40 explicit RgbaColor(uint32_t bgra); |
| 41 |
37 // Returns true if |this| and |right| is the same color. | 42 // Returns true if |this| and |right| is the same color. |
38 bool operator==(const RgbaColor& right) const; | 43 bool operator==(const RgbaColor& right) const; |
39 | 44 |
40 // Returns true if |this| and |right| are different colors. | 45 // Returns true if |this| and |right| are different colors. |
41 bool operator!=(const RgbaColor& right) const; | 46 bool operator!=(const RgbaColor& right) const; |
42 | 47 |
| 48 uint32_t ToUInt32() const; |
| 49 |
43 uint8_t blue; | 50 uint8_t blue; |
44 uint8_t green; | 51 uint8_t green; |
45 uint8_t red; | 52 uint8_t red; |
46 uint8_t alpha; | 53 uint8_t alpha; |
47 }; | 54 }; |
48 static_assert( | 55 static_assert( |
49 DesktopFrame::kBytesPerPixel == sizeof(RgbaColor), | 56 DesktopFrame::kBytesPerPixel == sizeof(RgbaColor), |
50 "A pixel in DesktopFrame should be safe to be represented by a RgbaColor"); | 57 "A pixel in DesktopFrame should be safe to be represented by a RgbaColor"); |
51 | 58 |
52 } // namespace webrtc | 59 } // namespace webrtc |
53 | 60 |
54 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_RGBA_COLOR_H_ | 61 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_RGBA_COLOR_H_ |
OLD | NEW |