Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: content/browser/gpu/browser_gpu_memory_buffer_manager.cc

Issue 2383753002: gpu: Add GpuFence framework.
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_memory_buffer_impl.h" 24 #include "gpu/ipc/client/gpu_memory_buffer_impl.h"
24 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" 25 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h"
25 #include "gpu/ipc/common/gpu_memory_buffer_support.h" 26 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
26 #include "ui/gfx/buffer_format_util.h" 27 #include "ui/gfx/buffer_format_util.h"
27 #include "ui/gfx/gpu_memory_buffer_tracing.h" 28 #include "ui/gfx/gpu_memory_buffer_tracing.h"
28 #include "ui/gl/gl_switches.h" 29 #include "ui/gl/gl_switches.h"
29 30
30 namespace content { 31 namespace content {
31 namespace { 32 namespace {
32 33
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 id, size, format, child_process_handle)); 292 id, size, format, child_process_handle));
292 } 293 }
293 294
294 void BrowserGpuMemoryBufferManager::SetDestructionSyncToken( 295 void BrowserGpuMemoryBufferManager::SetDestructionSyncToken(
295 gfx::GpuMemoryBuffer* buffer, 296 gfx::GpuMemoryBuffer* buffer,
296 const gpu::SyncToken& sync_token) { 297 const gpu::SyncToken& sync_token) {
297 static_cast<gpu::GpuMemoryBufferImpl*>(buffer)->set_destruction_sync_token( 298 static_cast<gpu::GpuMemoryBufferImpl*>(buffer)->set_destruction_sync_token(
298 sync_token); 299 sync_token);
299 } 300 }
300 301
302 std::unique_ptr<gfx::GpuFence> BrowserGpuMemoryBufferManager::CreateGpuFence() {
303 std::unique_ptr<gpu::GpuFenceImpl> fence(new gpu::GpuFenceImpl);
304 return std::move(fence);
305 }
306
307 std::unique_ptr<gfx::GpuFence>
308 BrowserGpuMemoryBufferManager::CreateGpuFenceFromHandle(
309 const gfx::GpuFenceHandle& handle) {
310 return nullptr;
311 }
312
313 gfx::GpuFence* BrowserGpuMemoryBufferManager::GpuFenceFromClientFence(
314 ClientFence fence) {
315 return gpu::GpuFenceImpl::FromClientFence(fence);
316 }
317
301 bool BrowserGpuMemoryBufferManager::OnMemoryDump( 318 bool BrowserGpuMemoryBufferManager::OnMemoryDump(
302 const base::trace_event::MemoryDumpArgs& args, 319 const base::trace_event::MemoryDumpArgs& args,
303 base::trace_event::ProcessMemoryDump* pmd) { 320 base::trace_event::ProcessMemoryDump* pmd) {
304 DCHECK_CURRENTLY_ON(BrowserThread::IO); 321 DCHECK_CURRENTLY_ON(BrowserThread::IO);
305 322
306 for (const auto& client : clients_) { 323 for (const auto& client : clients_) {
307 int client_id = client.first; 324 int client_id = client.first;
308 325
309 for (const auto& buffer : client.second) { 326 for (const auto& buffer : client.second) {
310 if (buffer.second.type == gfx::EMPTY_BUFFER) 327 if (buffer.second.type == gfx::EMPTY_BUFFER)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 void BrowserGpuMemoryBufferManager::ChildProcessDeletedGpuMemoryBuffer( 361 void BrowserGpuMemoryBufferManager::ChildProcessDeletedGpuMemoryBuffer(
345 gfx::GpuMemoryBufferId id, 362 gfx::GpuMemoryBufferId id,
346 base::ProcessHandle child_process_handle, 363 base::ProcessHandle child_process_handle,
347 int child_client_id, 364 int child_client_id,
348 const gpu::SyncToken& sync_token) { 365 const gpu::SyncToken& sync_token) {
349 DCHECK_CURRENTLY_ON(BrowserThread::IO); 366 DCHECK_CURRENTLY_ON(BrowserThread::IO);
350 367
351 DestroyGpuMemoryBufferOnIO(id, child_client_id, sync_token); 368 DestroyGpuMemoryBufferOnIO(id, child_client_id, sync_token);
352 } 369 }
353 370
371 void BrowserGpuMemoryBufferManager::CreateGpuFenceForChildProcess(
372 base::ProcessHandle child_process_handle,
373 const FenceCreationCallback& callback) {
374 DCHECK_CURRENTLY_ON(BrowserThread::IO);
375
376 callback.Run(gpu::GpuFenceImpl::CreateForChildProcess(child_process_handle));
377 }
378
354 void BrowserGpuMemoryBufferManager::ProcessRemoved( 379 void BrowserGpuMemoryBufferManager::ProcessRemoved(
355 base::ProcessHandle process_handle, 380 base::ProcessHandle process_handle,
356 int client_id) { 381 int client_id) {
357 DCHECK_CURRENTLY_ON(BrowserThread::IO); 382 DCHECK_CURRENTLY_ON(BrowserThread::IO);
358 383
359 ClientMap::iterator client_it = clients_.find(client_id); 384 ClientMap::iterator client_it = clients_.find(client_id);
360 if (client_it == clients_.end()) 385 if (client_it == clients_.end())
361 return; 386 return;
362 387
363 for (const auto& buffer : client_it->second) { 388 for (const auto& buffer : client_it->second) {
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 format(format), 704 format(format),
680 usage(usage), 705 usage(usage),
681 gpu_host_id(gpu_host_id) {} 706 gpu_host_id(gpu_host_id) {}
682 707
683 BrowserGpuMemoryBufferManager::BufferInfo::BufferInfo(const BufferInfo& other) = 708 BrowserGpuMemoryBufferManager::BufferInfo::BufferInfo(const BufferInfo& other) =
684 default; 709 default;
685 710
686 BrowserGpuMemoryBufferManager::BufferInfo::~BufferInfo() {} 711 BrowserGpuMemoryBufferManager::BufferInfo::~BufferInfo() {}
687 712
688 } // namespace content 713 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698