| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 15 #include "base/trace_event/process_memory_dump.h" | 15 #include "base/trace_event/process_memory_dump.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "content/browser/gpu/gpu_process_host.h" | 18 #include "content/browser/gpu/gpu_process_host.h" |
| 19 #include "content/common/child_process_host_impl.h" | 19 #include "content/common/child_process_host_impl.h" |
| 20 #include "content/common/generic_shared_memory_id_generator.h" | |
| 21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 23 #include "gpu/GLES2/gl2extchromium.h" | |
| 24 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" | 22 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" |
| 25 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" | 23 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" |
| 26 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | |
| 27 #include "ui/gfx/buffer_format_util.h" | 24 #include "ui/gfx/buffer_format_util.h" |
| 28 #include "ui/gfx/gpu_memory_buffer_tracing.h" | 25 #include "ui/gfx/gpu_memory_buffer_tracing.h" |
| 29 #include "ui/gl/gl_switches.h" | 26 #include "ui/gl/gl_switches.h" |
| 30 | 27 |
| 31 namespace content { | 28 namespace content { |
| 32 namespace { | 29 namespace { |
| 33 | 30 |
| 34 void GpuMemoryBufferDeleted( | 31 void GpuMemoryBufferDeleted( |
| 35 scoped_refptr<base::SingleThreadTaskRunner> destruction_task_runner, | 32 scoped_refptr<base::SingleThreadTaskRunner> destruction_task_runner, |
| 36 const gpu::GpuMemoryBufferImpl::DestructionCallback& destruction_callback, | 33 const gpu::GpuMemoryBufferImpl::DestructionCallback& destruction_callback, |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 "BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface"); | 252 "BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface"); |
| 256 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 253 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 257 request.event.Wait(); | 254 request.event.Wait(); |
| 258 return std::move(request.result); | 255 return std::move(request.result); |
| 259 } | 256 } |
| 260 | 257 |
| 261 void BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferOnIO( | 258 void BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferOnIO( |
| 262 CreateGpuMemoryBufferRequest* request) { | 259 CreateGpuMemoryBufferRequest* request) { |
| 263 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 260 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 264 | 261 |
| 265 gfx::GpuMemoryBufferId new_id = content::GetNextGenericSharedMemoryId(); | 262 gfx::GpuMemoryBufferId new_id(next_gpu_memory_id_++); |
| 266 | |
| 267 // Use service side allocation for native configurations. | 263 // Use service side allocation for native configurations. |
| 268 if (IsNativeGpuMemoryBufferConfiguration(request->format, request->usage)) { | 264 if (IsNativeGpuMemoryBufferConfiguration(request->format, request->usage)) { |
| 269 // Note: Unretained is safe as this is only used for synchronous allocation | 265 // Note: Unretained is safe as this is only used for synchronous allocation |
| 270 // from a non-IO thread. | 266 // from a non-IO thread. |
| 271 CreateGpuMemoryBufferOnIO( | 267 CreateGpuMemoryBufferOnIO( |
| 272 new_id, request->size, request->format, request->usage, | 268 new_id, request->size, request->format, request->usage, |
| 273 request->surface_handle, request->client_id, | 269 request->surface_handle, request->client_id, |
| 274 base::Bind( | 270 base::Bind( |
| 275 &BrowserGpuMemoryBufferManager::HandleGpuMemoryBufferCreatedOnIO, | 271 &BrowserGpuMemoryBufferManager::HandleGpuMemoryBufferCreatedOnIO, |
| 276 base::Unretained(this), base::Unretained(request))); | 272 base::Unretained(this), base::Unretained(request))); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 format(format), | 473 format(format), |
| 478 usage(usage), | 474 usage(usage), |
| 479 gpu_host_id(gpu_host_id) {} | 475 gpu_host_id(gpu_host_id) {} |
| 480 | 476 |
| 481 BrowserGpuMemoryBufferManager::BufferInfo::BufferInfo(const BufferInfo& other) = | 477 BrowserGpuMemoryBufferManager::BufferInfo::BufferInfo(const BufferInfo& other) = |
| 482 default; | 478 default; |
| 483 | 479 |
| 484 BrowserGpuMemoryBufferManager::BufferInfo::~BufferInfo() {} | 480 BrowserGpuMemoryBufferManager::BufferInfo::~BufferInfo() {} |
| 485 | 481 |
| 486 } // namespace content | 482 } // namespace content |
| OLD | NEW |