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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 10 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 11 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
11 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
12 #include "ui/gfx/buffer_format_util.h" | |
13 #include "ui/gfx/gpu_memory_buffer.h" | |
14 | 13 |
15 namespace content { | 14 namespace content { |
16 | 15 |
17 const int VideoCaptureBufferPool::kInvalidId = -1; | 16 const int VideoCaptureBufferPool::kInvalidId = -1; |
18 | 17 |
19 // A simple holder of a memory-backed buffer and accesors to it. | 18 // A simple holder of a memory-backed buffer and accesors to it. |
20 class SimpleBufferHandle final : public VideoCaptureBufferPool::BufferHandle { | 19 class SimpleBufferHandle final : public VideoCaptureBufferPool::BufferHandle { |
21 public: | 20 public: |
22 SimpleBufferHandle(void* data, size_t size, base::SharedMemoryHandle handle) | 21 SimpleBufferHandle(void* data, size_t size, base::SharedMemoryHandle handle) |
23 : data_(data), | 22 : data_(data), |
(...skipping 27 matching lines...) Expand all Loading... |
51 }; | 50 }; |
52 | 51 |
53 // A holder of a GpuMemoryBuffer-backed buffer, Map()ed on ctor and Unmap()ed on | 52 // A holder of a GpuMemoryBuffer-backed buffer, Map()ed on ctor and Unmap()ed on |
54 // dtor. Holds a weak reference to its GpuMemoryBuffer. | 53 // dtor. Holds a weak reference to its GpuMemoryBuffer. |
55 // TODO(mcasas) Map()ed on ctor, or on first use? | 54 // TODO(mcasas) Map()ed on ctor, or on first use? |
56 class GpuMemoryBufferBufferHandle | 55 class GpuMemoryBufferBufferHandle |
57 final : public VideoCaptureBufferPool::BufferHandle { | 56 final : public VideoCaptureBufferPool::BufferHandle { |
58 public: | 57 public: |
59 GpuMemoryBufferBufferHandle(gfx::GpuMemoryBuffer* gmb, size_t size) | 58 GpuMemoryBufferBufferHandle(gfx::GpuMemoryBuffer* gmb, size_t size) |
60 : gmb_(gmb), | 59 : gmb_(gmb), |
61 data_(new void*[gfx::NumberOfPlanesForBufferFormat(gmb_->GetFormat())]), | 60 data_(new void* [GpuMemoryBufferImpl:: |
| 61 NumberOfPlanesForGpuMemoryBufferFormat( |
| 62 gmb_->GetFormat())]), |
62 size_(size) { | 63 size_(size) { |
63 DCHECK(gmb && !gmb_->IsMapped()); | 64 DCHECK(gmb && !gmb_->IsMapped()); |
64 gmb_->Map(data_.get()); | 65 gmb_->Map(data_.get()); |
65 } | 66 } |
66 ~GpuMemoryBufferBufferHandle() override { gmb_->Unmap(); } | 67 ~GpuMemoryBufferBufferHandle() override { gmb_->Unmap(); } |
67 | 68 |
68 size_t size() const override { return size_; } | 69 size_t size() const override { return size_; } |
69 void* data() override { return data_[0]; } | 70 void* data() override { return data_[0]; } |
70 ClientBuffer AsClientBuffer() override { return gmb_->AsClientBuffer(); } | 71 ClientBuffer AsClientBuffer() override { return gmb_->AsClientBuffer(); } |
71 #if defined(OS_POSIX) | 72 #if defined(OS_POSIX) |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 return buffer_id; | 369 return buffer_id; |
369 } | 370 } |
370 | 371 |
371 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker( | 372 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker( |
372 int buffer_id) { | 373 int buffer_id) { |
373 TrackerMap::const_iterator it = trackers_.find(buffer_id); | 374 TrackerMap::const_iterator it = trackers_.find(buffer_id); |
374 return (it == trackers_.end()) ? NULL : it->second; | 375 return (it == trackers_.end()) ? NULL : it->second; |
375 } | 376 } |
376 | 377 |
377 } // namespace content | 378 } // namespace content |
OLD | NEW |