| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // the number of free buffers will be capped at |kMaxExpectedFreeBuffers|. | 78 // the number of free buffers will be capped at |kMaxExpectedFreeBuffers|. |
| 79 for (int i = 0; i < 10; ++i) { | 79 for (int i = 0; i < 10; ++i) { |
| 80 buffer_size += kBufferSizeIncrease; | 80 buffer_size += kBufferSizeIncrease; |
| 81 cdm::Buffer* buffer = CreateCdmBuffer(buffer_size); | 81 cdm::Buffer* buffer = CreateCdmBuffer(buffer_size); |
| 82 buffer->Destroy(); | 82 buffer->Destroy(); |
| 83 EXPECT_LE(GetAvailableBufferCount(), kMaxExpectedFreeBuffers); | 83 EXPECT_LE(GetAvailableBufferCount(), kMaxExpectedFreeBuffers); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 TEST_F(MojoCdmAllocatorTest, CreateCdmVideoFrame) { | 87 TEST_F(MojoCdmAllocatorTest, CreateCdmVideoFrame) { |
| 88 const int kHeight = 16; | 88 const int kWidth = 16; |
| 89 const int kWidth = 9; | 89 const int kHeight = 9; |
| 90 const VideoPixelFormat kFormat = PIXEL_FORMAT_I420; | 90 const VideoPixelFormat kFormat = PIXEL_FORMAT_I420; |
| 91 const gfx::Size kSize(kHeight, kWidth); | 91 const gfx::Size kSize(kWidth, kHeight); |
| 92 const size_t kBufferSize = VideoFrame::AllocationSize(kFormat, kSize); | 92 const size_t kBufferSize = VideoFrame::AllocationSize(kFormat, kSize); |
| 93 | 93 |
| 94 // Create a VideoFrameImpl and initialize it. | 94 // Create a VideoFrameImpl and initialize it. |
| 95 std::unique_ptr<VideoFrameImpl> video_frame = CreateCdmVideoFrame(); | 95 std::unique_ptr<VideoFrameImpl> video_frame = CreateCdmVideoFrame(); |
| 96 video_frame->SetFormat(cdm::kI420); | 96 video_frame->SetFormat(cdm::kI420); |
| 97 video_frame->SetSize(cdm::Size(kHeight, kWidth)); | 97 video_frame->SetSize(cdm::Size(kWidth, kHeight)); |
| 98 video_frame->SetStride(VideoFrameImpl::kYPlane, | 98 video_frame->SetStride(VideoFrameImpl::kYPlane, |
| 99 static_cast<uint32_t>(VideoFrame::RowBytes( | 99 static_cast<uint32_t>(VideoFrame::RowBytes( |
| 100 VideoFrame::kYPlane, kFormat, kWidth))); | 100 VideoFrame::kYPlane, kFormat, kWidth))); |
| 101 video_frame->SetStride(VideoFrameImpl::kUPlane, | 101 video_frame->SetStride(VideoFrameImpl::kUPlane, |
| 102 static_cast<uint32_t>(VideoFrame::RowBytes( | 102 static_cast<uint32_t>(VideoFrame::RowBytes( |
| 103 VideoFrame::kUPlane, kFormat, kWidth))); | 103 VideoFrame::kUPlane, kFormat, kWidth))); |
| 104 video_frame->SetStride(VideoFrameImpl::kVPlane, | 104 video_frame->SetStride(VideoFrameImpl::kVPlane, |
| 105 static_cast<uint32_t>(VideoFrame::RowBytes( | 105 static_cast<uint32_t>(VideoFrame::RowBytes( |
| 106 VideoFrame::kVPlane, kFormat, kWidth))); | 106 VideoFrame::kVPlane, kFormat, kWidth))); |
| 107 EXPECT_EQ(nullptr, video_frame->FrameBuffer()); | 107 EXPECT_EQ(nullptr, video_frame->FrameBuffer()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 122 // Check that the buffer is still in use. It will be freed when |frame| | 122 // Check that the buffer is still in use. It will be freed when |frame| |
| 123 // is destroyed. | 123 // is destroyed. |
| 124 EXPECT_EQ(0u, GetAvailableBufferCount()); | 124 EXPECT_EQ(0u, GetAvailableBufferCount()); |
| 125 frame = nullptr; | 125 frame = nullptr; |
| 126 | 126 |
| 127 // Check that the buffer is now in the free list. | 127 // Check that the buffer is now in the free list. |
| 128 EXPECT_EQ(1u, GetAvailableBufferCount()); | 128 EXPECT_EQ(1u, GetAvailableBufferCount()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace media | 131 } // namespace media |
| OLD | NEW |