mirror of
https://github.com/electron/electron.git
synced 2026-01-06 22:24:03 -05:00
feat: import shared texture supports nv12. (#48922)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
* `bgra` - 32bpp BGRA (byte-order), 1 plane.
|
||||
* `rgba` - 32bpp RGBA (byte-order), 1 plane.
|
||||
* `rgbaf16` - Half float RGBA, 1 plane.
|
||||
* `nv12` - 12bpp with Y plane followed by a 2x2 interleaved UV plane.
|
||||
* `colorSpace` [ColorSpace](color-space.md) (optional) - The color space of the texture.
|
||||
* `codedSize` [Size](size.md) - The full dimensions of the shared texture.
|
||||
* `visibleRect` [Rectangle](rectangle.md) (optional) - A subsection of [0, 0, codedSize.width, codedSize.height]. In common cases, it is the full section area.
|
||||
|
||||
@@ -126,6 +126,8 @@ std::string TransferVideoPixelFormatToString(media::VideoPixelFormat format) {
|
||||
return "rgba";
|
||||
case media::PIXEL_FORMAT_RGBAF16:
|
||||
return "rgbaf16";
|
||||
case media::PIXEL_FORMAT_NV12:
|
||||
return "nv12";
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
@@ -566,6 +568,8 @@ struct Converter<ImportSharedTextureInfo> {
|
||||
out->pixel_format = media::PIXEL_FORMAT_ABGR;
|
||||
else if (pixel_format_str == "rgbaf16")
|
||||
out->pixel_format = media::PIXEL_FORMAT_RGBAF16;
|
||||
else if (pixel_format_str == "nv12")
|
||||
out->pixel_format = media::PIXEL_FORMAT_NV12;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@@ -730,6 +734,14 @@ v8::Local<v8::Value> ImportSharedTexture(v8::Isolate* isolate,
|
||||
shared_image_usage, "SharedTextureVideoFrame"},
|
||||
std::move(gmb_handle));
|
||||
|
||||
if (!si) {
|
||||
gin_helper::ErrorThrower(isolate).ThrowTypeError(
|
||||
"Failed to create shared image from shared texture handle. Texture "
|
||||
"format or dimension might not be supported on current device or "
|
||||
"platform.");
|
||||
return v8::Null(isolate);
|
||||
}
|
||||
|
||||
ImportedSharedTexture* imported = new ImportedSharedTexture();
|
||||
imported->pixel_format = shared_texture.pixel_format;
|
||||
imported->coded_size = shared_texture.coded_size;
|
||||
|
||||
Reference in New Issue
Block a user