mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
feat: paint event move texture data to handle, add colorSpace (#47315)
* feat: paint event move shared texture to handle, add color space * feat: add breaking change * fix: properties. * fix: remove utf8 bom
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
|
||||
// Copyright (c) 2024 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be found in
|
||||
// the LICENSE file.
|
||||
// Copyright (c) 2025 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/gin_converters/osr_converter.h"
|
||||
|
||||
@@ -17,6 +16,7 @@
|
||||
#endif
|
||||
#include "shell/common/gin_converters/gfx_converter.h"
|
||||
#include "shell/common/gin_converters/optional_converter.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/node_util.h"
|
||||
|
||||
@@ -87,10 +87,11 @@ v8::Local<v8::Value> Converter<electron::OffscreenSharedTextureValue>::ToV8(
|
||||
|
||||
auto releaserHolder = v8::External::New(isolate, monitor);
|
||||
auto releaserFunc = [](const v8::FunctionCallbackInfo<v8::Value>& info) {
|
||||
auto* holder = static_cast<OffscreenReleaseHolderMonitor*>(
|
||||
auto* mon = static_cast<OffscreenReleaseHolderMonitor*>(
|
||||
info.Data().As<v8::External>()->Value());
|
||||
// Release the shared texture, so that future frames can be generated.
|
||||
holder->ReleaseTexture();
|
||||
mon->ReleaseTexture();
|
||||
// Release the monitor happens at GC, don't release here.
|
||||
};
|
||||
auto releaser = v8::Function::New(isolate->GetCurrentContext(), releaserFunc,
|
||||
releaserHolder)
|
||||
@@ -104,6 +105,7 @@ v8::Local<v8::Value> Converter<electron::OffscreenSharedTextureValue>::ToV8(
|
||||
dict.Set("visibleRect", val.visible_rect);
|
||||
dict.Set("contentRect", val.content_rect);
|
||||
dict.Set("timestamp", val.timestamp);
|
||||
dict.Set("colorSpace", val.color_space);
|
||||
dict.Set("widgetType", OsrWidgetTypeToString(val.widget_type));
|
||||
|
||||
gin::Dictionary metadata(isolate, v8::Object::New(isolate));
|
||||
@@ -113,12 +115,21 @@ v8::Local<v8::Value> Converter<electron::OffscreenSharedTextureValue>::ToV8(
|
||||
metadata.Set("frameCount", val.frame_count);
|
||||
dict.Set("metadata", ConvertToV8(isolate, metadata));
|
||||
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
|
||||
dict.Set("sharedTextureHandle",
|
||||
electron::Buffer::Copy(
|
||||
isolate, base::byte_span_from_ref(val.shared_texture_handle))
|
||||
.ToLocalChecked());
|
||||
gin::Dictionary sharedTexture(isolate, v8::Object::New(isolate));
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
sharedTexture.Set(
|
||||
"ntHandle",
|
||||
electron::Buffer::Copy(
|
||||
isolate, base::byte_span_from_ref(val.shared_texture_handle))
|
||||
.ToLocalChecked());
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
sharedTexture.Set(
|
||||
"ioSurface",
|
||||
electron::Buffer::Copy(
|
||||
isolate, base::byte_span_from_ref(val.shared_texture_handle))
|
||||
.ToLocalChecked());
|
||||
#elif BUILDFLAG(IS_LINUX)
|
||||
gin::Dictionary nativePixmap(isolate, v8::Object::New(isolate));
|
||||
auto v8_planes = base::ToVector(val.planes, [isolate](const auto& plane) {
|
||||
gin::Dictionary v8_plane(isolate, v8::Object::New(isolate));
|
||||
v8_plane.Set("stride", plane.stride);
|
||||
@@ -127,10 +138,14 @@ v8::Local<v8::Value> Converter<electron::OffscreenSharedTextureValue>::ToV8(
|
||||
v8_plane.Set("fd", plane.fd);
|
||||
return v8_plane;
|
||||
});
|
||||
dict.Set("planes", v8_planes);
|
||||
dict.Set("modifier", base::NumberToString(val.modifier));
|
||||
nativePixmap.Set("planes", v8_planes);
|
||||
nativePixmap.Set("modifier", base::NumberToString(val.modifier));
|
||||
nativePixmap.Set("supportsZeroCopyWebGpuImport",
|
||||
val.supports_zero_copy_webgpu_import);
|
||||
sharedTexture.Set("nativePixmap", ConvertToV8(isolate, nativePixmap));
|
||||
#endif
|
||||
|
||||
dict.Set("handle", ConvertToV8(isolate, sharedTexture));
|
||||
root.Set("textureInfo", ConvertToV8(isolate, dict));
|
||||
auto root_local = ConvertToV8(isolate, root);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
// Copyright (c) 2024 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be found in
|
||||
// the LICENSE file.
|
||||
// Copyright (c) 2025 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ELECTRON_SHELL_COMMON_GIN_CONVERTERS_OSR_CONVERTER_H_
|
||||
#define ELECTRON_SHELL_COMMON_GIN_CONVERTERS_OSR_CONVERTER_H_
|
||||
|
||||
Reference in New Issue
Block a user