| 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/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 14 #include "base/trace_event/process_memory_dump.h" | 14 #include "base/trace_event/process_memory_dump.h" |
| 15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "content/browser/gpu/gpu_process_host.h" | 17 #include "content/browser/gpu/gpu_process_host.h" |
| 18 #include "content/common/child_process_host_impl.h" | 18 #include "content/common/child_process_host_impl.h" |
| 19 #include "content/common/generic_shared_memory_id_generator.h" | 19 #include "content/common/generic_shared_memory_id_generator.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 22 #include "gpu/GLES2/gl2extchromium.h" | 22 #include "gpu/GLES2/gl2extchromium.h" |
| 23 #include "gpu/ipc/client/gpu_fence_impl.h" | 23 #include "gpu/ipc/client/gpu_fence_impl.h" |
| 24 #include "gpu/ipc/client/gpu_fence_impl_shared_event.h" |
| 24 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" | 25 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" |
| 25 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" | 26 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" |
| 26 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 27 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
| 27 #include "ui/gfx/buffer_format_util.h" | 28 #include "ui/gfx/buffer_format_util.h" |
| 28 #include "ui/gfx/gpu_memory_buffer_tracing.h" | 29 #include "ui/gfx/gpu_memory_buffer_tracing.h" |
| 29 #include "ui/gl/gl_switches.h" | 30 #include "ui/gl/gl_switches.h" |
| 30 | 31 |
| 32 #if defined(OS_LINUX) |
| 33 #include "gpu/ipc/client/gpu_fence_impl_libsync.h" |
| 34 #endif |
| 35 |
| 31 namespace content { | 36 namespace content { |
| 32 namespace { | 37 namespace { |
| 33 | 38 |
| 34 void HostCreateGpuMemoryBuffer( | 39 void HostCreateGpuMemoryBuffer( |
| 35 gpu::SurfaceHandle surface_handle, | 40 gpu::SurfaceHandle surface_handle, |
| 36 GpuProcessHost* host, | 41 GpuProcessHost* host, |
| 37 gfx::GpuMemoryBufferId id, | 42 gfx::GpuMemoryBufferId id, |
| 38 const gfx::Size& size, | 43 const gfx::Size& size, |
| 39 gfx::BufferFormat format, | 44 gfx::BufferFormat format, |
| 40 gfx::BufferUsage usage, | 45 gfx::BufferUsage usage, |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 } | 304 } |
| 300 | 305 |
| 301 void BrowserGpuMemoryBufferManager::SetDestructionSyncToken( | 306 void BrowserGpuMemoryBufferManager::SetDestructionSyncToken( |
| 302 gfx::GpuMemoryBuffer* buffer, | 307 gfx::GpuMemoryBuffer* buffer, |
| 303 const gpu::SyncToken& sync_token) { | 308 const gpu::SyncToken& sync_token) { |
| 304 static_cast<gpu::GpuMemoryBufferImpl*>(buffer)->set_destruction_sync_token( | 309 static_cast<gpu::GpuMemoryBufferImpl*>(buffer)->set_destruction_sync_token( |
| 305 sync_token); | 310 sync_token); |
| 306 } | 311 } |
| 307 | 312 |
| 308 std::unique_ptr<gfx::GpuFence> BrowserGpuMemoryBufferManager::CreateGpuFence() { | 313 std::unique_ptr<gfx::GpuFence> BrowserGpuMemoryBufferManager::CreateGpuFence() { |
| 309 std::unique_ptr<gpu::GpuFenceImpl> fence(new gpu::GpuFenceImpl); | 314 std::unique_ptr<gpu::GpuFenceImpl> fence(new gpu::GpuFenceImplSharedEvent); |
| 310 return std::move(fence); | 315 return std::move(fence); |
| 311 } | 316 } |
| 312 | 317 |
| 313 std::unique_ptr<gfx::GpuFence> | 318 std::unique_ptr<gfx::GpuFence> |
| 314 BrowserGpuMemoryBufferManager::CreateGpuFenceFromHandle( | 319 BrowserGpuMemoryBufferManager::CreateGpuFenceFromHandle( |
| 315 const gfx::GpuFenceHandle& handle) { | 320 const gfx::GpuFenceHandle& handle) { |
| 321 #if defined(OS_LINUX) |
| 322 if (handle.fd.fd >= 0) |
| 323 return base::MakeUnique<gpu::GpuFenceImplLibsync>(handle.fd); |
| 324 #endif |
| 316 return nullptr; | 325 return nullptr; |
| 317 } | 326 } |
| 318 | 327 |
| 319 gfx::GpuFence* BrowserGpuMemoryBufferManager::GpuFenceFromClientFence( | 328 gfx::GpuFence* BrowserGpuMemoryBufferManager::GpuFenceFromClientFence( |
| 320 ClientFence fence) { | 329 ClientFence fence) { |
| 321 return gpu::GpuFenceImpl::FromClientFence(fence); | 330 return gpu::GpuFenceImpl::FromClientFence(fence); |
| 322 } | 331 } |
| 323 | 332 |
| 324 bool BrowserGpuMemoryBufferManager::OnMemoryDump( | 333 bool BrowserGpuMemoryBufferManager::OnMemoryDump( |
| 325 const base::trace_event::MemoryDumpArgs& args, | 334 const base::trace_event::MemoryDumpArgs& args, |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 format(format), | 719 format(format), |
| 711 usage(usage), | 720 usage(usage), |
| 712 gpu_host_id(gpu_host_id) {} | 721 gpu_host_id(gpu_host_id) {} |
| 713 | 722 |
| 714 BrowserGpuMemoryBufferManager::BufferInfo::BufferInfo(const BufferInfo& other) = | 723 BrowserGpuMemoryBufferManager::BufferInfo::BufferInfo(const BufferInfo& other) = |
| 715 default; | 724 default; |
| 716 | 725 |
| 717 BrowserGpuMemoryBufferManager::BufferInfo::~BufferInfo() {} | 726 BrowserGpuMemoryBufferManager::BufferInfo::~BufferInfo() {} |
| 718 | 727 |
| 719 } // namespace content | 728 } // namespace content |
| OLD | NEW |