Co-authored-by: reito <cnschwarzer@qq.com>
This commit is contained in:
trop[bot] 2024-09-11 22:16:23 +00:00 коммит произвёл GitHub
Родитель fcab67ad37
Коммит 55b66488bc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 18 добавлений и 9 удалений

Просмотреть файл

@ -20,4 +20,5 @@
* `fd` number - File descriptor for the underlying memory object (usually dmabuf). * `fd` number - File descriptor for the underlying memory object (usually dmabuf).
* `modifier` string _Linux_ - The modifier is retrieved from GBM library and passed to EGL driver. * `modifier` string _Linux_ - The modifier is retrieved from GBM library and passed to EGL driver.
* `release` Function - Release the resources. The `texture` cannot be directly passed to another process, users need to maintain texture lifecycles in * `release` Function - Release the resources. The `texture` cannot be directly passed to another process, users need to maintain texture lifecycles in
main process, but it is safe to pass the `textureInfo` to another process. main process, but it is safe to pass the `textureInfo` to another process. Only a limited number of textures can exist at the same time, so it's important
that you call `texture.release()` as soon as you're done with the texture.

Просмотреть файл

@ -889,7 +889,7 @@ win.loadURL('https://github.com')
When using shared texture (set `webPreferences.offscreen.useSharedTexture` to `true`) feature, you can pass the texture handle to external rendering pipeline without the overhead of When using shared texture (set `webPreferences.offscreen.useSharedTexture` to `true`) feature, you can pass the texture handle to external rendering pipeline without the overhead of
copying data between CPU and GPU memory, with Chromium's hardware acceleration support. This feature is helpful for high-performance rendering scenarios. copying data between CPU and GPU memory, with Chromium's hardware acceleration support. This feature is helpful for high-performance rendering scenarios.
Only a limited number of textures can exist at the same time, so it's important that you call `texure.release()` as soon as you're done with the texture. Only a limited number of textures can exist at the same time, so it's important that you call `texture.release()` as soon as you're done with the texture.
By managing the texture lifecycle by yourself, you can safely pass the `texture.textureInfo` to other processes through IPC. By managing the texture lifecycle by yourself, you can safely pass the `texture.textureInfo` to other processes through IPC.
```js ```js

Просмотреть файл

@ -28,11 +28,18 @@ OffScreenVideoConsumer::OffScreenVideoConsumer(
video_capturer_->SetMinSizeChangePeriod(base::TimeDelta()); video_capturer_->SetMinSizeChangePeriod(base::TimeDelta());
video_capturer_->SetFormat(media::PIXEL_FORMAT_ARGB); video_capturer_->SetFormat(media::PIXEL_FORMAT_ARGB);
// Disable any constraint to make the capture_size keep same with source_size, // Previous design of OSR try to set the resolution constraint to match the
// which will not have a letterbox no matter how size changed. It can also // view's size. It is actually not necessary and creates faulty textures
// prevent the delay that caused by comparing content_rect with view's size // when the window/view's size changes frequently. The constraint may not
// when received a new frame and reset the resolution change then request a // take effect before the internal frame size changes, and makes the capturer
// new frame. // try to resize the new frame size to the old constraint size, which makes
// the output image blurry. (For example, small window suddenly expands to
// maximum size, will actually produce a small output image with maximized
// window resized to fit the small image, however, the expected output is
// a maximized image without resizing).
// So, we just set the constraint to no limit (1x1 to max). When the window
// size changed, a new frame with new size will be automatically generated.
// There's no need to manually set the constraint and request a new frame.
video_capturer_->SetResolutionConstraints( video_capturer_->SetResolutionConstraints(
gfx::Size(1, 1), gfx::Size(1, 1),
gfx::Size(media::limits::kMaxDimension, media::limits::kMaxDimension), gfx::Size(media::limits::kMaxDimension, media::limits::kMaxDimension),
@ -109,7 +116,7 @@ void OffScreenVideoConsumer::OnFrameCaptured(
texture.releaser_holder = new OffscreenReleaserHolder(std::move(gmb_handle), texture.releaser_holder = new OffscreenReleaserHolder(std::move(gmb_handle),
std::move(callbacks)); std::move(callbacks));
callback_.Run(content_rect, {}, texture); callback_.Run(content_rect, {}, std::move(texture));
return; return;
} }

Просмотреть файл

@ -11,6 +11,7 @@
#include <string> #include <string>
#include "base/containers/to_vector.h"
#include "shell/common/gin_converters/gfx_converter.h" #include "shell/common/gin_converters/gfx_converter.h"
#include "shell/common/gin_converters/optional_converter.h" #include "shell/common/gin_converters/optional_converter.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
@ -117,7 +118,7 @@ v8::Local<v8::Value> Converter<electron::OffscreenSharedTextureValue>::ToV8(
sizeof(val.shared_texture_handle)); sizeof(val.shared_texture_handle));
dict.Set("sharedTextureHandle", handle_buf.ToLocalChecked()); dict.Set("sharedTextureHandle", handle_buf.ToLocalChecked());
#elif BUILDFLAG(IS_LINUX) #elif BUILDFLAG(IS_LINUX)
auto v8_planes = base::ToVector(val.planes, [isolate](const auto& plane){ auto v8_planes = base::ToVector(val.planes, [isolate](const auto& plane) {
gin::Dictionary v8_plane(isolate, v8::Object::New(isolate)); gin::Dictionary v8_plane(isolate, v8::Object::New(isolate));
v8_plane.Set("stride", plane.stride); v8_plane.Set("stride", plane.stride);
v8_plane.Set("offset", plane.offset); v8_plane.Set("offset", plane.offset);