| 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 <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 9 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 10 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 12 #include "base/trace_event/process_memory_dump.h" | 14 #include "base/trace_event/process_memory_dump.h" |
| 13 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 14 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 15 #include "content/browser/gpu/gpu_process_host.h" | 17 #include "content/browser/gpu/gpu_process_host.h" |
| 16 #include "content/common/child_process_host_impl.h" | 18 #include "content/common/child_process_host_impl.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 HandleCreateGpuMemoryBufferFromHandleOnIO, | 281 HandleCreateGpuMemoryBufferFromHandleOnIO, |
| 280 base::Unretained(this), // Safe as we wait for result below. | 282 base::Unretained(this), // Safe as we wait for result below. |
| 281 base::Unretained(&request))); | 283 base::Unretained(&request))); |
| 282 | 284 |
| 283 // We're blocking the UI thread, which is generally undesirable. | 285 // We're blocking the UI thread, which is generally undesirable. |
| 284 TRACE_EVENT0( | 286 TRACE_EVENT0( |
| 285 "browser", | 287 "browser", |
| 286 "BrowserGpuMemoryBufferManager::CreateGpuMemoryBufferFromHandle"); | 288 "BrowserGpuMemoryBufferManager::CreateGpuMemoryBufferFromHandle"); |
| 287 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 289 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 288 request.event.Wait(); | 290 request.event.Wait(); |
| 289 return request.result.Pass(); | 291 return std::move(request.result); |
| 290 } | 292 } |
| 291 | 293 |
| 292 scoped_ptr<gfx::GpuMemoryBuffer> | 294 scoped_ptr<gfx::GpuMemoryBuffer> |
| 293 BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForScanout( | 295 BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForScanout( |
| 294 const gfx::Size& size, | 296 const gfx::Size& size, |
| 295 gfx::BufferFormat format, | 297 gfx::BufferFormat format, |
| 296 int32_t surface_id) { | 298 int32_t surface_id) { |
| 297 DCHECK_GT(surface_id, 0); | 299 DCHECK_GT(surface_id, 0); |
| 298 return AllocateGpuMemoryBufferForSurface( | 300 return AllocateGpuMemoryBufferForSurface( |
| 299 size, format, gfx::BufferUsage::SCANOUT, surface_id); | 301 size, format, gfx::BufferUsage::SCANOUT, surface_id); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 &BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferOnIO, | 455 &BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferOnIO, |
| 454 base::Unretained(this), // Safe as we wait for result below. | 456 base::Unretained(this), // Safe as we wait for result below. |
| 455 base::Unretained(&request))); | 457 base::Unretained(&request))); |
| 456 | 458 |
| 457 // We're blocking the UI thread, which is generally undesirable. | 459 // We're blocking the UI thread, which is generally undesirable. |
| 458 TRACE_EVENT0( | 460 TRACE_EVENT0( |
| 459 "browser", | 461 "browser", |
| 460 "BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface"); | 462 "BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface"); |
| 461 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 463 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 462 request.event.Wait(); | 464 request.event.Wait(); |
| 463 return request.result.Pass(); | 465 return std::move(request.result); |
| 464 } | 466 } |
| 465 | 467 |
| 466 void BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferOnIO( | 468 void BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferOnIO( |
| 467 CreateGpuMemoryBufferRequest* request) { | 469 CreateGpuMemoryBufferRequest* request) { |
| 468 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 470 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 469 | 471 |
| 470 gfx::GpuMemoryBufferId new_id = content::GetNextGenericSharedMemoryId(); | 472 gfx::GpuMemoryBufferId new_id = content::GetNextGenericSharedMemoryId(); |
| 471 | 473 |
| 472 // Use service side allocation for native configurations. | 474 // Use service side allocation for native configurations. |
| 473 if (IsNativeGpuMemoryBufferConfiguration(request->format, request->usage)) { | 475 if (IsNativeGpuMemoryBufferConfiguration(request->format, request->usage)) { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 return gpu_client_tracing_id_; | 747 return gpu_client_tracing_id_; |
| 746 } | 748 } |
| 747 | 749 |
| 748 // In normal cases, |client_id| is a child process id, so we can perform | 750 // In normal cases, |client_id| is a child process id, so we can perform |
| 749 // the standard conversion. | 751 // the standard conversion. |
| 750 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( | 752 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( |
| 751 client_id); | 753 client_id); |
| 752 } | 754 } |
| 753 | 755 |
| 754 } // namespace content | 756 } // namespace content |
| OLD | NEW |