diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /third_party/libwebrtc/modules/desktop_capture/rgba_color.h | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/modules/desktop_capture/rgba_color.h')
-rw-r--r-- | third_party/libwebrtc/modules/desktop_capture/rgba_color.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/third_party/libwebrtc/modules/desktop_capture/rgba_color.h b/third_party/libwebrtc/modules/desktop_capture/rgba_color.h new file mode 100644 index 0000000000..2b13430a45 --- /dev/null +++ b/third_party/libwebrtc/modules/desktop_capture/rgba_color.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef MODULES_DESKTOP_CAPTURE_RGBA_COLOR_H_ +#define MODULES_DESKTOP_CAPTURE_RGBA_COLOR_H_ + +#include <stdint.h> + +#include "modules/desktop_capture/desktop_frame.h" + +namespace webrtc { + +// A four-byte structure to store a color in BGRA format. This structure also +// provides functions to be created from uint8_t array, say, +// DesktopFrame::data(). It always uses BGRA order for internal storage to match +// DesktopFrame::data(). +struct RgbaColor final { + // Creates a color with BGRA channels. + RgbaColor(uint8_t blue, uint8_t green, uint8_t red, uint8_t alpha); + + // Creates a color with BGR channels, and set alpha channel to 255 (opaque). + RgbaColor(uint8_t blue, uint8_t green, uint8_t red); + + // Creates a color from four-byte in BGRA order, i.e. DesktopFrame::data(). + explicit RgbaColor(const uint8_t* bgra); + + // Creates a color from BGRA channels in a uint format. Consumers should make + // sure the memory order of the uint32_t is always BGRA from left to right, no + // matter the system endian. This function creates an equivalent RgbaColor + // instance from the ToUInt32() result of another RgbaColor instance. + explicit RgbaColor(uint32_t bgra); + + // Returns true if `this` and `right` is the same color. + bool operator==(const RgbaColor& right) const; + + // Returns true if `this` and `right` are different colors. + bool operator!=(const RgbaColor& right) const; + + uint32_t ToUInt32() const; + + uint8_t blue; + uint8_t green; + uint8_t red; + uint8_t alpha; +}; +static_assert( + DesktopFrame::kBytesPerPixel == sizeof(RgbaColor), + "A pixel in DesktopFrame should be safe to be represented by a RgbaColor"); + +} // namespace webrtc + +#endif // MODULES_DESKTOP_CAPTURE_RGBA_COLOR_H_ |