| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/renderer_host/media/video_capture_buffer_pool.h" | 5 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 set_storage_type(storage_type); | 35 set_storage_type(storage_type); |
| 36 mapped_size_ = | 36 mapped_size_ = |
| 37 media::VideoCaptureFormat(dimensions, 0.0f, format, storage_type) | 37 media::VideoCaptureFormat(dimensions, 0.0f, format, storage_type) |
| 38 .ImageAllocationSize(); | 38 .ImageAllocationSize(); |
| 39 if (!mapped_size_) | 39 if (!mapped_size_) |
| 40 return true; | 40 return true; |
| 41 return shared_memory_.CreateAndMapAnonymous(mapped_size_); | 41 return shared_memory_.CreateAndMapAnonymous(mapped_size_); |
| 42 } | 42 } |
| 43 | 43 |
| 44 std::unique_ptr<BufferHandle> GetBufferHandle() override { | 44 std::unique_ptr<BufferHandle> GetBufferHandle() override { |
| 45 return base::WrapUnique(new SharedMemBufferHandle(this)); | 45 return base::MakeUnique<SharedMemBufferHandle>(this); |
| 46 } | 46 } |
| 47 bool ShareToProcess(base::ProcessHandle process_handle, | 47 bool ShareToProcess(base::ProcessHandle process_handle, |
| 48 base::SharedMemoryHandle* new_handle) override { | 48 base::SharedMemoryHandle* new_handle) override { |
| 49 return shared_memory_.ShareToProcess(process_handle, new_handle); | 49 return shared_memory_.ShareToProcess(process_handle, new_handle); |
| 50 } | 50 } |
| 51 bool ShareToProcess2(int plane, | 51 bool ShareToProcess2(int plane, |
| 52 base::ProcessHandle process_handle, | 52 base::ProcessHandle process_handle, |
| 53 gfx::GpuMemoryBufferHandle* new_handle) override { | 53 gfx::GpuMemoryBufferHandle* new_handle) override { |
| 54 NOTREACHED(); | 54 NOTREACHED(); |
| 55 return false; | 55 return false; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 DLOG_IF(ERROR, !gpu_memory_buffers_[i]) << "Allocating GpuMemoryBuffer"; | 137 DLOG_IF(ERROR, !gpu_memory_buffers_[i]) << "Allocating GpuMemoryBuffer"; |
| 138 if (!gpu_memory_buffers_[i] || !gpu_memory_buffers_[i]->Map()) | 138 if (!gpu_memory_buffers_[i] || !gpu_memory_buffers_[i]->Map()) |
| 139 return false; | 139 return false; |
| 140 } | 140 } |
| 141 return true; | 141 return true; |
| 142 } | 142 } |
| 143 | 143 |
| 144 std::unique_ptr<BufferHandle> GetBufferHandle() override { | 144 std::unique_ptr<BufferHandle> GetBufferHandle() override { |
| 145 DCHECK_EQ(gpu_memory_buffers_.size(), | 145 DCHECK_EQ(gpu_memory_buffers_.size(), |
| 146 media::VideoFrame::NumPlanes(pixel_format())); | 146 media::VideoFrame::NumPlanes(pixel_format())); |
| 147 return base::WrapUnique(new GpuMemoryBufferBufferHandle(this)); | 147 return base::MakeUnique<GpuMemoryBufferBufferHandle>(this); |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool ShareToProcess(base::ProcessHandle process_handle, | 150 bool ShareToProcess(base::ProcessHandle process_handle, |
| 151 base::SharedMemoryHandle* new_handle) override { | 151 base::SharedMemoryHandle* new_handle) override { |
| 152 NOTREACHED(); | 152 NOTREACHED(); |
| 153 return false; | 153 return false; |
| 154 } | 154 } |
| 155 | 155 |
| 156 bool ShareToProcess2(int plane, | 156 bool ShareToProcess2(int plane, |
| 157 base::ProcessHandle process_handle, | 157 base::ProcessHandle process_handle, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 // Owned references to GpuMemoryBuffers. | 225 // Owned references to GpuMemoryBuffers. |
| 226 std::vector<std::unique_ptr<gfx::GpuMemoryBuffer>> gpu_memory_buffers_; | 226 std::vector<std::unique_ptr<gfx::GpuMemoryBuffer>> gpu_memory_buffers_; |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 // static | 229 // static |
| 230 std::unique_ptr<VideoCaptureBufferPool::Tracker> | 230 std::unique_ptr<VideoCaptureBufferPool::Tracker> |
| 231 VideoCaptureBufferPool::Tracker::CreateTracker( | 231 VideoCaptureBufferPool::Tracker::CreateTracker( |
| 232 media::VideoPixelStorage storage) { | 232 media::VideoPixelStorage storage) { |
| 233 switch (storage) { | 233 switch (storage) { |
| 234 case media::PIXEL_STORAGE_GPUMEMORYBUFFER: | 234 case media::PIXEL_STORAGE_GPUMEMORYBUFFER: |
| 235 return base::WrapUnique(new GpuMemoryBufferTracker()); | 235 return base::MakeUnique<GpuMemoryBufferTracker>(); |
| 236 case media::PIXEL_STORAGE_CPU: | 236 case media::PIXEL_STORAGE_CPU: |
| 237 return base::WrapUnique(new SharedMemTracker()); | 237 return base::MakeUnique<SharedMemTracker>(); |
| 238 } | 238 } |
| 239 NOTREACHED(); | 239 NOTREACHED(); |
| 240 return std::unique_ptr<VideoCaptureBufferPool::Tracker>(); | 240 return std::unique_ptr<VideoCaptureBufferPool::Tracker>(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 VideoCaptureBufferPool::Tracker::~Tracker() {} | 243 VideoCaptureBufferPool::Tracker::~Tracker() {} |
| 244 | 244 |
| 245 VideoCaptureBufferPool::VideoCaptureBufferPool(int count) | 245 VideoCaptureBufferPool::VideoCaptureBufferPool(int count) |
| 246 : count_(count), | 246 : count_(count), |
| 247 next_buffer_id_(0), | 247 next_buffer_id_(0), |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 return buffer_id; | 474 return buffer_id; |
| 475 } | 475 } |
| 476 | 476 |
| 477 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker( | 477 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker( |
| 478 int buffer_id) { | 478 int buffer_id) { |
| 479 TrackerMap::const_iterator it = trackers_.find(buffer_id); | 479 TrackerMap::const_iterator it = trackers_.find(buffer_id); |
| 480 return (it == trackers_.end()) ? NULL : it->second; | 480 return (it == trackers_.end()) ? NULL : it->second; |
| 481 } | 481 } |
| 482 | 482 |
| 483 } // namespace content | 483 } // namespace content |
| OLD | NEW |