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" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 public: | 63 public: |
64 SimpleBufferHandle(void* data, size_t size, base::SharedMemoryHandle handle) | 64 SimpleBufferHandle(void* data, size_t size, base::SharedMemoryHandle handle) |
65 : data_(data), size_(size), handle_(handle) {} | 65 : data_(data), size_(size), handle_(handle) {} |
66 ~SimpleBufferHandle() override {} | 66 ~SimpleBufferHandle() override {} |
67 | 67 |
68 size_t size() const override { return size_; } | 68 size_t size() const override { return size_; } |
69 void* data() override { return data_; } | 69 void* data() override { return data_; } |
70 ClientBuffer AsClientBuffer() override { return nullptr; } | 70 ClientBuffer AsClientBuffer() override { return nullptr; } |
71 #if defined(OS_POSIX) | 71 #if defined(OS_POSIX) |
72 base::FileDescriptor AsPlatformFile() override { | 72 base::FileDescriptor AsPlatformFile() override { |
73 #if defined(OS_MACOSX) | |
74 return handle_.GetFileDescriptor(); | |
75 #else | |
76 return handle_; | 73 return handle_; |
77 #endif // defined(OS_MACOSX) | |
78 } | 74 } |
79 #endif | 75 #endif |
80 | 76 |
81 private: | 77 private: |
82 void* const data_; | 78 void* const data_; |
83 const size_t size_; | 79 const size_t size_; |
84 const base::SharedMemoryHandle handle_; | 80 const base::SharedMemoryHandle handle_; |
85 }; | 81 }; |
86 | 82 |
87 // A holder of a GpuMemoryBuffer-backed buffer, Map()ed on ctor and Unmap()ed on | 83 // A holder of a GpuMemoryBuffer-backed buffer, Map()ed on ctor and Unmap()ed on |
(...skipping 11 matching lines...) Expand all Loading... |
99 DCHECK(gmb && !gmb_->IsMapped()); | 95 DCHECK(gmb && !gmb_->IsMapped()); |
100 gmb_->Map(data_.get()); | 96 gmb_->Map(data_.get()); |
101 } | 97 } |
102 ~GpuMemoryBufferBufferHandle() override { gmb_->Unmap(); } | 98 ~GpuMemoryBufferBufferHandle() override { gmb_->Unmap(); } |
103 | 99 |
104 size_t size() const override { return size_; } | 100 size_t size() const override { return size_; } |
105 void* data() override { return data_[0]; } | 101 void* data() override { return data_[0]; } |
106 ClientBuffer AsClientBuffer() override { return gmb_->AsClientBuffer(); } | 102 ClientBuffer AsClientBuffer() override { return gmb_->AsClientBuffer(); } |
107 #if defined(OS_POSIX) | 103 #if defined(OS_POSIX) |
108 base::FileDescriptor AsPlatformFile() override { | 104 base::FileDescriptor AsPlatformFile() override { |
109 #if defined(OS_MACOSX) | |
110 return gmb_->GetHandle().handle.GetFileDescriptor(); | |
111 #else | |
112 return gmb_->GetHandle().handle; | 105 return gmb_->GetHandle().handle; |
113 #endif // defined(OS_MACOSX) | |
114 } | 106 } |
115 #endif | 107 #endif |
116 | 108 |
117 private: | 109 private: |
118 gfx::GpuMemoryBuffer* const gmb_; | 110 gfx::GpuMemoryBuffer* const gmb_; |
119 scoped_ptr<void*[]> data_; | 111 scoped_ptr<void*[]> data_; |
120 const size_t size_; | 112 const size_t size_; |
121 }; | 113 }; |
122 | 114 |
123 // Tracker specifics for SharedMemory. | 115 // Tracker specifics for SharedMemory. |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 return buffer_id; | 397 return buffer_id; |
406 } | 398 } |
407 | 399 |
408 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker( | 400 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker( |
409 int buffer_id) { | 401 int buffer_id) { |
410 TrackerMap::const_iterator it = trackers_.find(buffer_id); | 402 TrackerMap::const_iterator it = trackers_.find(buffer_id); |
411 return (it == trackers_.end()) ? NULL : it->second; | 403 return (it == trackers_.end()) ? NULL : it->second; |
412 } | 404 } |
413 | 405 |
414 } // namespace content | 406 } // namespace content |
OLD | NEW |