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. 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 { | |
|
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.
| |
| 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; | |
|
Sergey Ulanov
2016/09/02 19:35:00
Style guide requires overloaded operators behavior
Hzj_jie
2016/09/02 21:46:09
Done.
| |
| 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; | |
|
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.
| |
| 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; | |
| 48 uint8_t green; | |
| 49 uint8_t red; | |
| 50 uint8_t alpha; | |
| 51 }; | |
| 52 static_assert( | |
| 53 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
| |
| 54 "A pixel in DesktopFrame should be safe to represent by a uint32_t"); | |
| 55 | |
| 56 } // namespace webrtc | |
| 57 | |
| 58 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_COLOR_H_ | |
| OLD | NEW |