diff --git a/media/renderers/shared_image_video_frame_test_utils.cc b/media/renderers/shared_image_video_frame_test_utils.cc index 3d8fef48571c1..b6c6fc6c58abc 100644 --- a/media/renderers/shared_image_video_frame_test_utils.cc +++ b/media/renderers/shared_image_video_frame_test_utils.cc @@ -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,