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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is | 248 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is |
249 // destroyed with the default release sync point. | 249 // destroyed with the default release sync point. |
250 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { | 250 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { |
251 uint32 called_sync_point = 1; | 251 uint32 called_sync_point = 1; |
252 | 252 |
253 { | 253 { |
254 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( | 254 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( |
255 make_scoped_ptr( | 255 make_scoped_ptr( |
256 new gpu::MailboxHolder(gpu::Mailbox(), 5, 0 /* sync_point */)), | 256 new gpu::MailboxHolder(gpu::Mailbox(), 5, 0 /* sync_point */)), |
257 base::Bind(&TextureCallback, &called_sync_point), | 257 base::Bind(&TextureCallback, &called_sync_point), |
258 gfx::Size(10, 10), // coded_size | 258 gfx::Size(10, 10), // coded_size |
259 gfx::Rect(10, 10), // visible_rect | 259 gfx::Rect(10, 10), // visible_rect |
260 gfx::Size(10, 10), // natural_size | 260 gfx::Size(10, 10), // natural_size |
261 base::TimeDelta(), // timestamp | 261 base::TimeDelta(), // timestamp |
262 VideoFrame::ReadPixelsCB(), // read_pixels_cb | 262 VideoFrame::ReadPixelsCB()); // read_pixels_cb |
263 false); // allow_overlay | |
264 } | 263 } |
265 // Nobody set a sync point to |frame|, so |frame| set |called_sync_point| to 0 | 264 // Nobody set a sync point to |frame|, so |frame| set |called_sync_point| to 0 |
266 // as default value. | 265 // as default value. |
267 EXPECT_EQ(0u, called_sync_point); | 266 EXPECT_EQ(0u, called_sync_point); |
268 } | 267 } |
269 | 268 |
270 namespace { | 269 namespace { |
271 | 270 |
272 class SyncPointClientImpl : public VideoFrame::SyncPointClient { | 271 class SyncPointClientImpl : public VideoFrame::SyncPointClient { |
273 public: | 272 public: |
(...skipping 16 matching lines...) Expand all Loading... |
290 mailbox.name[0] = 50; | 289 mailbox.name[0] = 50; |
291 uint32 sync_point = 7; | 290 uint32 sync_point = 7; |
292 uint32 target = 9; | 291 uint32 target = 9; |
293 uint32 release_sync_point = 111; | 292 uint32 release_sync_point = 111; |
294 uint32 called_sync_point = 0; | 293 uint32 called_sync_point = 0; |
295 | 294 |
296 { | 295 { |
297 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( | 296 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( |
298 make_scoped_ptr(new gpu::MailboxHolder(mailbox, target, sync_point)), | 297 make_scoped_ptr(new gpu::MailboxHolder(mailbox, target, sync_point)), |
299 base::Bind(&TextureCallback, &called_sync_point), | 298 base::Bind(&TextureCallback, &called_sync_point), |
300 gfx::Size(10, 10), // coded_size | 299 gfx::Size(10, 10), // coded_size |
301 gfx::Rect(10, 10), // visible_rect | 300 gfx::Rect(10, 10), // visible_rect |
302 gfx::Size(10, 10), // natural_size | 301 gfx::Size(10, 10), // natural_size |
303 base::TimeDelta(), // timestamp | 302 base::TimeDelta(), // timestamp |
304 VideoFrame::ReadPixelsCB(), // read_pixels_cb | 303 VideoFrame::ReadPixelsCB()); // read_pixels_cb |
305 false); // allow_overlay | |
306 | 304 |
307 const gpu::MailboxHolder* mailbox_holder = frame->mailbox_holder(); | 305 const gpu::MailboxHolder* mailbox_holder = frame->mailbox_holder(); |
308 | 306 |
309 EXPECT_EQ(mailbox.name[0], mailbox_holder->mailbox.name[0]); | 307 EXPECT_EQ(mailbox.name[0], mailbox_holder->mailbox.name[0]); |
310 EXPECT_EQ(target, mailbox_holder->texture_target); | 308 EXPECT_EQ(target, mailbox_holder->texture_target); |
311 EXPECT_EQ(sync_point, mailbox_holder->sync_point); | 309 EXPECT_EQ(sync_point, mailbox_holder->sync_point); |
312 | 310 |
313 SyncPointClientImpl client(release_sync_point); | 311 SyncPointClientImpl client(release_sync_point); |
314 frame->UpdateReleaseSyncPoint(&client); | 312 frame->UpdateReleaseSyncPoint(&client); |
315 EXPECT_EQ(sync_point, mailbox_holder->sync_point); | 313 EXPECT_EQ(sync_point, mailbox_holder->sync_point); |
316 } | 314 } |
317 EXPECT_EQ(release_sync_point, called_sync_point); | 315 EXPECT_EQ(release_sync_point, called_sync_point); |
318 } | 316 } |
319 | 317 |
320 TEST(VideoFrame, ZeroInitialized) { | 318 TEST(VideoFrame, ZeroInitialized) { |
321 const int kWidth = 64; | 319 const int kWidth = 64; |
322 const int kHeight = 48; | 320 const int kHeight = 48; |
323 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); | 321 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); |
324 | 322 |
325 gfx::Size size(kWidth, kHeight); | 323 gfx::Size size(kWidth, kHeight); |
326 scoped_refptr<media::VideoFrame> frame = VideoFrame::CreateFrame( | 324 scoped_refptr<media::VideoFrame> frame = VideoFrame::CreateFrame( |
327 media::VideoFrame::YV12, size, gfx::Rect(size), size, kTimestamp); | 325 media::VideoFrame::YV12, size, gfx::Rect(size), size, kTimestamp); |
328 | 326 |
329 for (size_t i = 0; i < VideoFrame::NumPlanes(frame->format()); ++i) | 327 for (size_t i = 0; i < VideoFrame::NumPlanes(frame->format()); ++i) |
330 EXPECT_EQ(0, frame->data(i)[0]); | 328 EXPECT_EQ(0, frame->data(i)[0]); |
331 } | 329 } |
332 | 330 |
333 } // namespace media | 331 } // namespace media |
OLD | NEW |