community/firefox: upgrade to 113.0

This commit is contained in:
psykose 2023-05-09 01:46:39 +00:00
parent 74a737b1e2
commit bdfb05fb29
4 changed files with 53 additions and 519 deletions

View File

@ -0,0 +1,41 @@
Patch-Source: https://github.com/archlinux/svntogit-packages/blob/f1173939c033b642ea4c2b5c53fa9b881d0545f5/trunk/0001-Bug-1831691-Use-the-vendored-glean_parser-for-all-of.patch
--
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ahochheiden <ahochheiden@mozilla.com>
Date: Sat, 6 May 2023 21:07:09 +0000
Subject: [PATCH] Bug 1831691 - Use the vendored 'glean_parser' for all of
`mach` r=firefox-build-system-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D177340
---
python/sites/build.txt | 1 -
python/sites/mach.txt | 1 +
python/sites/python-test.txt | 1 -
3 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/python/sites/build.txt b/python/sites/build.txt
index b43f7680d200..4e6f6c51d9ad 100644
--- a/python/sites/build.txt
+++ b/python/sites/build.txt
@@ -1,2 +1 @@
-vendored:third_party/python/glean_parser
pth:third_party/python/vsdownload
diff --git a/python/sites/mach.txt b/python/sites/mach.txt
index b9fafd0b9c59..a18691184312 100644
--- a/python/sites/mach.txt
+++ b/python/sites/mach.txt
@@ -78,6 +78,7 @@ vendored:third_party/python/esprima
vendored:third_party/python/fluent.migrate
vendored:third_party/python/fluent.syntax
vendored:third_party/python/giturlparse
+vendored:third_party/python/glean_parser
vendored:third_party/python/gyp/pylib
vendored:third_party/python/idna
vendored:third_party/python/importlib_metadata
diff --git a/python/sites/python-test.txt b/python/sites/python-test.txt
index 48cdcd2b8f48..74889365a22b 100644
--- a/python/sites/python-test.txt
+++ b/python/sites/python-test.txt
@@ -1,2 +1 @@
-vendored:third_party/python/glean_parser
pypi:pytest==7.0.1

View File

