Chromium Code Reviews| 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, which can be converted | |
| 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-endian and little-endian safe, but it always | |
| 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 with BGRA channels. | |
| 30 Color(uint8_t blue, uint8_t green, uint8_t red, uint8_t alpha); | |
| 31 | |
| 32 // Creates a color with BGR channels, and set alpha channel to 255 (opaque). | |
| 33 Color(uint8_t blue, uint8_t green, uint8_t red); | |
| 34 | |
| 35 // Returns true if |bgra| four-byte in BGRA order represents a same color as | |
| 36 // |this|. | |
| 37 bool operator==(const uint8_t* const bgra) const; | |
| 38 | |
| 39 // Returns true if |bgra| four-byte in BGRA order represents a different color | |
| 40 // as |this|. | |
| 41 bool operator!=(const uint8_t* const bgra) const; | |
| 42 | |
| 43 // Returns true if |this| and |right| is the same color. | |
| 44 bool operator==(const Color& right) const; | |
| 45 | |
| 46 // Returns true if |this| and |right| are different colors. | |
| 47 bool operator!=(const Color& right) const; | |
| 48 | |
| 49 // Converts current Color into its uint format in BGRA order (little-endian) | |
| 50 // or ARGB order (big-endian) for a quick assignment or compare with | |
| 51 // DesktopFrame::data(). | |
| 52 uint32_t ToUInt32() const; | |
|
Jamie
2016/08/31 17:39:39
I don't think you're using this method. Please rem
Hzj_jie
2016/08/31 21:22:39
This will be used in change 2202443002. I can sure
| |
| 53 | |
| 54 uint8_t blue() const; | |
| 55 | |
| 56 uint8_t green() const; | |
| 57 | |
| 58 uint8_t red() const; | |
| 59 | |
| 60 uint8_t alpha() const; | |
| 61 | |
| 62 uint8_t bgra[DesktopFrame::kBytesPerPixel]; | |
| 63 }; | |
| 64 static_assert( | |
| 65 DesktopFrame::kBytesPerPixel == sizeof(uint32_t), | |
| 66 "A pixel in DesktopFrame should be safe to represent by a uint32_t"); | |
| 67 | |
| 68 } // namespace webrtc | |
| 69 | |
| 70 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_COLOR_H_ | |
| OLD | NEW |