Index: media/base/video_frame_unittest.cc |
diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc |
index 967d37653c49ef469f1fd841fd45c3547635447d..f6b61a5cd64924715659d7749bab2f4e56b3e65b 100644 |
--- a/media/base/video_frame_unittest.cc |
+++ b/media/base/video_frame_unittest.cc |
@@ -248,51 +248,59 @@ TEST(VideoFrame, CheckFrameExtents) { |
VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461"); |
} |
-static void TextureCallback(uint32* called_sync_point, |
- scoped_ptr<gpu::MailboxHolder> mailbox_holder) { |
- *called_sync_point = mailbox_holder->sync_point; |
+static void TextureCallback(std::vector<uint32>* called_sync_point, |
+ const std::vector<uint32>& release_sync_points) { |
+ std::vector<uint32> sync_points(release_sync_points); |
+ called_sync_point->swap(sync_points); |
Ami GONE FROM CHROMIUM
2014/04/11 20:55:17
nit: simpler as:
called_sync_point->clear();
calle
dshwang
2014/04/22 19:16:51
Done.
|
} |
// Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is |
-// destroyed with the original sync point. |
+// destroyed with the default release sync points. |
TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { |
- uint32 sync_point = 7; |
- uint32 called_sync_point = 0; |
+ std::vector<uint32> called_sync_points; |
+ called_sync_points.push_back(1); |
{ |
scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( |
- make_scoped_ptr(new gpu::MailboxHolder(gpu::Mailbox(), 5, sync_point)), |
- base::Bind(&TextureCallback, &called_sync_point), |
- gfx::Size(10, 10), // coded_size |
- gfx::Rect(10, 10), // visible_rect |
- gfx::Size(10, 10), // natural_size |
- base::TimeDelta(), // timestamp |
- base::Callback<void(const SkBitmap&)>()); // read_pixels_cb |
- |
- EXPECT_EQ(0u, called_sync_point); |
+ make_scoped_ptr( |
+ new gpu::MailboxHolder(gpu::Mailbox(), 5, 0 /* sync_point */)), |
+ base::Bind(&TextureCallback, &called_sync_points), |
+ gfx::Size(10, 10), // coded_size |
+ gfx::Rect(10, 10), // visible_rect |
+ gfx::Size(10, 10), // natural_size |
+ base::TimeDelta(), // timestamp |
+ VideoFrame::ReadPixelsCB()); // read_pixels_cb |
+ |
+ EXPECT_EQ(1u, called_sync_points.size()); |
} |
- EXPECT_EQ(sync_point, called_sync_point); |
+ EXPECT_TRUE(called_sync_points.empty()); |
} |
// Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is |
-// destroyed with the new sync point, when the mailbox is accessed by a caller. |
+// destroyed with the release sync points, which was updated by clients. |
+// (i.e. the compositor, webgl). |
TEST(VideoFrame, TextureNoLongerNeededCallbackAfterTakingAndReleasingMailbox) { |
- uint32 called_sync_point = 0; |
+ std::vector<uint32> called_sync_points; |
gpu::Mailbox mailbox; |
mailbox.name[0] = 50; |
uint32 sync_point = 7; |
uint32 target = 9; |
+ std::vector<uint32> release_sync_points; |
+ release_sync_points.push_back(1); |
+ release_sync_points.push_back(2); |
+ release_sync_points.push_back(3); |
{ |
scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( |
make_scoped_ptr(new gpu::MailboxHolder(mailbox, target, sync_point)), |
- base::Bind(&TextureCallback, &called_sync_point), |
- gfx::Size(10, 10), // coded_size |
- gfx::Rect(10, 10), // visible_rect |
- gfx::Size(10, 10), // natural_size |
- base::TimeDelta(), // timestamp |
- base::Callback<void(const SkBitmap&)>()); // read_pixels_cb |
+ base::Bind(&TextureCallback, &called_sync_points), |
+ gfx::Size(10, 10), // coded_size |
+ gfx::Rect(10, 10), // visible_rect |
+ gfx::Size(10, 10), // natural_size |
+ base::TimeDelta(), // timestamp |
+ VideoFrame::ReadPixelsCB()); // read_pixels_cb |
+ EXPECT_TRUE(called_sync_points.empty()); |
gpu::MailboxHolder* mailbox_holder = frame->mailbox_holder(); |
@@ -300,11 +308,12 @@ TEST(VideoFrame, TextureNoLongerNeededCallbackAfterTakingAndReleasingMailbox) { |
EXPECT_EQ(target, mailbox_holder->texture_target); |
EXPECT_EQ(sync_point, mailbox_holder->sync_point); |
- // Finish using the mailbox_holder and drop our reference. |
- sync_point = 10; |
- mailbox_holder->sync_point = sync_point; |
+ frame->AppendReleaseSyncPoint(release_sync_points[0]); |
+ frame->AppendReleaseSyncPoint(release_sync_points[1]); |
+ frame->AppendReleaseSyncPoint(release_sync_points[2]); |
+ EXPECT_EQ(sync_point, mailbox_holder->sync_point); |
} |
- EXPECT_EQ(sync_point, called_sync_point); |
+ EXPECT_EQ(release_sync_points, called_sync_points); |
} |
} // namespace media |