@ -3,9 +3,9 @@
# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: psykose <alice@ayaya.dev>
pkgname=firefox
pkgver=112.0.2
_releasedate=2023-04-25
pkgrel=1
pkgver=113.0
_releasedate=2023-05-09
pkgrel=0
pkgdesc="Firefox web browser"
url="https://www.firefox.com/"
# s390x blocked by lld
@ -67,6 +67,7 @@ makedepends="
zip
"
source="$pkgname-$pkgver.tar.xz::https://ftp.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz
0001-Bug-1831691-Use-the-vendored-glean_parser-for-all-of.patch
avoid-redefinition.patch
disable-moz-stackwalk.patch
fix-fortify-system-wrappers.patch
@ -74,13 +75,12 @@ source="$pkgname-$pkgver.tar.xz::https://ftp.mozilla.org/pub/firefox/releases/$p
fix-rust-target.patch
fix-webrtc-glibcisms.patch
no-ccache-stats.patch
python-deps.patch
rust-lto-thin.patch
riscv64-no-lto.patch
sandbox-fork.patch
sandbox-largefile.patch
sandbox-sched_setscheduler.patch
webrtc.patch
zstandard.patch
stab.h
@ -712,7 +712,8 @@ package() {
}
sha512sums="
2cd7adeb6c9a39ad4c5366982e0e58382d7f205e6f2cee02b8ec2867034d1c0c884eeeb870a35db35cba60fa9c84aea73f8c77cfd9f36b5146dde06464aaabd1 firefox-112.0.2.tar.xz
96b0f0774083270f4fcce06085b177ced25ba05da7291d777f1da1d5bbad30721bc6363b76e06ccb64fc092778c8326a426a8bfdfa3cbaafd4f1169b924744a5 firefox-113.0.tar.xz
028a723d749b9b0a924a13de3e33ff84829bfab872cf6e41293fe11b7e8f640b5ca45d1323597ac7c9bb093ffcee4c72a83ca9210f6bdd22e12ea5d67ef3d3f3 0001-Bug-1831691-Use-the-vendored-glean_parser-for-all-of.patch
b1cb2db3122634f66d2bae7066e76f2dcd455c464e021db4de3b0a08314df95cb667846081682db549dd2af8a00831cabe44a2420c66cdfb5e3b5fa7e6bd21d3 avoid-redefinition.patch
454ea3263cabce099accbdc47aaf83be26a19f8b5a4568c01a7ef0384601cf8315efd86cd917f9c8bf419c2c845db89a905f3ff9a8eb0c8e41042e93aa96a85c disable-moz-stackwalk.patch
2f4f15974d52de4bb273b62a332d13620945d284bbc6fe6bd0a1f58ff7388443bc1d3bf9c82cc31a8527aad92b0cd3a1bc41d0af5e1800e0dcbd7033e58ffd71 fix-fortify-system-wrappers.patch
@ -720,13 +721,12 @@ d3a54897089eda9fdfe4b25ade1cb2c01c4b31fa9bf0e0ddbb0bbe674072ec5d36a6e52f791a8cbc
cd68b89e29e5f6379fbd5679db27b9a5ef70ea65e51c0d0a8137e1f1fd210e35a8cfb047798e9549bc7275606d7ec5c8d8af1335d29da4699db7acd8bc7ff556 fix-rust-target.patch
305c874fdea3096e9c4c6aa6520ac64bb1c347c4b59db8360096646593fe684c3b5377874d91cecd33d56d1410b4714fbdea2b514923723ecbeff79d51265d9b fix-webrtc-glibcisms.patch
c0437a6753f3f350968fa12d250efdfe1bea77baf0e4c06b072b5cc9e78c774dbf4506bc536337030d349fb3ba4460097b75b0c7c5b8fb2d39d8b0a392948936 no-ccache-stats.patch
ff3618223bba2d7b877a16451256e67d973c5f4e24027cb5a7da4c0a6f6a028a1eb51d3cbcddae71bca584a4c13cb485950b86022ea26d4e25ae3fdf3ce5d910 python-deps.patch
9f433c8051d05efb8b119e0b67b97951837aca6a8c5671646714a24023be11a9d63fa7c4e56a6c7f3911c9d8406b06cd95926de1a82925d02197dfd55daf5642 rust-lto-thin.patch
b12dbff6513ac8c231d91c257a9accecc034d9ea9c31d99ca0454334ccf80fe7b50d6a356182dc46a9f25064366ea9a177f463cb2544b1cf5368ee6bd71bc095 riscv64-no-lto.patch
2518f2fc75b5db30058e0735f47d60fdf1e7adfaeee4b33fb2afb1bd9a616ce943fd88f4404d0802d4083703f4acf1d5ad42377218d025bc768807fbaf7e1609 sandbox-fork.patch
b7d0a6126bdf6c0569f80aabf5b37ed2c7a35712eb8a0404a2d85381552f5555d4f97d213ea26cec6a45dc2785f22439376ed5f8e78b4fd664ef0223307b333e sandbox-largefile.patch
94433c5ffdbe579c456d95c5f053f61fcbab2f652fa90bc69dcc27d9a1507a8e5c677adeadae9a7a75cc9a55184c1040737f4dfd10b279c088ef016561e6f135 sandbox-sched_setscheduler.patch
4d711fb68512138656f4702802aee2c6a89ebc0892dd0a5dcf9a7fbef0d96f41fcb2907409d586499fc9254a0c690210e22a6e4638f1bcf6c8a1e2cb5137a6fb webrtc.patch
54e37035bf86a5ead9092714af1a7bc7c1c86751133cd3937b59e700a8b17a244694812b83d16f8bca28333d157b273f7496611d17ccd09268ed0ef346a8cb6b zstandard.patch
0b3f1e4b9fdc868e4738b5c81fd6c6128ce8885b260affcb9a65ff9d164d7232626ce1291aaea70132b3e3124f5e13fef4d39326b8e7173e362a823722a85127 stab.h
333b9df0c8a7693601245dac13522c9e90632f490b2fe1b852bf85fbd033c111a82fec3cfc302cfdea62d591c51042ae69c2c33a5668afacca11ea1f215188bc firefox.desktop
9869ef092609af4caed6aa27f3de6ac49b91ef993ccbfd8a2080465def442d3b02745fbe3c71d362f07c3075d46f388a023c0ad8ebb5f6ffd37e601d997b74f7 distribution.ini

View File

