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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 for (auto& format : kNativeFormats) { | 134 for (auto& format : kNativeFormats) { |
135 for (auto& usage : kNativeUsages) { | 135 for (auto& usage : kNativeUsages) { |
136 if (IsNativeGpuMemoryBufferFactoryConfigurationSupported(format, usage)) | 136 if (IsNativeGpuMemoryBufferFactoryConfigurationSupported(format, usage)) |
137 configurations.insert(std::make_pair(format, usage)); | 137 configurations.insert(std::make_pair(format, usage)); |
138 } | 138 } |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 if (force_native_scanout_formats) { | 142 if (force_native_scanout_formats) { |
143 const gfx::BufferFormat kScanoutFormats[] = { | 143 const gfx::BufferFormat kScanoutFormats[] = { |
144 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888, | 144 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::RGBX_8888, |
145 gfx::BufferFormat::BGRX_8888, gfx::BufferFormat::UYVY_422, | 145 gfx::BufferFormat::BGRA_8888, gfx::BufferFormat::BGRX_8888, |
146 gfx::BufferFormat::YUV_420_BIPLANAR}; | 146 gfx::BufferFormat::UYVY_422, gfx::BufferFormat::YUV_420_BIPLANAR}; |
147 for (auto& format : kScanoutFormats) { | 147 for (auto& format : kScanoutFormats) { |
148 if (IsNativeGpuMemoryBufferFactoryConfigurationSupported( | 148 if (IsNativeGpuMemoryBufferFactoryConfigurationSupported( |
149 format, gfx::BufferUsage::SCANOUT)) { | 149 format, gfx::BufferUsage::SCANOUT)) { |
150 configurations.insert( | 150 configurations.insert( |
151 std::make_pair(format, gfx::BufferUsage::SCANOUT)); | 151 std::make_pair(format, gfx::BufferUsage::SCANOUT)); |
152 } | 152 } |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 return configurations; | 156 return configurations; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 304 |
305 // Use service side allocation for native configurations. | 305 // Use service side allocation for native configurations. |
306 if (IsNativeGpuMemoryBufferConfiguration(format, usage)) { | 306 if (IsNativeGpuMemoryBufferConfiguration(format, usage)) { |
307 CreateGpuMemoryBufferOnIO(base::Bind(&HostCreateGpuMemoryBuffer, 0), id, | 307 CreateGpuMemoryBufferOnIO(base::Bind(&HostCreateGpuMemoryBuffer, 0), id, |
308 size, format, usage, child_client_id, false, | 308 size, format, usage, child_client_id, false, |
309 callback); | 309 callback); |
310 return; | 310 return; |
311 } | 311 } |
312 | 312 |
313 // Early out if we cannot fallback to shared memory buffer. | 313 // Early out if we cannot fallback to shared memory buffer. |
314 if (!GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) || | 314 if (!GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage) || |
315 !GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage) || | |
316 !GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size, format)) { | 315 !GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size, format)) { |
317 callback.Run(gfx::GpuMemoryBufferHandle()); | 316 callback.Run(gfx::GpuMemoryBufferHandle()); |
318 return; | 317 return; |
319 } | 318 } |
320 | 319 |
321 BufferMap& buffers = clients_[child_client_id]; | 320 BufferMap& buffers = clients_[child_client_id]; |
322 | 321 |
323 // Allocate shared memory buffer as fallback. | 322 // Allocate shared memory buffer as fallback. |
324 auto insert_result = buffers.insert(std::make_pair( | 323 auto insert_result = buffers.insert(std::make_pair( |
325 id, BufferInfo(size, gfx::SHARED_MEMORY_BUFFER, format, usage, 0))); | 324 id, BufferInfo(size, gfx::SHARED_MEMORY_BUFFER, format, usage, 0))); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 CreateGpuMemoryBufferOnIO( | 468 CreateGpuMemoryBufferOnIO( |
470 base::Bind(&HostCreateGpuMemoryBuffer, request->surface_id), new_id, | 469 base::Bind(&HostCreateGpuMemoryBuffer, request->surface_id), new_id, |
471 request->size, request->format, request->usage, request->client_id, | 470 request->size, request->format, request->usage, request->client_id, |
472 false, | 471 false, |
473 base::Bind( | 472 base::Bind( |
474 &BrowserGpuMemoryBufferManager::HandleGpuMemoryBufferCreatedOnIO, | 473 &BrowserGpuMemoryBufferManager::HandleGpuMemoryBufferCreatedOnIO, |
475 base::Unretained(this), base::Unretained(request))); | 474 base::Unretained(this), base::Unretained(request))); |
476 return; | 475 return; |
477 } | 476 } |
478 | 477 |
479 DCHECK(GpuMemoryBufferImplSharedMemory::IsFormatSupported(request->format)) | |
480 << static_cast<int>(request->format); | |
481 DCHECK(GpuMemoryBufferImplSharedMemory::IsUsageSupported(request->usage)) | 478 DCHECK(GpuMemoryBufferImplSharedMemory::IsUsageSupported(request->usage)) |
482 << static_cast<int>(request->usage); | 479 << static_cast<int>(request->usage); |
483 | 480 |
484 BufferMap& buffers = clients_[request->client_id]; | 481 BufferMap& buffers = clients_[request->client_id]; |
485 | 482 |
486 // Allocate shared memory buffer as fallback. | 483 // Allocate shared memory buffer as fallback. |
487 auto insert_result = buffers.insert(std::make_pair( | 484 auto insert_result = buffers.insert(std::make_pair( |
488 new_id, BufferInfo(request->size, gfx::SHARED_MEMORY_BUFFER, | 485 new_id, BufferInfo(request->size, gfx::SHARED_MEMORY_BUFFER, |
489 request->format, request->usage, 0))); | 486 request->format, request->usage, 0))); |
490 DCHECK(insert_result.second); | 487 DCHECK(insert_result.second); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 return gpu_client_tracing_id_; | 703 return gpu_client_tracing_id_; |
707 } | 704 } |
708 | 705 |
709 // In normal cases, |client_id| is a child process id, so we can perform | 706 // In normal cases, |client_id| is a child process id, so we can perform |
710 // the standard conversion. | 707 // the standard conversion. |
711 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( | 708 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( |
712 client_id); | 709 client_id); |
713 } | 710 } |
714 | 711 |
715 } // namespace content | 712 } // namespace content |
OLD | NEW |