OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/base/video_frame.h" | 5 #include "media/base/video_frame.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/memory/aligned_memory.h" | 10 #include "base/memory/aligned_memory.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 TEST(VideoFrame, CheckFrameExtents) { | 204 TEST(VideoFrame, CheckFrameExtents) { |
205 // Each call consists of a VideoFrame::Format, # of planes, bytes per pixel, | 205 // Each call consists of a VideoFrame::Format, # of planes, bytes per pixel, |
206 // and the expected hash of all planes if filled with kFillByte (defined in | 206 // and the expected hash of all planes if filled with kFillByte (defined in |
207 // ExpectFrameExtents). | 207 // ExpectFrameExtents). |
208 ExpectFrameExtents( | 208 ExpectFrameExtents( |
209 VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1"); | 209 VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1"); |
210 ExpectFrameExtents( | 210 ExpectFrameExtents( |
211 VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461"); | 211 VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461"); |
212 } | 212 } |
213 | 213 |
214 static void TextureCallback(uint32* called_sync_point, uint32 sync_point) { | 214 static void TextureCallback(uint32* called_sync_point, |
215 *called_sync_point = sync_point; | 215 scoped_ptr<gpu::MailboxHolder> mailbox_holder) { |
| 216 *called_sync_point = mailbox_holder->sync_point; |
216 } | 217 } |
217 | 218 |
218 // Verify the TextureNoLongerNeededCallback is called when VideoFrame is | 219 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is |
219 // destroyed with the original sync point. | 220 // destroyed with the original sync point. |
220 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { | 221 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { |
221 uint32 sync_point = 7; | 222 uint32 sync_point = 7; |
222 uint32 called_sync_point = 0; | 223 uint32 called_sync_point = 0; |
223 | 224 |
224 { | 225 { |
225 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( | 226 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( |
226 make_scoped_ptr(new VideoFrame::MailboxHolder( | 227 make_scoped_ptr(new gpu::MailboxHolder(gpu::Mailbox(), 5, sync_point)), |
227 gpu::Mailbox(), | 228 base::Bind(&TextureCallback, &called_sync_point), |
228 sync_point, | 229 gfx::Size(10, 10), // coded_size |
229 base::Bind(&TextureCallback, &called_sync_point))), | 230 gfx::Rect(10, 10), // visible_rect |
230 5, // texture_target | 231 gfx::Size(10, 10), // natural_size |
231 gfx::Size(10, 10), // coded_size | 232 base::TimeDelta(), // timestamp |
232 gfx::Rect(10, 10), // visible_rect | 233 base::Callback<void(const SkBitmap&)>()); // read_pixels_cb |
233 gfx::Size(10, 10), // natural_size | |
234 base::TimeDelta(), // timestamp | |
235 base::Callback<void(const SkBitmap&)>(), // read_pixels_cb | |
236 base::Closure()); // no_longer_needed_cb | |
237 | 234 |
238 EXPECT_EQ(0u, called_sync_point); | 235 EXPECT_EQ(0u, called_sync_point); |
239 } | 236 } |
240 EXPECT_EQ(sync_point, called_sync_point); | 237 EXPECT_EQ(sync_point, called_sync_point); |
241 } | 238 } |
242 | 239 |
243 // Verify the TextureNoLongerNeededCallback is called when VideoFrame is | 240 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is |
244 // destroyed with the new sync point, when the mailbox is accessed by a caller. | 241 // destroyed with the new sync point, when the mailbox is accessed by a caller. |
245 TEST(VideoFrame, TextureNoLongerNeededCallbackAfterTakingAndReleasingMailbox) { | 242 TEST(VideoFrame, TextureNoLongerNeededCallbackAfterTakingAndReleasingMailbox) { |
246 uint32 called_sync_point = 0; | 243 uint32 called_sync_point = 0; |
247 | 244 |
248 gpu::Mailbox mailbox; | 245 gpu::Mailbox mailbox; |
249 mailbox.name[0] = 50; | 246 mailbox.name[0] = 50; |
250 uint32 sync_point = 7; | 247 uint32 sync_point = 7; |
251 uint32 target = 9; | 248 uint32 target = 9; |
252 | 249 |
253 { | 250 { |
254 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( | 251 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( |
255 make_scoped_ptr(new VideoFrame::MailboxHolder( | 252 make_scoped_ptr(new gpu::MailboxHolder(mailbox, target, sync_point)), |
256 mailbox, | 253 base::Bind(&TextureCallback, &called_sync_point), |
257 sync_point, | 254 gfx::Size(10, 10), // coded_size |
258 base::Bind(&TextureCallback, &called_sync_point))), | 255 gfx::Rect(10, 10), // visible_rect |
259 target, | 256 gfx::Size(10, 10), // natural_size |
260 gfx::Size(10, 10), // coded_size | 257 base::TimeDelta(), // timestamp |
261 gfx::Rect(10, 10), // visible_rect | 258 base::Callback<void(const SkBitmap&)>()); // read_pixels_cb |
262 gfx::Size(10, 10), // natural_size | |
263 base::TimeDelta(), // timestamp | |
264 base::Callback<void(const SkBitmap&)>(), // read_pixels_cb | |
265 base::Closure()); // no_longer_needed_cb | |
266 | 259 |
267 VideoFrame::MailboxHolder* mailbox_holder = frame->texture_mailbox(); | 260 gpu::MailboxHolder* mailbox_holder = frame->mailbox_holder(); |
268 | 261 |
269 EXPECT_EQ(mailbox.name[0], mailbox_holder->mailbox().name[0]); | 262 EXPECT_EQ(mailbox.name[0], mailbox_holder->mailbox.name[0]); |
270 EXPECT_EQ(sync_point, mailbox_holder->sync_point()); | 263 EXPECT_EQ(target, mailbox_holder->texture_target); |
271 EXPECT_EQ(target, frame->texture_target()); | 264 EXPECT_EQ(sync_point, mailbox_holder->sync_point); |
272 | 265 |
273 // Finish using the mailbox_holder and drop our reference. | 266 // Finish using the mailbox_holder and drop our reference. |
274 sync_point = 10; | 267 sync_point = 10; |
275 mailbox_holder->Resync(sync_point); | 268 mailbox_holder->sync_point = sync_point; |
276 } | 269 } |
277 EXPECT_EQ(sync_point, called_sync_point); | 270 EXPECT_EQ(sync_point, called_sync_point); |
278 } | 271 } |
279 | 272 |
280 } // namespace media | 273 } // namespace media |
OLD | NEW |