@ -1,9 +1,9 @@
fix build with newer versions
--- a/python/sites/mach.txt
+++ b/python/sites/mach.txt
@@ -141,4 +141,4 @@
@@ -134,4 +134,4 @@
# We aren't (yet) able to pin packages in automation, so we have to
# support down to the oldest locally-installed version (5.4.2).
pypi-optional:psutil>=5.4.2,<=5.9.4:telemetry will be missing some data
-pypi-optional:psutil>=5.4.2,<=5.9.4:telemetry will be missing some data
+pypi-optional:psutil>=5.4.2,<=5.10.0:telemetry will be missing some data
-pypi-optional:zstandard>=0.11.1,<=0.19.0:zstd archives will not be possible to extract
+pypi-optional:zstandard>=0.11.1:zstd archives will not be possible to extract
+pypi-optional:zstandard>=0.11.1,<=0.24.0:zstd archives will not be possible to extract

View File

@ -1,507 +0,0 @@
Patch-Source: https://src.fedoraproject.org/rpms/firefox/blob/d5f2b2028f09d610ce0c3e70f85eb5baea4e9037/f/libwebrtc-pipewire-capturer-import-dmabuf-directly-into-desktop-frame.patch
--
From d9faa73cbbc186d7dd0dbfce0589012a0bed9f17 Mon Sep 17 00:00:00 2001
From: Jan Grulich <grulja@gmail.com>
Date: Fri, 17 Mar 2023 10:58:10 +0100
Subject: [PATCH] PipeWire capturer: import DMABufs directly into desktop frame
Originally DMABufs were imported into a temporary buffer followed by a
copy operation into the desktop frame itself. This is not needed as we
can import them directly into desktop frames and avoid this overhead.
Also drop support for MemPtr buffers as both Mutter and KWin don't seem
to support them and they are going to be too slow anyway.
Testing with latest Chromium, I could see two processes with usage around 20% and 40% without this change going down to 10% and 20% with
this change applied.
Bug: webrtc:13429
Bug: chrome:1378258
Change-Id: Ice3292528ff56300931c8638f8e03d4883d5e331
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/297501
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Jan Grulich <grulja@gmail.com>
Cr-Commit-Position: refs/heads/main@{#39594}
---
diff --git a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
index 5bbd5d7aba..b529077c6d 100644
--- a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
+++ b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
@@ -101,11 +101,23 @@ typedef void (*glDeleteTextures_func)(GLsizei n, const GLuint* textures);
typedef void (*glGenTextures_func)(GLsizei n, GLuint* textures);
typedef GLenum (*glGetError_func)(void);
typedef const GLubyte* (*glGetString_func)(GLenum name);
-typedef void (*glGetTexImage_func)(GLenum target,
- GLint level,
- GLenum format,
- GLenum type,
- void* pixels);
+typedef void (*glReadPixels_func)(GLint x,
+ GLint y,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ void* data);
+typedef void (*glGenFramebuffers_func)(GLsizei n, GLuint* ids);
+typedef void (*glDeleteFramebuffers_func)(GLsizei n,
+ const GLuint* framebuffers);
+typedef void (*glBindFramebuffer_func)(GLenum target, GLuint framebuffer);
+typedef void (*glFramebufferTexture2D_func)(GLenum target,
+ GLenum attachment,
+ GLenum textarget,
+ GLuint texture,
+ GLint level);
+typedef GLenum (*glCheckFramebufferStatus_func)(GLenum target);
typedef void (*glTexParameteri_func)(GLenum target, GLenum pname, GLint param);
typedef void* (*glXGetProcAddressARB_func)(const char*);
@@ -118,7 +130,12 @@ glDeleteTextures_func GlDeleteTextures = nullptr;
glGenTextures_func GlGenTextures = nullptr;
glGetError_func GlGetError = nullptr;
glGetString_func GlGetString = nullptr;
-glGetTexImage_func GlGetTexImage = nullptr;
+glReadPixels_func GlReadPixels = nullptr;
+glGenFramebuffers_func GlGenFramebuffers = nullptr;
+glDeleteFramebuffers_func GlDeleteFramebuffers = nullptr;
+glBindFramebuffer_func GlBindFramebuffer = nullptr;
+glFramebufferTexture2D_func GlFramebufferTexture2D = nullptr;
+glCheckFramebufferStatus_func GlCheckFramebufferStatus = nullptr;
glTexParameteri_func GlTexParameteri = nullptr;
glXGetProcAddressARB_func GlXGetProcAddressARB = nullptr;
@@ -279,12 +296,26 @@ static bool LoadGL() {
(glDeleteTextures_func)GlXGetProcAddressARB("glDeleteTextures");
GlGenTextures = (glGenTextures_func)GlXGetProcAddressARB("glGenTextures");
GlGetError = (glGetError_func)GlXGetProcAddressARB("glGetError");
- GlGetTexImage = (glGetTexImage_func)GlXGetProcAddressARB("glGetTexImage");
+ GlReadPixels = (glReadPixels_func)GlXGetProcAddressARB("glReadPixels");
+ GlGenFramebuffers =
+ (glGenFramebuffers_func)GlXGetProcAddressARB("glGenFramebuffers");
+ GlDeleteFramebuffers =
+ (glDeleteFramebuffers_func)GlXGetProcAddressARB("glDeleteFramebuffers");
+ GlBindFramebuffer =
+ (glBindFramebuffer_func)GlXGetProcAddressARB("glBindFramebuffer");
+ GlFramebufferTexture2D = (glFramebufferTexture2D_func)GlXGetProcAddressARB(
+ "glFramebufferTexture2D");
+ GlCheckFramebufferStatus =
+ (glCheckFramebufferStatus_func)GlXGetProcAddressARB(
+ "glCheckFramebufferStatus");
+
GlTexParameteri =
(glTexParameteri_func)GlXGetProcAddressARB("glTexParameteri");
return GlBindTexture && GlDeleteTextures && GlGenTextures && GlGetError &&
- GlGetTexImage && GlTexParameteri;
+ GlReadPixels && GlGenFramebuffers && GlDeleteFramebuffers &&
+ GlBindFramebuffer && GlFramebufferTexture2D &&
+ GlCheckFramebufferStatus && GlTexParameteri;
}
return false;
@@ -435,6 +466,14 @@ EglDmaBuf::~EglDmaBuf() {
EglTerminate(egl_.display);
}
+ if (fbo_) {
+ GlDeleteFramebuffers(1, &fbo_);
+ }
+
+ if (texture_) {
+ GlDeleteTextures(1, &texture_);
+ }
+
// BUG: crbug.com/1290566
// Closing libEGL.so.1 when using NVidia drivers causes a crash
// when EglGetPlatformDisplayEXT() is used, at least this one is enough
@@ -466,20 +505,20 @@ bool EglDmaBuf::GetClientExtensions(EGLDisplay dpy, EGLint name) {
}
RTC_NO_SANITIZE("cfi-icall")
-std::unique_ptr<uint8_t[]> EglDmaBuf::ImageFromDmaBuf(
- const DesktopSize& size,
- uint32_t format,
- const std::vector<PlaneData>& plane_datas,
- uint64_t modifier) {
- std::unique_ptr<uint8_t[]> src;
-
+bool EglDmaBuf::ImageFromDmaBuf(const DesktopSize& size,
+ uint32_t format,
+ const std::vector<PlaneData>& plane_datas,
+ uint64_t modifier,
+ const DesktopVector& offset,
+ const DesktopSize& buffer_size,
+ uint8_t* data) {
if (!egl_initialized_) {
- return src;
+ return false;
}
if (plane_datas.size() <= 0) {
RTC_LOG(LS_ERROR) << "Failed to process buffer: invalid number of planes";
- return src;
+ return false;
}
EGLint attribs[47];
@@ -568,20 +607,32 @@ std::unique_ptr<uint8_t[]> EglDmaBuf::ImageFromDmaBuf(
if (image == EGL_NO_IMAGE) {
RTC_LOG(LS_ERROR) << "Failed to record frame: Error creating EGLImage - "
<< FormatEGLError(EglGetError());
- return src;
+ return false;
}
// create GL 2D texture for framebuffer
- GLuint texture;
- GlGenTextures(1, &texture);
- GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- GlBindTexture(GL_TEXTURE_2D, texture);
+ if (!texture_) {
+ GlGenTextures(1, &texture_);
+ GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ }
+ GlBindTexture(GL_TEXTURE_2D, texture_);
GlEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
- src = std::make_unique<uint8_t[]>(plane_datas[0].stride * size.height());
+ if (!fbo_) {
+ GlGenFramebuffers(1, &fbo_);
+ }
+
+ GlBindFramebuffer(GL_FRAMEBUFFER, fbo_);
+ GlFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+ texture_, 0);
+ if (GlCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
+ RTC_LOG(LS_ERROR) << "Failed to bind DMA buf framebuffer";
+ EglDestroyImageKHR(egl_.display, image);
+ return false;
+ }
GLenum gl_format = GL_BGRA;
switch (format) {
@@ -598,17 +649,18 @@ std::unique_ptr<uint8_t[]> EglDmaBuf::ImageFromDmaBuf(
gl_format = GL_BGRA;
break;
}
- GlGetTexImage(GL_TEXTURE_2D, 0, gl_format, GL_UNSIGNED_BYTE, src.get());
- if (GlGetError()) {
+ GlReadPixels(offset.x(), offset.y(), buffer_size.width(),
+ buffer_size.height(), gl_format, GL_UNSIGNED_BYTE, data);
+
+ const GLenum error = GlGetError();
+ if (error) {
RTC_LOG(LS_ERROR) << "Failed to get image from DMA buffer.";
- return src;
}
- GlDeleteTextures(1, &texture);
EglDestroyImageKHR(egl_.display, image);
- return src;
+ return !error;
}
RTC_NO_SANITIZE("cfi-icall")
diff --git a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.h b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.h
index f1d96b2f80..22a8f5ab52 100644
--- a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.h
+++ b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.h
@@ -41,11 +41,15 @@ class EglDmaBuf {
EglDmaBuf();
~EglDmaBuf();
- std::unique_ptr<uint8_t[]> ImageFromDmaBuf(
- const DesktopSize& size,
- uint32_t format,
- const std::vector<PlaneData>& plane_datas,
- uint64_t modifiers);
+ // Returns whether the image was successfully imported from
+ // given DmaBuf and its parameters
+ bool ImageFromDmaBuf(const DesktopSize& size,
+ uint32_t format,
+ const std::vector<PlaneData>& plane_datas,
+ uint64_t modifiers,
+ const DesktopVector& offset,
+ const DesktopSize& buffer_size,
+ uint8_t* data);
std::vector<uint64_t> QueryDmaBufModifiers(uint32_t format);
bool IsEglInitialized() const { return egl_initialized_; }
@@ -58,6 +62,8 @@ class EglDmaBuf {
int32_t drm_fd_ = -1; // for GBM buffer mmap
gbm_device* gbm_device_ = nullptr; // for passed GBM buffer retrieval
+ GLuint fbo_ = 0;
+ GLuint texture_ = 0;
EGLStruct egl_;
absl::optional<std::string> GetRenderNode();
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
index 0ca75d00fc..a8879764c7 100644
--- 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
@@ -149,6 +149,12 @@ class SharedScreenCastStreamPrivate {
struct spa_video_info_raw spa_video_format_;
void ProcessBuffer(pw_buffer* buffer);
+ bool ProcessMemFDBuffer(pw_buffer* buffer,
+ DesktopFrame& frame,
+ const DesktopVector& offset);
+ bool ProcessDMABuffer(pw_buffer* buffer,
+ DesktopFrame& frame,
+ const DesktopVector& offset);
void ConvertRGBxToBGRx(uint8_t* frame, uint32_t size);
// PipeWire callbacks
@@ -268,9 +274,8 @@ void SharedScreenCastStreamPrivate::OnStreamParamChanged(
std::vector<const spa_pod*> params;
const int buffer_types =
has_modifier || (that->pw_server_version_ >= kDmaBufMinVersion)
- ? (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd) |
- (1 << SPA_DATA_MemPtr)
- : (1 << SPA_DATA_MemFd) | (1 << SPA_DATA_MemPtr);
+ ? (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd)
+ : (1 << SPA_DATA_MemFd);
params.push_back(reinterpret_cast<spa_pod*>(spa_pod_builder_add_object(
&builder, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
@@ -605,9 +610,6 @@ DesktopVector SharedScreenCastStreamPrivate::CaptureCursorPosition() {
RTC_NO_SANITIZE("cfi-icall")
void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) {
spa_buffer* spa_buffer = buffer->buffer;
- ScopedBuf map;
- std::unique_ptr<uint8_t[]> src_unique_ptr;
- uint8_t* src = nullptr;
// Try to update the mouse cursor first, because it can be the only
// information carried by the buffer
@@ -641,76 +643,6 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) {
return;
}
- if (spa_buffer->datas[0].type == SPA_DATA_MemFd) {
- map.initialize(
- static_cast<uint8_t*>(
- mmap(nullptr,
- spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
- PROT_READ, MAP_PRIVATE, spa_buffer->datas[0].fd, 0)),
- spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
- spa_buffer->datas[0].fd);
-
- if (!map) {
- RTC_LOG(LS_ERROR) << "Failed to mmap the memory: "
- << std::strerror(errno);
- return;
- }
-
- src = SPA_MEMBER(map.get(), spa_buffer->datas[0].mapoffset, uint8_t);
- } else if (spa_buffer->datas[0].type == SPA_DATA_DmaBuf) {
- const uint n_planes = spa_buffer->n_datas;
-
- if (!n_planes) {
- return;
- }
-
- std::vector<EglDmaBuf::PlaneData> plane_datas;
- for (uint32_t i = 0; i < n_planes; ++i) {
- EglDmaBuf::PlaneData data = {
- static_cast<int32_t>(spa_buffer->datas[i].fd),
- static_cast<uint32_t>(spa_buffer->datas[i].chunk->stride),
- static_cast<uint32_t>(spa_buffer->datas[i].chunk->offset)};
- plane_datas.push_back(data);
- }
-
- // When importing DMA-BUFs, we use the stride (number of bytes from one row
- // of pixels in the buffer) provided by PipeWire. The stride from PipeWire
- // is given by the graphics driver and some drivers might add some
- // additional padding for memory layout optimizations so not everytime the
- // stride is equal to BYTES_PER_PIXEL x WIDTH. This is fine, because during
- // the import we will use OpenGL and same graphics driver so it will be able
- // to work with the stride it provided, but later on when we work with
- // images we get from DMA-BUFs we will need to update the stride to be equal
- // to BYTES_PER_PIXEL x WIDTH as that's the size of the DesktopFrame we
- // allocate for each captured frame.
- src_unique_ptr = egl_dmabuf_->ImageFromDmaBuf(
- stream_size_, spa_video_format_.format, plane_datas, modifier_);
- if (src_unique_ptr) {
- src = src_unique_ptr.get();
- } else {
- RTC_LOG(LS_ERROR) << "Dropping DMA-BUF modifier: " << modifier_
- << " and trying to renegotiate stream parameters";
-
- if (pw_server_version_ >= kDropSingleModifierMinVersion) {
- modifiers_.erase(
- std::remove(modifiers_.begin(), modifiers_.end(), modifier_),
- modifiers_.end());
- } else {
- modifiers_.clear();
- }
-
- pw_loop_signal_event(pw_thread_loop_get_loop(pw_main_loop_),
- renegotiate_);
- return;
- }
- } else if (spa_buffer->datas[0].type == SPA_DATA_MemPtr) {
- src = static_cast<uint8_t*>(spa_buffer->datas[0].data);
- }
-
- if (!src) {
- return;
- }
-
// Use SPA_META_VideoCrop metadata to get the frame size. KDE and GNOME do
// handle screen/window sharing differently. KDE/KWin doesn't use
// SPA_META_VideoCrop metadata and when sharing a window, it always sets
@@ -763,8 +695,8 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) {
}
// Get the position of the video crop within the stream. Just double-check
- // that the position doesn't exceed the size of the stream itself. NOTE:
- // Currently it looks there is no implementation using this.
+ // that the position doesn't exceed the size of the stream itself.
+ // NOTE: Currently it looks there is no implementation using this.
uint32_t y_offset =
videocrop_metadata_use &&
(videocrop_metadata->region.position.y + frame_size_.height() <=
@@ -777,22 +709,7 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) {
stream_size_.width())
? videocrop_metadata->region.position.x
: 0;
-
- const uint32_t stream_stride = kBytesPerPixel * stream_size_.width();
- uint32_t buffer_stride = spa_buffer->datas[0].chunk->stride;
- uint32_t src_stride = buffer_stride;
-
- if (spa_buffer->datas[0].type == SPA_DATA_DmaBuf &&
- buffer_stride > stream_stride) {
- // When DMA-BUFs are used, sometimes spa_buffer->stride we get might
- // contain additional padding, but after we import the buffer, the stride
- // we used is no longer relevant and we should just calculate it based on
- // the stream width. For more context see https://crbug.com/1333304.
- src_stride = stream_stride;
- }
-
- uint8_t* updated_src =
- src + (src_stride * y_offset) + (kBytesPerPixel * x_offset);
+ DesktopVector offset = DesktopVector(x_offset, y_offset);
webrtc::MutexLock lock(&queue_lock_);
@@ -813,9 +730,17 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) {
queue_.ReplaceCurrentFrame(SharedDesktopFrame::Wrap(std::move(frame)));
}
- queue_.current_frame()->CopyPixelsFrom(
- updated_src, (src_stride - (kBytesPerPixel * x_offset)),
- DesktopRect::MakeWH(frame_size_.width(), frame_size_.height()));
+ bool bufferProcessed = false;
+ if (spa_buffer->datas[0].type == SPA_DATA_MemFd) {
+ bufferProcessed =
+ ProcessMemFDBuffer(buffer, *queue_.current_frame(), offset);
+ } else if (spa_buffer->datas[0].type == SPA_DATA_DmaBuf) {
+ bufferProcessed = ProcessDMABuffer(buffer, *queue_.current_frame(), offset);
+ }
+
+ if (!bufferProcessed) {
+ return;
+ }
if (spa_video_format_.format == SPA_VIDEO_FORMAT_RGBx ||
spa_video_format_.format == SPA_VIDEO_FORMAT_RGBA) {
@@ -832,6 +757,87 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) {
DesktopRect::MakeSize(queue_.current_frame()->size()));
}
+RTC_NO_SANITIZE("cfi-icall")
+bool SharedScreenCastStreamPrivate::ProcessMemFDBuffer(
+ pw_buffer* buffer,
+ DesktopFrame& frame,
+ const DesktopVector& offset) {
+ spa_buffer* spa_buffer = buffer->buffer;
+ ScopedBuf map;
+ uint8_t* src = nullptr;
+
+ map.initialize(
+ static_cast<uint8_t*>(
+ mmap(nullptr,
+ spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+ PROT_READ, MAP_PRIVATE, spa_buffer->datas[0].fd, 0)),
+ spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+ spa_buffer->datas[0].fd);
+
+ if (!map) {
+ RTC_LOG(LS_ERROR) << "Failed to mmap the memory: " << std::strerror(errno);
+ return false;
+ }
+
+ src = SPA_MEMBER(map.get(), spa_buffer->datas[0].mapoffset, uint8_t);
+
+ uint32_t buffer_stride = spa_buffer->datas[0].chunk->stride;
+ uint32_t src_stride = buffer_stride;
+
+ uint8_t* updated_src =
+ src + (src_stride * offset.y()) + (kBytesPerPixel * offset.x());
+
+ frame.CopyPixelsFrom(
+ updated_src, (src_stride - (kBytesPerPixel * offset.x())),
+ DesktopRect::MakeWH(frame.size().width(), frame.size().height()));
+
+ return true;
+}
+
+RTC_NO_SANITIZE("cfi-icall")
+bool SharedScreenCastStreamPrivate::ProcessDMABuffer(
+ pw_buffer* buffer,
+ DesktopFrame& frame,
+ const DesktopVector& offset) {
+ spa_buffer* spa_buffer = buffer->buffer;
+
+ const uint n_planes = spa_buffer->n_datas;
+
+ if (!n_planes) {
+ return false;
+ }
+
+ std::vector<EglDmaBuf::PlaneData> plane_datas;
+ for (uint32_t i = 0; i < n_planes; ++i) {
+ EglDmaBuf::PlaneData data = {
+ static_cast<int32_t>(spa_buffer->datas[i].fd),
+ static_cast<uint32_t>(spa_buffer->datas[i].chunk->stride),
+ static_cast<uint32_t>(spa_buffer->datas[i].chunk->offset)};
+ plane_datas.push_back(data);
+ }
+
+ const bool imported = egl_dmabuf_->ImageFromDmaBuf(
+ stream_size_, spa_video_format_.format, plane_datas, modifier_, offset,
+ frame.size(), frame.data());
+ if (!imported) {
+ RTC_LOG(LS_ERROR) << "Dropping DMA-BUF modifier: " << modifier_
+ << " and trying to renegotiate stream parameters";
+
+ if (pw_server_version_ >= kDropSingleModifierMinVersion) {
+ modifiers_.erase(
+ std::remove(modifiers_.begin(), modifiers_.end(), modifier_),
+ modifiers_.end());
+ } else {
+ modifiers_.clear();
+ }
+
+ pw_loop_signal_event(pw_thread_loop_get_loop(pw_main_loop_), renegotiate_);
+ return false;
+ }
+
+ return true;
+}
+
void SharedScreenCastStreamPrivate::ConvertRGBxToBGRx(uint8_t* frame,
uint32_t size) {
for (uint32_t i = 0; i < size; i += 4) {