0

[//media] Correct usages of multiplanar test SharedImages

These SharedImages are created for usage in tests of
PaintCanvasVideoRenderer::Copy() and
PaintCanvasVideoRenderer::CopyVideoFrameTexturesToGLTexture(). In this
context they will be read by the raster interface for the former use
case and for 2-copy upload in the latter use case. On platforms other
than Android, they may also be read by GL for 1-copy upload in the
latter use case (1-copy upload is not supported on Android).

In the context of these unittests GPU rasterization is always used [1],
so I didn't bother plumbing through the raster context provider into
these creation functions to check that capability.

[1] https://source.chromium.org/chromium/chromium/src/+/main:media/renderers/paint_canvas_video_renderer_unittest.cc;l=1056-1057;drc=c0265133106c7647e90f9aaa4377d28190b1a6a9?q=PaintCanvasVideoRendererWithGLTest.P&ss=chromium

Bug: 336837285
Change-Id: If3746234851258e9d54adebdf27f3335eb7315db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5569590
Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1305665}
This commit is contained in:
Colin Blundell
2024-05-24 13:18:36 +00:00
committed by Chromium LUCI CQ
parent 61bd1ed5d1
commit 3c156736a3

@ -140,17 +140,25 @@ scoped_refptr<VideoFrame> CreateSharedImageI420Frame(
? viz::SinglePlaneFormat::kR_8
: viz::SinglePlaneFormat::kLUMINANCE_8;
auto* sii = context_provider->SharedImageInterface();
// These SharedImages will be read by the raster interface to create
// intermediate copies in copy to canvas and 2-copy upload to WebGL.
// In the context of the tests using these SharedImages, GPU rasterization is
// always used.
auto usages = gpu::SHARED_IMAGE_USAGE_RASTER_READ |
gpu::SHARED_IMAGE_USAGE_OOP_RASTERIZATION;
#if !BUILDFLAG(IS_ANDROID)
// These SharedImages may be read by the GLES2 interface for 1-copy upload to
// WebGL (not supported on Android).
usages |= gpu::SHARED_IMAGE_USAGE_GLES2_READ;
#endif
auto y_shared_image = sii->CreateSharedImage(
{plane_format, coded_size, gfx::ColorSpace(),
gpu::SHARED_IMAGE_USAGE_GLES2_READ, "I420Frame_Y"},
{plane_format, coded_size, gfx::ColorSpace(), usages, "I420Frame_Y"},
y_pixels);
auto u_shared_image = sii->CreateSharedImage(
{plane_format, uv_size, gfx::ColorSpace(),
gpu::SHARED_IMAGE_USAGE_GLES2_READ, "I420Frame_U"},
{plane_format, uv_size, gfx::ColorSpace(), usages, "I420Frame_U"},
u_pixels);
auto v_shared_image = sii->CreateSharedImage(
{plane_format, uv_size, gfx::ColorSpace(),
gpu::SHARED_IMAGE_USAGE_GLES2_READ, "I420Frame_V"},
{plane_format, uv_size, gfx::ColorSpace(), usages, "I420Frame_V"},
v_pixels);
return CreateSharedImageFrame(
@ -197,14 +205,25 @@ scoped_refptr<VideoFrame> CreateSharedImageNV12Frame(
DCHECK_EQ(uv_i, uv_pixels_size);
auto* sii = context_provider->SharedImageInterface();
auto y_shared_image = sii->CreateSharedImage(
{viz::SinglePlaneFormat::kR_8, coded_size, gfx::ColorSpace(),
gpu::SHARED_IMAGE_USAGE_GLES2_READ, "NV12Frame_Y"},
y_pixels);
auto uv_shared_image = sii->CreateSharedImage(
{viz::SinglePlaneFormat::kRG_88, uv_size, gfx::ColorSpace(),
gpu::SHARED_IMAGE_USAGE_GLES2_READ, "NV12Frame_UV"},
uv_pixels);
// These SharedImages will be read by the raster interface to create
// intermediate copies in copy to canvas and 2-copy upload to WebGL.
// In the context of the tests using these SharedImages, GPU rasterization is
// always used.
auto usages = gpu::SHARED_IMAGE_USAGE_RASTER_READ |
gpu::SHARED_IMAGE_USAGE_OOP_RASTERIZATION;
#if !BUILDFLAG(IS_ANDROID)
// These SharedImages may be read by the GLES2 interface for 1-copy upload to
// WebGL (not supported on Android).
usages |= gpu::SHARED_IMAGE_USAGE_GLES2_READ;
#endif
auto y_shared_image =
sii->CreateSharedImage({viz::SinglePlaneFormat::kR_8, coded_size,
gfx::ColorSpace(), usages, "NV12Frame_Y"},
y_pixels);
auto uv_shared_image =
sii->CreateSharedImage({viz::SinglePlaneFormat::kRG_88, uv_size,
gfx::ColorSpace(), usages, "NV12Frame_UV"},
uv_pixels);
return CreateSharedImageFrame(
std::move(context_provider), VideoPixelFormat::PIXEL_FORMAT_NV12,
{y_shared_image, uv_shared_image}, {}, GL_TEXTURE_2D, coded_size,