mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: import shared texture supports nv12. (#49040)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: reito <reito@chromium.org>
This commit is contained in:
@@ -125,6 +125,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();
|
||||
}
|
||||
@@ -565,6 +567,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;
|
||||
}
|
||||
@@ -727,6 +731,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