OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gpu/browser_gpu_memory_buffer_manager.h" | 5 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 BufferMap& buffers = clients_[child_client_id]; | 133 BufferMap& buffers = clients_[child_client_id]; |
134 DCHECK(buffers.find(new_id) == buffers.end()); | 134 DCHECK(buffers.find(new_id) == buffers.end()); |
135 | 135 |
136 // Fallback to shared memory buffer if |format| and |usage| are not supported | 136 // Fallback to shared memory buffer if |format| and |usage| are not supported |
137 // by factory. | 137 // by factory. |
138 if (!gpu_memory_buffer_factory_host_->IsGpuMemoryBufferConfigurationSupported( | 138 if (!gpu_memory_buffer_factory_host_->IsGpuMemoryBufferConfigurationSupported( |
139 format, usage)) { | 139 format, usage)) { |
140 // Early out if we cannot fallback to shared memory buffer. | 140 // Early out if we cannot fallback to shared memory buffer. |
141 if (!GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) || | 141 if (!GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) || |
| 142 !GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size, format) || |
142 usage != gfx::GpuMemoryBuffer::MAP) { | 143 usage != gfx::GpuMemoryBuffer::MAP) { |
143 callback.Run(gfx::GpuMemoryBufferHandle()); | 144 callback.Run(gfx::GpuMemoryBufferHandle()); |
144 return; | 145 return; |
145 } | 146 } |
146 | 147 |
147 buffers[new_id] = gfx::SHARED_MEMORY_BUFFER; | 148 buffers[new_id] = gfx::SHARED_MEMORY_BUFFER; |
148 callback.Run(GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( | 149 callback.Run(GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( |
149 new_id, size, format, child_process_handle)); | 150 new_id, size, format, child_process_handle)); |
150 return; | 151 return; |
151 } | 152 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 DCHECK_NE(handle.type, gfx::SHARED_MEMORY_BUFFER); | 317 DCHECK_NE(handle.type, gfx::SHARED_MEMORY_BUFFER); |
317 | 318 |
318 // Store the type of this buffer so it can be cleaned up if the child | 319 // Store the type of this buffer so it can be cleaned up if the child |
319 // process is removed. | 320 // process is removed. |
320 buffer_it->second = handle.type; | 321 buffer_it->second = handle.type; |
321 | 322 |
322 callback.Run(handle); | 323 callback.Run(handle); |
323 } | 324 } |
324 | 325 |
325 } // namespace content | 326 } // namespace content |
OLD | NEW |