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