Index: media/video/gpu_memory_buffer_video_frame_pool_unittest.cc |
diff --git a/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc b/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc |
index 67ece214ec13598a8f1db4d93400b23d1dbd8bae..df4f76116330937ed47489db1dda4bc7e42e0faf 100644 |
--- a/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc |
+++ b/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc |
@@ -122,6 +122,26 @@ class GpuMemoryBufferVideoFramePoolTest : public ::testing::Test { |
return video_frame; |
} |
+ static scoped_refptr<media::VideoFrame> CreateTestY16VideoFrame( |
+ int dimension) { |
+ const int kDimension = 10; |
+ static uint8_t data[kDimension * kDimension * 2] = {0}; |
+ |
+ DCHECK_LE(dimension, kDimension); |
+ gfx::Size size(dimension, dimension); |
+ |
+ scoped_refptr<VideoFrame> video_frame = |
+ media::VideoFrame::WrapExternalData(media::PIXEL_FORMAT_Y16, // format |
+ size, // coded_size |
+ gfx::Rect(size), // visible_rect |
+ size, // natural_size |
+ data, // data |
+ sizeof(data), // byte size |
+ base::TimeDelta()); // timestamp |
+ EXPECT_TRUE(video_frame); |
+ return video_frame; |
+ } |
+ |
protected: |
std::unique_ptr<MockGpuVideoAcceleratorFactories> mock_gpu_factories_; |
std::unique_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_; |
@@ -198,7 +218,8 @@ TEST_F(GpuMemoryBufferVideoFramePoolTest, ReuseFirstResource) { |
EXPECT_NE(frame->mailbox_holder(0).sync_token, sync_token); |
} |
-TEST_F(GpuMemoryBufferVideoFramePoolTest, DropResourceWhenSizeIsDifferent) { |
+TEST_F(GpuMemoryBufferVideoFramePoolTest, |
+ DropResourceWhenSizeOrFormatAreDifferent) { |
scoped_refptr<VideoFrame> frame; |
gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( |
CreateTestYUVVideoFrame(10), |
@@ -214,6 +235,16 @@ TEST_F(GpuMemoryBufferVideoFramePoolTest, DropResourceWhenSizeIsDifferent) { |
base::Bind(MaybeCreateHardwareFrameCallback, &frame)); |
RunUntilIdle(); |
EXPECT_EQ(6u, gles2_->gen_textures); |
+ |
+ frame = nullptr; |
+ RunUntilIdle(); |
+ mock_gpu_factories_->SetVideoFrameOutputFormat( |
+ media::GpuVideoAcceleratorFactories::OutputFormat::Y16); |
+ gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( |
+ CreateTestY16VideoFrame(4), |
+ base::Bind(MaybeCreateHardwareFrameCallback, &frame)); |
+ RunUntilIdle(); |
+ EXPECT_EQ(7u, gles2_->gen_textures); |
} |
TEST_F(GpuMemoryBufferVideoFramePoolTest, CreateOneHardwareUYUVFrame) { |
@@ -264,6 +295,22 @@ TEST_F(GpuMemoryBufferVideoFramePoolTest, CreateOneHardwareNV12Frame2) { |
media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED)); |
} |
+TEST_F(GpuMemoryBufferVideoFramePoolTest, CreateOneHardwareY16Frame) { |
+ scoped_refptr<VideoFrame> software_frame = CreateTestY16VideoFrame(10); |
+ scoped_refptr<VideoFrame> frame; |
+ mock_gpu_factories_->SetVideoFrameOutputFormat( |
+ media::GpuVideoAcceleratorFactories::OutputFormat::Y16); |
+ gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( |
+ software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); |
+ |
+ RunUntilIdle(); |
+ |
+ EXPECT_NE(software_frame.get(), frame.get()); |
+ EXPECT_EQ(1u, gles2_->gen_textures); |
+ EXPECT_TRUE(frame->metadata()->IsTrue( |
+ media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED)); |
+} |
+ |
// AllocateGpuMemoryBuffer can return null (e.g: when the GPU process is down). |
// This test checks that in that case we don't crash and still create the |
// textures. |