| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 *called_sync_token = release_sync_token; | 287 *called_sync_token = release_sync_token; |
| 288 } | 288 } |
| 289 | 289 |
| 290 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is | 290 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is |
| 291 // destroyed with the default release sync point. | 291 // destroyed with the default release sync point. |
| 292 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { | 292 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { |
| 293 gpu::SyncToken called_sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, | 293 gpu::SyncToken called_sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, |
| 294 gpu::CommandBufferId::FromUnsafeValue(1), 1); | 294 gpu::CommandBufferId::FromUnsafeValue(1), 1); |
| 295 | 295 |
| 296 { | 296 { |
| 297 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( | 297 gpu::MailboxHolder holders[media::VideoFrame::kMaxPlanes] = { |
| 298 PIXEL_FORMAT_ARGB, | 298 gpu::MailboxHolder(gpu::Mailbox::Generate(), gpu::SyncToken(), 5)}; |
| 299 gpu::MailboxHolder(gpu::Mailbox::Generate(), gpu::SyncToken(), 5), | 299 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTextures( |
| 300 PIXEL_FORMAT_ARGB, holders, |
| 300 base::Bind(&TextureCallback, &called_sync_token), | 301 base::Bind(&TextureCallback, &called_sync_token), |
| 301 gfx::Size(10, 10), // coded_size | 302 gfx::Size(10, 10), // coded_size |
| 302 gfx::Rect(10, 10), // visible_rect | 303 gfx::Rect(10, 10), // visible_rect |
| 303 gfx::Size(10, 10), // natural_size | 304 gfx::Size(10, 10), // natural_size |
| 304 base::TimeDelta()); // timestamp | 305 base::TimeDelta()); // timestamp |
| 305 EXPECT_EQ(PIXEL_FORMAT_ARGB, frame->format()); | 306 EXPECT_EQ(PIXEL_FORMAT_ARGB, frame->format()); |
| 306 EXPECT_EQ(VideoFrame::STORAGE_OPAQUE, frame->storage_type()); | 307 EXPECT_EQ(VideoFrame::STORAGE_OPAQUE, frame->storage_type()); |
| 307 EXPECT_TRUE(frame->HasTextures()); | 308 EXPECT_TRUE(frame->HasTextures()); |
| 308 } | 309 } |
| 309 // Nobody set a sync point to |frame|, so |frame| set |called_sync_token| | 310 // Nobody set a sync point to |frame|, so |frame| set |called_sync_token| |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 } | 346 } |
| 346 | 347 |
| 347 gpu::SyncToken sync_token(kNamespace, 0, kCommandBufferId, 7); | 348 gpu::SyncToken sync_token(kNamespace, 0, kCommandBufferId, 7); |
| 348 sync_token.SetVerifyFlush(); | 349 sync_token.SetVerifyFlush(); |
| 349 uint32_t target = 9; | 350 uint32_t target = 9; |
| 350 gpu::SyncToken release_sync_token(kNamespace, 0, kCommandBufferId, 111); | 351 gpu::SyncToken release_sync_token(kNamespace, 0, kCommandBufferId, 111); |
| 351 release_sync_token.SetVerifyFlush(); | 352 release_sync_token.SetVerifyFlush(); |
| 352 | 353 |
| 353 gpu::SyncToken called_sync_token; | 354 gpu::SyncToken called_sync_token; |
| 354 { | 355 { |
| 355 scoped_refptr<VideoFrame> frame = VideoFrame::WrapYUV420NativeTextures( | 356 gpu::MailboxHolder holders[media::VideoFrame::kMaxPlanes] = { |
| 356 gpu::MailboxHolder(mailbox[VideoFrame::kYPlane], sync_token, target), | 357 gpu::MailboxHolder(mailbox[VideoFrame::kYPlane], sync_token, target), |
| 357 gpu::MailboxHolder(mailbox[VideoFrame::kUPlane], sync_token, target), | 358 gpu::MailboxHolder(mailbox[VideoFrame::kUPlane], sync_token, target), |
| 358 gpu::MailboxHolder(mailbox[VideoFrame::kVPlane], sync_token, target), | 359 gpu::MailboxHolder(mailbox[VideoFrame::kVPlane], sync_token, target), |
| 360 }; |
| 361 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTextures( |
| 362 PIXEL_FORMAT_I420, holders, |
| 359 base::Bind(&TextureCallback, &called_sync_token), | 363 base::Bind(&TextureCallback, &called_sync_token), |
| 360 gfx::Size(10, 10), // coded_size | 364 gfx::Size(10, 10), // coded_size |
| 361 gfx::Rect(10, 10), // visible_rect | 365 gfx::Rect(10, 10), // visible_rect |
| 362 gfx::Size(10, 10), // natural_size | 366 gfx::Size(10, 10), // natural_size |
| 363 base::TimeDelta()); // timestamp | 367 base::TimeDelta()); // timestamp |
| 364 | 368 |
| 365 EXPECT_EQ(VideoFrame::STORAGE_OPAQUE, frame->storage_type()); | 369 EXPECT_EQ(VideoFrame::STORAGE_OPAQUE, frame->storage_type()); |
| 366 EXPECT_EQ(PIXEL_FORMAT_I420, frame->format()); | 370 EXPECT_EQ(PIXEL_FORMAT_I420, frame->format()); |
| 367 EXPECT_EQ(3u, VideoFrame::NumPlanes(frame->format())); | 371 EXPECT_EQ(3u, VideoFrame::NumPlanes(frame->format())); |
| 368 EXPECT_TRUE(frame->HasTextures()); | 372 EXPECT_TRUE(frame->HasTextures()); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 509 |
| 506 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) { | 510 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) { |
| 507 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i); | 511 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i); |
| 508 int value = -1; | 512 int value = -1; |
| 509 EXPECT_TRUE(result.GetInteger(key, &value)); | 513 EXPECT_TRUE(result.GetInteger(key, &value)); |
| 510 EXPECT_EQ(i, value); | 514 EXPECT_EQ(i, value); |
| 511 } | 515 } |
| 512 } | 516 } |
| 513 | 517 |
| 514 } // namespace media | 518 } // namespace media |
| OLD | NEW |