tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 182eac43c2c4609eeab8842cc12f3e7f72c69feb
parent e80418de9b3e06015752b2773bf6252a9d50781e
Author: Dan Baker <dbaker@mozilla.com>
Date:   Thu, 23 Oct 2025 15:43:22 -0600

Bug 1995393 - Vendor libwebrtc from 2cf793d20c

Upstream commit: https://webrtc.googlesource.com/src/+/2cf793d20c46e45b5ca3124e0c8dc3eab00be835
    Add FourCC pixel format to DesktopFrame

    Android returns buffers in various pixel formats. Currently,
    DesktopFrame is assumed to be ARGB. This CL adds a specific annotation
    with the pixel format.

    Bug: webrtc:436974448
    Test: CQ
    Change-Id: I72a31215c66aa953753d8ec97cea597a01cb6561
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/403520
    Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
    Reviewed-by: Alexander Cooper <alcooper@chromium.org>
    Commit-Queue: Eliot Courtney <edcourtney@google.com>
    Cr-Commit-Position: refs/heads/main@{#45349}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/modules/desktop_capture/BUILD.gn | 1+
Mthird_party/libwebrtc/modules/desktop_capture/DEPS | 1+
Mthird_party/libwebrtc/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc | 3+++
Mthird_party/libwebrtc/modules/desktop_capture/cropped_desktop_frame.cc | 1+
Mthird_party/libwebrtc/modules/desktop_capture/desktop_and_cursor_composer.cc | 3++-
Mthird_party/libwebrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.cc | 1+
Mthird_party/libwebrtc/modules/desktop_capture/desktop_frame.cc | 39++++++++++++++++++++++++++++++++++++---
Mthird_party/libwebrtc/modules/desktop_capture/desktop_frame.h | 34++++++++++++++++++++++++++++++++--
Mthird_party/libwebrtc/modules/desktop_capture/desktop_frame_generator.cc | 7+++++--
Mthird_party/libwebrtc/modules/desktop_capture/desktop_frame_rotation.cc | 2++
Mthird_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc | 9+++++++--
Mthird_party/libwebrtc/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc | 4++--
Mthird_party/libwebrtc/modules/desktop_capture/linux/x11/screen_capturer_x11.cc | 2+-
Mthird_party/libwebrtc/modules/desktop_capture/linux/x11/window_capturer_x11.cc | 4++--
Mthird_party/libwebrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc | 1+
Mthird_party/libwebrtc/modules/desktop_capture/mac/screen_capturer_mac.mm | 1+
Mthird_party/libwebrtc/modules/desktop_capture/rgba_color.h | 3+--
Mthird_party/libwebrtc/modules/desktop_capture/shared_desktop_frame.cc | 1+
Mthird_party/libwebrtc/modules/desktop_capture/win/cursor.cc | 2+-
Mthird_party/libwebrtc/modules/desktop_capture/win/dxgi_frame.cc | 4++--
Mthird_party/libwebrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.cc | 8+++++---
Mthird_party/libwebrtc/moz-patch-stack/s0001.patch | 6+++---
Mthird_party/libwebrtc/moz-patch-stack/s0005.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0006.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0027.patch | 6+++---
Mthird_party/libwebrtc/moz-patch-stack/s0034.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0074.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0075.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0076.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0102.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0114.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0119.patch | 4++--
33 files changed, 129 insertions(+), 44 deletions(-)

diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-23T21:40:28.858947+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-23T21:43:10.801657+00:00. # base of lastest vendoring -7d159d47a1 +2cf793d20c diff --git a/third_party/libwebrtc/modules/desktop_capture/BUILD.gn b/third_party/libwebrtc/modules/desktop_capture/BUILD.gn @@ -36,6 +36,7 @@ rtc_library("primitives") { deps = [ "../../api:scoped_refptr", + "../../media:video_common", "../../rtc_base:checks", "../../rtc_base:refcount", "../../rtc_base:stringutils", diff --git a/third_party/libwebrtc/modules/desktop_capture/DEPS b/third_party/libwebrtc/modules/desktop_capture/DEPS @@ -1,4 +1,5 @@ include_rules = [ + "+media/base", "+system_wrappers", "+third_party/libyuv", ] diff --git a/third_party/libwebrtc/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc b/third_party/libwebrtc/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc @@ -119,6 +119,9 @@ void BlankDetectorDesktopCapturerWrapper::OnCaptureResult( bool BlankDetectorDesktopCapturerWrapper::IsBlankFrame( const DesktopFrame& frame) const { + // TODO(bugs.webrtc.org/436974448): Support other pixel formats. + RTC_CHECK_EQ(FOURCC_ARGB, frame.pixel_format()); + // We will check 7489 pixels for a frame with 1024 x 768 resolution. for (int i = 0; i < frame.size().width() * frame.size().height(); i += 105) { const int x = i % frame.size().width(); diff --git a/third_party/libwebrtc/modules/desktop_capture/cropped_desktop_frame.cc b/third_party/libwebrtc/modules/desktop_capture/cropped_desktop_frame.cc @@ -56,6 +56,7 @@ CroppedDesktopFrame::CroppedDesktopFrame(std::unique_ptr<DesktopFrame> frame, const DesktopRect& rect) : DesktopFrame(rect.size(), frame->stride(), + frame->pixel_format(), frame->GetFrameDataAtPos(rect.top_left()), frame->shared_memory()), frame_(std::move(frame)) { diff --git a/third_party/libwebrtc/modules/desktop_capture/desktop_and_cursor_composer.cc b/third_party/libwebrtc/modules/desktop_capture/desktop_and_cursor_composer.cc @@ -107,6 +107,7 @@ DesktopFrameWithCursor::DesktopFrameWithCursor( bool cursor_changed) : DesktopFrame(frame->size(), frame->stride(), + frame->pixel_format(), frame->data(), frame->shared_memory()), original_frame_(std::move(frame)) { @@ -136,7 +137,7 @@ DesktopFrameWithCursor::DesktopFrameWithCursor( // Copy original screen content under cursor to `restore_frame_`. restore_position_ = cursor_rect_.top_left(); - restore_frame_.reset(new BasicDesktopFrame(cursor_rect_.size())); + restore_frame_.reset(new BasicDesktopFrame(cursor_rect_.size(), FOURCC_ARGB)); restore_frame_->CopyPixelsFrom(*this, cursor_rect_.top_left(), DesktopRect::MakeSize(restore_frame_->size())); diff --git a/third_party/libwebrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.cc b/third_party/libwebrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.cc @@ -123,6 +123,7 @@ void CompareFrames(const DesktopFrame& old_frame, DesktopRegion* const output) { RTC_DCHECK(old_frame.size().equals(new_frame.size())); RTC_DCHECK_EQ(old_frame.stride(), new_frame.stride()); + RTC_CHECK_EQ(old_frame.pixel_format(), new_frame.pixel_format()); rect.IntersectWith(DesktopRect::MakeSize(old_frame.size())); const int y_block_count = (rect.height() - 1) / kBlockSize; diff --git a/third_party/libwebrtc/modules/desktop_capture/desktop_frame.cc b/third_party/libwebrtc/modules/desktop_capture/desktop_frame.cc @@ -27,18 +27,28 @@ namespace webrtc { DesktopFrame::DesktopFrame(DesktopSize size, int stride, + FourCC pixel_format, uint8_t* data, SharedMemory* shared_memory) : data_(data), shared_memory_(shared_memory), size_(size), stride_(stride), + pixel_format_(pixel_format), capture_time_ms_(0), capturer_id_(DesktopCapturerId::kUnknown) { RTC_DCHECK(size_.width() >= 0); RTC_DCHECK(size_.height() >= 0); + // TODO(bugs.webrtc.org/436974448): Support other pixel formats. + RTC_CHECK_EQ(FOURCC_ARGB, pixel_format_); } +DesktopFrame::DesktopFrame(DesktopSize size, + int stride, + uint8_t* data, + SharedMemory* shared_memory) + : DesktopFrame(size, stride, FOURCC_ARGB, data, shared_memory) {} + DesktopFrame::~DesktopFrame() = default; void DesktopFrame::CopyPixelsFrom(const uint8_t* src_buffer, @@ -58,6 +68,7 @@ void DesktopFrame::CopyPixelsFrom(const DesktopFrame& src_frame, RTC_CHECK(DesktopRect::MakeSize(src_frame.size()) .ContainsRect( DesktopRect::MakeOriginSize(src_pos, dest_rect.size()))); + RTC_CHECK_EQ(pixel_format(), src_frame.pixel_format()); CopyPixelsFrom(src_frame.GetFrameDataAtPos(src_pos), src_frame.stride(), dest_rect); @@ -168,8 +179,12 @@ void DesktopFrame::SetFrameDataToBlack() { } BasicDesktopFrame::BasicDesktopFrame(DesktopSize size) + : BasicDesktopFrame(size, FOURCC_ARGB) {} + +BasicDesktopFrame::BasicDesktopFrame(DesktopSize size, FourCC pixel_format) : DesktopFrame(size, kBytesPerPixel * size.width(), + pixel_format, new uint8_t[kBytesPerPixel * size.width() * size.height()](), nullptr) {} @@ -179,7 +194,8 @@ BasicDesktopFrame::~BasicDesktopFrame() { // static DesktopFrame* BasicDesktopFrame::CopyOf(const DesktopFrame& frame) { - DesktopFrame* result = new BasicDesktopFrame(frame.size()); + DesktopFrame* result = + new BasicDesktopFrame(frame.size(), frame.pixel_format()); // TODO(crbug.com/1330019): Temporary workaround for a known libyuv crash when // the height or width is 0. Remove this once this change has been merged. if (frame.size().width() && frame.size().height()) { @@ -194,6 +210,7 @@ DesktopFrame* BasicDesktopFrame::CopyOf(const DesktopFrame& frame) { // static std::unique_ptr<DesktopFrame> SharedMemoryDesktopFrame::Create( DesktopSize size, + FourCC pixel_format, SharedMemoryFactory* shared_memory_factory) { RTC_DCHECK(shared_memory_factory); @@ -204,22 +221,38 @@ std::unique_ptr<DesktopFrame> SharedMemoryDesktopFrame::Create( return nullptr; return std::make_unique<SharedMemoryDesktopFrame>( - size, size.width() * kBytesPerPixel, std::move(shared_memory)); + size, size.width() * kBytesPerPixel, pixel_format, + std::move(shared_memory)); } +SharedMemoryDesktopFrame::SharedMemoryDesktopFrame( + DesktopSize size, + int stride, + std::unique_ptr<SharedMemory> shared_memory) + : SharedMemoryDesktopFrame(size, + stride, + FOURCC_ARGB, + std::move(shared_memory)) {} + SharedMemoryDesktopFrame::SharedMemoryDesktopFrame(DesktopSize size, int stride, + FourCC pixel_format, SharedMemory* shared_memory) : DesktopFrame(size, stride, + pixel_format, reinterpret_cast<uint8_t*>(shared_memory->data()), shared_memory) {} SharedMemoryDesktopFrame::SharedMemoryDesktopFrame( DesktopSize size, int stride, + FourCC pixel_format, std::unique_ptr<SharedMemory> shared_memory) - : SharedMemoryDesktopFrame(size, stride, shared_memory.release()) {} + : SharedMemoryDesktopFrame(size, + stride, + pixel_format, + shared_memory.release()) {} SharedMemoryDesktopFrame::~SharedMemoryDesktopFrame() { delete shared_memory_; diff --git a/third_party/libwebrtc/modules/desktop_capture/desktop_frame.h b/third_party/libwebrtc/modules/desktop_capture/desktop_frame.h @@ -17,6 +17,7 @@ #include <optional> #include <vector> +#include "media/base/video_common.h" #include "modules/desktop_capture/desktop_geometry.h" #include "modules/desktop_capture/desktop_region.h" #include "modules/desktop_capture/shared_memory.h" @@ -58,6 +59,9 @@ class RTC_EXPORT DesktopFrame { // Distance in the buffer between two neighboring rows in bytes. int stride() const { return stride_; } + // The pixel format the `DesktopFrame` is stored in. + FourCC pixel_format() const { return pixel_format_; } + // Data buffer used for the frame. uint8_t* data() const { return data_; } @@ -157,8 +161,16 @@ class RTC_EXPORT DesktopFrame { bool FrameDataIsBlack() const; protected: + // TODO(bugs.webrtc.org/436974448): Remove. + // Deprecated, use the next constructor. + DesktopFrame(DesktopSize size, + int stride, + uint8_t* data, + SharedMemory* shared_memory); + DesktopFrame(DesktopSize size, int stride, + FourCC pixel_format, uint8_t* data, SharedMemory* shared_memory); @@ -172,6 +184,10 @@ class RTC_EXPORT DesktopFrame { const DesktopSize size_; const int stride_; + // The pixel format for the data stored. Currently, only 4 byte per pixel + // formats are supported. + const FourCC pixel_format_; + DesktopRegion updated_region_; DesktopVector top_left_; DesktopVector dpi_; @@ -188,9 +204,13 @@ class RTC_EXPORT DesktopFrame { // A DesktopFrame that stores data in the heap. class RTC_EXPORT BasicDesktopFrame : public DesktopFrame { public: - // The entire data buffer used for the frame is initialized with zeros. + // TODO(bugs.webrtc.org/436974448): Remove. + // Deprecated, use the last constructor. explicit BasicDesktopFrame(DesktopSize size); + // The entire data buffer used for the frame is initialized with zeros. + BasicDesktopFrame(DesktopSize size, FourCC pixel_format); + ~BasicDesktopFrame() override; BasicDesktopFrame(const BasicDesktopFrame&) = delete; @@ -209,17 +229,26 @@ class RTC_EXPORT SharedMemoryDesktopFrame : public DesktopFrame { // `shared_memory_factory` should not be nullptr. static std::unique_ptr<DesktopFrame> Create( DesktopSize size, + FourCC pixel_format, SharedMemoryFactory* shared_memory_factory); + // TODO(bugs.webrtc.org/436974448): Remove. + // Deprecated, use the last constructor. + SharedMemoryDesktopFrame(DesktopSize size, + int stride, + std::unique_ptr<SharedMemory> shared_memory); + // Takes ownership of `shared_memory`. - // Deprecated, use the next constructor. + // Deprecated, use the last constructor. SharedMemoryDesktopFrame(DesktopSize size, int stride, + FourCC pixel_format, SharedMemory* shared_memory); // Preferred. SharedMemoryDesktopFrame(DesktopSize size, int stride, + FourCC pixel_format, std::unique_ptr<SharedMemory> shared_memory); ~SharedMemoryDesktopFrame() override; @@ -237,6 +266,7 @@ class RTC_EXPORT SharedMemoryDesktopFrame : public DesktopFrame { // constructor, std::unique_ptr<T>::operator->() won't be involved anymore. SharedMemoryDesktopFrame(DesktopRect rect, int stride, + FourCC pixel_format, SharedMemory* shared_memory); }; diff --git a/third_party/libwebrtc/modules/desktop_capture/desktop_frame_generator.cc b/third_party/libwebrtc/modules/desktop_capture/desktop_frame_generator.cc @@ -70,6 +70,8 @@ void PaintRect(DesktopFrame* frame, DesktopRect rect, RgbaColor rgba_color) { "kBytesPerPixel should be 4."); RTC_DCHECK_GE(frame->size().width(), rect.right()); RTC_DCHECK_GE(frame->size().height(), rect.bottom()); + // TODO(bugs.webrtc.org/436974448): Support other pixel formats. + RTC_CHECK_EQ(FOURCC_ARGB, frame->pixel_format()); uint32_t color = rgba_color.ToUInt32(); uint8_t* row = frame->GetFrameDataAtPos(rect.top_left()); for (int i = 0; i < rect.height(); i++) { @@ -116,8 +118,9 @@ std::unique_ptr<DesktopFrame> PainterDesktopFrameGenerator::GetNextFrame( } std::unique_ptr<DesktopFrame> frame = std::unique_ptr<DesktopFrame>( - factory ? SharedMemoryDesktopFrame::Create(size_, factory).release() - : new BasicDesktopFrame(size_)); + factory ? SharedMemoryDesktopFrame::Create(size_, FOURCC_ARGB, factory) + .release() + : new BasicDesktopFrame(size_, FOURCC_ARGB)); if (painter_) { DesktopRegion updated_region; if (!painter_->Paint(frame.get(), &updated_region)) { diff --git a/third_party/libwebrtc/modules/desktop_capture/desktop_frame_rotation.cc b/third_party/libwebrtc/modules/desktop_capture/desktop_frame_rotation.cc @@ -100,6 +100,8 @@ void RotateDesktopFrame(const DesktopFrame& source, DesktopFrame* target) { RTC_DCHECK(target); RTC_DCHECK(DesktopRect::MakeSize(source.size()).ContainsRect(source_rect)); + // TODO(bugs.webrtc.org/436974448): Support other pixel formats. + RTC_CHECK_EQ(FOURCC_ARGB, source.pixel_format()); // The rectangle in `target`. const DesktopRect target_rect = RotateAndOffsetRect(source_rect, source.size(), rotation, target_offset); diff --git a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc @@ -735,8 +735,11 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) { if (bitmap && bitmap->size.width > 0 && bitmap->size.height > 0) { const uint8_t* bitmap_data = SPA_MEMBER(bitmap, bitmap->offset, uint8_t); + // TODO(bugs.webrtc.org/436974448): Convert `spa_video_format` to + // `FourCC`. BasicDesktopFrame* mouse_frame = new BasicDesktopFrame( - DesktopSize(bitmap->size.width, bitmap->size.height)); + DesktopSize(bitmap->size.width, bitmap->size.height), + FOURCC_ARGB); mouse_frame->CopyPixelsFrom( bitmap_data, bitmap->stride, DesktopRect::MakeWH(bitmap->size.width, bitmap->size.height)); @@ -863,7 +866,7 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) { if (!queue_.current_frame() || !queue_.current_frame()->size().equals(frame_size_)) { std::unique_ptr<DesktopFrame> frame(new BasicDesktopFrame( - DesktopSize(frame_size_.width(), frame_size_.height()))); + DesktopSize(frame_size_.width(), frame_size_.height()), FOURCC_ARGB)); queue_.ReplaceCurrentFrame(SharedDesktopFrame::Wrap(std::move(frame))); } @@ -884,6 +887,8 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) { return; } + // TODO(bugs.webrtc.org/436974448): Remove this conversion when arbitrary + // pixel formats are supported. if (spa_video_format_.format == SPA_VIDEO_FORMAT_RGBx || spa_video_format_.format == SPA_VIDEO_FORMAT_RGBA) { uint8_t* tmp_src = queue_.current_frame()->data(); diff --git a/third_party/libwebrtc/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc b/third_party/libwebrtc/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc @@ -80,7 +80,7 @@ MouseCursorMonitorX11::MouseCursorMonitorX11( // Set a default initial cursor shape in case XFixes is not present. const int kSize = 5; std::unique_ptr<DesktopFrame> default_cursor( - new BasicDesktopFrame(DesktopSize(kSize, kSize))); + new BasicDesktopFrame(DesktopSize(kSize, kSize), FOURCC_ARGB)); const uint8_t pixels[kSize * kSize] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, @@ -211,7 +211,7 @@ void MouseCursorMonitorX11::CaptureCursor() { } std::unique_ptr<DesktopFrame> image( - new BasicDesktopFrame(DesktopSize(img->width, img->height))); + new BasicDesktopFrame(DesktopSize(img->width, img->height), FOURCC_ARGB)); // Xlib stores 32-bit data in longs, even if longs are 64-bits long. unsigned long* src = img->pixels; // NOLINT(runtime/int) diff --git a/third_party/libwebrtc/modules/desktop_capture/linux/x11/screen_capturer_x11.cc b/third_party/libwebrtc/modules/desktop_capture/linux/x11/screen_capturer_x11.cc @@ -269,7 +269,7 @@ void ScreenCapturerX11::CaptureFrame() { // may still be reading from them. if (!queue_.current_frame()) { std::unique_ptr<DesktopFrame> frame( - new BasicDesktopFrame(selected_monitor_rect_.size())); + new BasicDesktopFrame(selected_monitor_rect_.size(), FOURCC_ARGB)); // We set the top-left of the frame so the mouse cursor will be composited // properly, and our frame buffer will not be overrun while blitting. diff --git a/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_capturer_x11.cc b/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_capturer_x11.cc @@ -167,13 +167,13 @@ void WindowCapturerX11::CaptureFrame() { if (GetWindowState(&atom_cache_, selected_window_) == IconicState) { // Window is in minimized. Return a 1x1 frame as same as OSX/Win does. std::unique_ptr<DesktopFrame> frame( - new BasicDesktopFrame(DesktopSize(1, 1))); + new BasicDesktopFrame(DesktopSize(1, 1), FOURCC_ARGB)); callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); return; } std::unique_ptr<DesktopFrame> frame( - new BasicDesktopFrame(x_server_pixel_buffer_.window_size())); + new BasicDesktopFrame(x_server_pixel_buffer_.window_size(), FOURCC_ARGB)); x_server_pixel_buffer_.Synchronize(); if (!x_server_pixel_buffer_.CaptureRect(DesktopRect::MakeSize(frame->size()), diff --git a/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc b/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc @@ -334,6 +334,7 @@ bool XServerPixelBuffer::CaptureRect(const DesktopRect& rect, DesktopFrame* frame) { RTC_DCHECK_LE(rect.right(), window_rect_.width()); RTC_DCHECK_LE(rect.bottom(), window_rect_.height()); + RTC_CHECK_EQ(FOURCC_ARGB, frame->pixel_format()); XImage* image; uint8_t* data; diff --git a/third_party/libwebrtc/modules/desktop_capture/mac/screen_capturer_mac.mm b/third_party/libwebrtc/modules/desktop_capture/mac/screen_capturer_mac.mm @@ -386,6 +386,7 @@ bool ScreenCapturerMac::CgBlit(const DesktopFrame& frame, if (!frame_source) { continue; } + RTC_CHECK_EQ(frame_source->pixel_format(), frame.pixel_format()); const uint8_t* display_base_address = frame_source->data(); int src_bytes_per_row = frame_source->stride(); diff --git a/third_party/libwebrtc/modules/desktop_capture/rgba_color.h b/third_party/libwebrtc/modules/desktop_capture/rgba_color.h @@ -19,8 +19,7 @@ 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(). +// DesktopFrame::data(). It always uses BGRA order for internal storage. struct RgbaColor final { // Creates a color with BGRA channels. RgbaColor(uint8_t blue, uint8_t green, uint8_t red, uint8_t alpha); diff --git a/third_party/libwebrtc/modules/desktop_capture/shared_desktop_frame.cc b/third_party/libwebrtc/modules/desktop_capture/shared_desktop_frame.cc @@ -52,6 +52,7 @@ bool SharedDesktopFrame::IsShared() { SharedDesktopFrame::SharedDesktopFrame(scoped_refptr<Core> core) : DesktopFrame((*core)->size(), (*core)->stride(), + (*core)->pixel_format(), (*core)->data(), (*core)->shared_memory()), core_(core) { diff --git a/third_party/libwebrtc/modules/desktop_capture/win/cursor.cc b/third_party/libwebrtc/modules/desktop_capture/win/cursor.cc @@ -156,7 +156,7 @@ MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor) { uint32_t* mask_plane = mask_data.get(); std::unique_ptr<DesktopFrame> image( - new BasicDesktopFrame(DesktopSize(width, height))); + new BasicDesktopFrame(DesktopSize(width, height), FOURCC_ARGB)); bool has_alpha = false; if (is_color) { diff --git a/third_party/libwebrtc/modules/desktop_capture/win/dxgi_frame.cc b/third_party/libwebrtc/modules/desktop_capture/win/dxgi_frame.cc @@ -43,7 +43,7 @@ bool DxgiFrame::Prepare(DesktopSize size, DesktopCapturer::SourceId source_id) { if (!frame_) { std::unique_ptr<DesktopFrame> frame; if (factory_) { - frame = SharedMemoryDesktopFrame::Create(size, factory_); + frame = SharedMemoryDesktopFrame::Create(size, FOURCC_ARGB, factory_); if (!frame) { RTC_LOG(LS_WARNING) << "DxgiFrame cannot create a new DesktopFrame."; @@ -58,7 +58,7 @@ bool DxgiFrame::Prepare(DesktopSize size, DesktopCapturer::SourceId source_id) { frame->size().width() * DesktopFrame::kBytesPerPixel); memset(frame->data(), 0, frame->stride() * frame->size().height()); } else { - frame.reset(new BasicDesktopFrame(size)); + frame.reset(new BasicDesktopFrame(size, FOURCC_ARGB)); } frame_ = SharedDesktopFrame::Wrap(std::move(frame)); } diff --git a/third_party/libwebrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.cc b/third_party/libwebrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.cc @@ -346,7 +346,8 @@ void ScreenCapturerWinMagnifier::OnCaptured(void* data, DesktopFrame* current_frame = queue_.current_frame(); // Verify the format. - // TODO(jiayl): support capturing sources with pixel formats other than RGBA. + // TODO(bugs.webrtc.org/436974448): support capturing sources with pixel + // formats other than RGBA. int captured_bytes_per_pixel = header.cbSize / header.width / header.height; if (header.format != GUID_WICPixelFormat32bppRGBA || header.width != static_cast<UINT>(current_frame->size().width()) || @@ -388,9 +389,10 @@ void ScreenCapturerWinMagnifier::CreateCurrentFrameIfNecessary( if (!queue_.current_frame() || !queue_.current_frame()->size().equals(size)) { std::unique_ptr<DesktopFrame> frame = shared_memory_factory_ - ? SharedMemoryDesktopFrame::Create(size, + ? SharedMemoryDesktopFrame::Create(size, FOURCC_ARGB, shared_memory_factory_.get()) - : std::unique_ptr<DesktopFrame>(new BasicDesktopFrame(size)); + : std::unique_ptr<DesktopFrame>( + new BasicDesktopFrame(size, FOURCC_ARGB)); queue_.ReplaceCurrentFrame(SharedDesktopFrame::Wrap(std::move(frame))); } } diff --git a/third_party/libwebrtc/moz-patch-stack/s0001.patch b/third_party/libwebrtc/moz-patch-stack/s0001.patch @@ -492,7 +492,7 @@ index a80d9aa1ff..0e77405fa4 100644 } diff --git a/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc b/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc -index 531130a876..fcaaee9eb7 100644 +index 732aa4d29d..50a3147b31 100644 --- a/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc +++ b/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc @@ -39,6 +39,7 @@ namespace { @@ -521,7 +521,7 @@ index 531130a876..fcaaee9eb7 100644 x_display_->AddEventHandler(xfixes_event_base_ + XFixesCursorNotify, this); diff --git a/modules/desktop_capture/linux/x11/screen_capturer_x11.cc b/modules/desktop_capture/linux/x11/screen_capturer_x11.cc -index 27b334f4f7..68ae5fea33 100644 +index 90dd797cb3..158e2cc90a 100644 --- a/modules/desktop_capture/linux/x11/screen_capturer_x11.cc +++ b/modules/desktop_capture/linux/x11/screen_capturer_x11.cc @@ -307,7 +307,7 @@ bool ScreenCapturerX11::GetSourceList(SourceList* sources) { @@ -534,7 +534,7 @@ index 27b334f4f7..68ae5fea33 100644 } diff --git a/modules/desktop_capture/linux/x11/window_capturer_x11.cc b/modules/desktop_capture/linux/x11/window_capturer_x11.cc -index 95f453064e..01ef044dd3 100644 +index 8e592ff2d9..d39a3a2361 100644 --- a/modules/desktop_capture/linux/x11/window_capturer_x11.cc +++ b/modules/desktop_capture/linux/x11/window_capturer_x11.cc @@ -62,6 +62,7 @@ bool WindowCapturerX11::GetSourceList(SourceList* sources) { diff --git a/third_party/libwebrtc/moz-patch-stack/s0005.patch b/third_party/libwebrtc/moz-patch-stack/s0005.patch @@ -29,7 +29,7 @@ index 127cf5ee24..28f0510e3d 100644 } // namespace webrtc diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm -index 5f36971ea9..82c07d777a 100644 +index 57ff0688a3..7405c95911 100644 --- a/modules/desktop_capture/mac/screen_capturer_mac.mm +++ b/modules/desktop_capture/mac/screen_capturer_mac.mm @@ -189,6 +189,7 @@ void ScreenCapturerMac::Start(Callback* callback) { diff --git a/third_party/libwebrtc/moz-patch-stack/s0006.patch b/third_party/libwebrtc/moz-patch-stack/s0006.patch @@ -16,7 +16,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/9314046d89ebc0836 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm -index 82c07d777a..955a13f435 100644 +index 7405c95911..06fc71da29 100644 --- a/modules/desktop_capture/mac/screen_capturer_mac.mm +++ b/modules/desktop_capture/mac/screen_capturer_mac.mm @@ -287,7 +287,8 @@ bool ScreenCapturerMac::GetSourceList(SourceList* screens) { diff --git a/third_party/libwebrtc/moz-patch-stack/s0027.patch b/third_party/libwebrtc/moz-patch-stack/s0027.patch @@ -871,10 +871,10 @@ index 075e2a8110..1f3a66667a 100644 } else { cflags = [ diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn -index a3110d134f..d41f2ccb2b 100644 +index 80036ec012..f45c664600 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn -@@ -344,37 +344,12 @@ rtc_library("desktop_capture") { +@@ -345,37 +345,12 @@ rtc_library("desktop_capture") { ] deps += [ ":desktop_capture_objc" ] } @@ -912,7 +912,7 @@ index a3110d134f..d41f2ccb2b 100644 } if (rtc_use_x11_extensions) { -@@ -537,9 +512,7 @@ rtc_library("desktop_capture") { +@@ -538,9 +513,7 @@ rtc_library("desktop_capture") { deps += [ "../../rtc_base:sanitizer" ] } diff --git a/third_party/libwebrtc/moz-patch-stack/s0034.patch b/third_party/libwebrtc/moz-patch-stack/s0034.patch @@ -263,7 +263,7 @@ index e90ef0e06a..0e96125f40 100644 cflags = [ "-mfpu=neon" ] } diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn -index d41f2ccb2b..9ea19a8b48 100644 +index f45c664600..4c4366dad2 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -10,7 +10,7 @@ import("//build/config/linux/gtk/gtk.gni") diff --git a/third_party/libwebrtc/moz-patch-stack/s0074.patch b/third_party/libwebrtc/moz-patch-stack/s0074.patch @@ -10,7 +10,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/158a888cad8869a2f 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc -index 02f5a56bed..f1f5a796e1 100644 +index dfcb446fa0..bab528507a 100644 --- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc @@ -57,6 +57,13 @@ diff --git a/third_party/libwebrtc/moz-patch-stack/s0075.patch b/third_party/libwebrtc/moz-patch-stack/s0075.patch @@ -12,7 +12,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/237d19fe96dd7d25b 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc -index f1f5a796e1..9be5546e3c 100644 +index bab528507a..77c0d8576b 100644 --- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc @@ -436,7 +436,9 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream( @@ -36,7 +36,7 @@ index f1f5a796e1..9be5546e3c 100644 modifiers_ = egl_dmabuf_->QueryDmaBufModifiers(format); if (!modifiers_.empty()) { -@@ -971,7 +974,7 @@ bool SharedScreenCastStreamPrivate::ProcessDMABuffer( +@@ -976,7 +979,7 @@ bool SharedScreenCastStreamPrivate::ProcessDMABuffer( const uint n_planes = spa_buffer->n_datas; diff --git a/third_party/libwebrtc/moz-patch-stack/s0076.patch b/third_party/libwebrtc/moz-patch-stack/s0076.patch @@ -11,10 +11,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0ec1b33b95dbb2d39 2 files changed, 7 insertions(+) diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn -index 9ea19a8b48..6e2b55c4ad 100644 +index 4c4366dad2..b4860feadb 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn -@@ -388,6 +388,9 @@ rtc_library("desktop_capture") { +@@ -389,6 +389,9 @@ rtc_library("desktop_capture") { "Xrender", "Xtst", ] diff --git a/third_party/libwebrtc/moz-patch-stack/s0102.patch b/third_party/libwebrtc/moz-patch-stack/s0102.patch @@ -560,7 +560,7 @@ index 0e96125f40..c72b3714c4 100644 } diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn -index 6e2b55c4ad..94a3be6ad1 100644 +index b4860feadb..651ea6ac51 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -6,8 +6,8 @@ diff --git a/third_party/libwebrtc/moz-patch-stack/s0114.patch b/third_party/libwebrtc/moz-patch-stack/s0114.patch @@ -17,10 +17,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/506d4efaf2dc29472 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn -index 94a3be6ad1..75196a1bc6 100644 +index 651ea6ac51..85aecb7b1e 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn -@@ -553,6 +553,10 @@ rtc_library("desktop_capture") { +@@ -554,6 +554,10 @@ rtc_library("desktop_capture") { "../../rtc_base:sanitizer", "../portal", ] diff --git a/third_party/libwebrtc/moz-patch-stack/s0119.patch b/third_party/libwebrtc/moz-patch-stack/s0119.patch @@ -65,10 +65,10 @@ index 87e1884583..420a754edd 100644 static std::unique_ptr<Call> Create(CallConfig config); diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn -index 75196a1bc6..bcc2c87ce8 100644 +index 85aecb7b1e..8447de5d9f 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn -@@ -390,6 +390,11 @@ rtc_library("desktop_capture") { +@@ -391,6 +391,11 @@ rtc_library("desktop_capture") { ] if (build_with_mozilla) { libs -= [ "Xtst" ]