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

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

Issue 1414793018: Revert of Converted video frame and image callbacks to use new sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 "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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 gfx::BufferUsage usage, 60 gfx::BufferUsage usage,
61 int client_id, 61 int client_id,
62 const BrowserGpuMemoryBufferManager::CreateCallback& callback) { 62 const BrowserGpuMemoryBufferManager::CreateCallback& callback) {
63 host->CreateGpuMemoryBufferFromHandle(handle, id, size, format, client_id, 63 host->CreateGpuMemoryBufferFromHandle(handle, id, size, format, client_id,
64 callback); 64 callback);
65 } 65 }
66 66
67 void GpuMemoryBufferDeleted( 67 void GpuMemoryBufferDeleted(
68 scoped_refptr<base::SingleThreadTaskRunner> destruction_task_runner, 68 scoped_refptr<base::SingleThreadTaskRunner> destruction_task_runner,
69 const GpuMemoryBufferImpl::DestructionCallback& destruction_callback, 69 const GpuMemoryBufferImpl::DestructionCallback& destruction_callback,
70 const gpu::SyncToken& sync_token) { 70 uint32 sync_point) {
71 destruction_task_runner->PostTask( 71 destruction_task_runner->PostTask(
72 FROM_HERE, base::Bind(destruction_callback, sync_token)); 72 FROM_HERE, base::Bind(destruction_callback, sync_point));
73 } 73 }
74 74
75 bool IsNativeGpuMemoryBufferFactoryConfigurationSupported( 75 bool IsNativeGpuMemoryBufferFactoryConfigurationSupported(
76 gfx::BufferFormat format, 76 gfx::BufferFormat format,
77 gfx::BufferUsage usage) { 77 gfx::BufferUsage usage) {
78 switch (GpuMemoryBufferFactory::GetNativeType()) { 78 switch (GpuMemoryBufferFactory::GetNativeType()) {
79 case gfx::SHARED_MEMORY_BUFFER: 79 case gfx::SHARED_MEMORY_BUFFER:
80 return false; 80 return false;
81 #if defined(OS_MACOSX) 81 #if defined(OS_MACOSX)
82 case gfx::IO_SURFACE_BUFFER: 82 case gfx::IO_SURFACE_BUFFER:
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 callback.Run(GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( 334 callback.Run(GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
335 id, size, format, child_process_handle)); 335 id, size, format, child_process_handle));
336 } 336 }
337 337
338 gfx::GpuMemoryBuffer* 338 gfx::GpuMemoryBuffer*
339 BrowserGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( 339 BrowserGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer(
340 ClientBuffer buffer) { 340 ClientBuffer buffer) {
341 return GpuMemoryBufferImpl::FromClientBuffer(buffer); 341 return GpuMemoryBufferImpl::FromClientBuffer(buffer);
342 } 342 }
343 343
344 void BrowserGpuMemoryBufferManager::SetDestructionSyncToken( 344 void BrowserGpuMemoryBufferManager::SetDestructionSyncPoint(
345 gfx::GpuMemoryBuffer* buffer, 345 gfx::GpuMemoryBuffer* buffer,
346 const gpu::SyncToken& sync_token) { 346 uint32 sync_point) {
347 static_cast<GpuMemoryBufferImpl*>(buffer) 347 static_cast<GpuMemoryBufferImpl*>(buffer)
348 ->set_destruction_sync_token(sync_token); 348 ->set_destruction_sync_point(sync_point);
349 } 349 }
350 350
351 bool BrowserGpuMemoryBufferManager::OnMemoryDump( 351 bool BrowserGpuMemoryBufferManager::OnMemoryDump(
352 const base::trace_event::MemoryDumpArgs& args, 352 const base::trace_event::MemoryDumpArgs& args,
353 base::trace_event::ProcessMemoryDump* pmd) { 353 base::trace_event::ProcessMemoryDump* pmd) {
354 DCHECK_CURRENTLY_ON(BrowserThread::IO); 354 DCHECK_CURRENTLY_ON(BrowserThread::IO);
355 355
356 for (const auto& client : clients_) { 356 for (const auto& client : clients_) {
357 int client_id = client.first; 357 int client_id = client.first;
358 358
(...skipping 28 matching lines...) Expand all
387 } 387 }
388 } 388 }
389 389
390 return true; 390 return true;
391 } 391 }
392 392
393 void BrowserGpuMemoryBufferManager::ChildProcessDeletedGpuMemoryBuffer( 393 void BrowserGpuMemoryBufferManager::ChildProcessDeletedGpuMemoryBuffer(
394 gfx::GpuMemoryBufferId id, 394 gfx::GpuMemoryBufferId id,
395 base::ProcessHandle child_process_handle, 395 base::ProcessHandle child_process_handle,
396 int child_client_id, 396 int child_client_id,
397 const gpu::SyncToken& sync_token) { 397 uint32 sync_point) {
398 DCHECK_CURRENTLY_ON(BrowserThread::IO); 398 DCHECK_CURRENTLY_ON(BrowserThread::IO);
399 399
400 DestroyGpuMemoryBufferOnIO(id, child_client_id, sync_token); 400 DestroyGpuMemoryBufferOnIO(id, child_client_id, sync_point);
401 } 401 }
402 402
403 void BrowserGpuMemoryBufferManager::ProcessRemoved( 403 void BrowserGpuMemoryBufferManager::ProcessRemoved(
404 base::ProcessHandle process_handle, 404 base::ProcessHandle process_handle,
405 int client_id) { 405 int client_id) {
406 DCHECK_CURRENTLY_ON(BrowserThread::IO); 406 DCHECK_CURRENTLY_ON(BrowserThread::IO);
407 407
408 ClientMap::iterator client_it = clients_.find(client_id); 408 ClientMap::iterator client_it = clients_.find(client_id);
409 if (client_it == clients_.end()) 409 if (client_it == clients_.end())
410 return; 410 return;
411 411
412 for (const auto& buffer : client_it->second) { 412 for (const auto& buffer : client_it->second) {
413 // This might happen if buffer is currenlty in the process of being 413 // This might happen if buffer is currenlty in the process of being
414 // allocated. The buffer will in that case be cleaned up when allocation 414 // allocated. The buffer will in that case be cleaned up when allocation
415 // completes. 415 // completes.
416 if (buffer.second.type == gfx::EMPTY_BUFFER) 416 if (buffer.second.type == gfx::EMPTY_BUFFER)
417 continue; 417 continue;
418 418
419 GpuProcessHost* host = GpuProcessHost::FromID(buffer.second.gpu_host_id); 419 GpuProcessHost* host = GpuProcessHost::FromID(buffer.second.gpu_host_id);
420 if (host) 420 if (host)
421 host->DestroyGpuMemoryBuffer(buffer.first, client_id, gpu::SyncToken()); 421 host->DestroyGpuMemoryBuffer(buffer.first, client_id, 0);
422 } 422 }
423 423
424 clients_.erase(client_it); 424 clients_.erase(client_it);
425 } 425 }
426 426
427 bool BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBufferConfiguration( 427 bool BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBufferConfiguration(
428 gfx::BufferFormat format, 428 gfx::BufferFormat format,
429 gfx::BufferUsage usage) const { 429 gfx::BufferUsage usage) const {
430 return native_configurations_.find(std::make_pair(format, usage)) != 430 return native_configurations_.find(std::make_pair(format, usage)) !=
431 native_configurations_.end(); 431 native_configurations_.end();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 const gfx::GpuMemoryBufferHandle& handle) { 646 const gfx::GpuMemoryBufferHandle& handle) {
647 DCHECK_CURRENTLY_ON(BrowserThread::IO); 647 DCHECK_CURRENTLY_ON(BrowserThread::IO);
648 648
649 ClientMap::iterator client_it = clients_.find(client_id); 649 ClientMap::iterator client_it = clients_.find(client_id);
650 650
651 // This can happen if client is removed while the buffer is being allocated. 651 // This can happen if client is removed while the buffer is being allocated.
652 if (client_it == clients_.end()) { 652 if (client_it == clients_.end()) {
653 if (!handle.is_null()) { 653 if (!handle.is_null()) {
654 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id); 654 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id);
655 if (host) 655 if (host)
656 host->DestroyGpuMemoryBuffer(handle.id, client_id, gpu::SyncToken()); 656 host->DestroyGpuMemoryBuffer(handle.id, client_id, 0);
657 } 657 }
658 callback.Run(gfx::GpuMemoryBufferHandle()); 658 callback.Run(gfx::GpuMemoryBufferHandle());
659 return; 659 return;
660 } 660 }
661 661
662 BufferMap& buffers = client_it->second; 662 BufferMap& buffers = client_it->second;
663 663
664 BufferMap::iterator buffer_it = buffers.find(id); 664 BufferMap::iterator buffer_it = buffers.find(id);
665 DCHECK(buffer_it != buffers.end()); 665 DCHECK(buffer_it != buffers.end());
666 DCHECK_EQ(buffer_it->second.type, gfx::EMPTY_BUFFER); 666 DCHECK_EQ(buffer_it->second.type, gfx::EMPTY_BUFFER);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 // client is removed. 698 // client is removed.
699 buffer_it->second.type = handle.type; 699 buffer_it->second.type = handle.type;
700 buffer_it->second.gpu_host_id = gpu_host_id; 700 buffer_it->second.gpu_host_id = gpu_host_id;
701 701
702 callback.Run(handle); 702 callback.Run(handle);
703 } 703 }
704 704
705 void BrowserGpuMemoryBufferManager::DestroyGpuMemoryBufferOnIO( 705 void BrowserGpuMemoryBufferManager::DestroyGpuMemoryBufferOnIO(
706 gfx::GpuMemoryBufferId id, 706 gfx::GpuMemoryBufferId id,
707 int client_id, 707 int client_id,
708 const gpu::SyncToken& sync_token) { 708 uint32 sync_point) {
709 DCHECK_CURRENTLY_ON(BrowserThread::IO); 709 DCHECK_CURRENTLY_ON(BrowserThread::IO);
710 DCHECK(clients_.find(client_id) != clients_.end()); 710 DCHECK(clients_.find(client_id) != clients_.end());
711 711
712 BufferMap& buffers = clients_[client_id]; 712 BufferMap& buffers = clients_[client_id];
713 713
714 BufferMap::iterator buffer_it = buffers.find(id); 714 BufferMap::iterator buffer_it = buffers.find(id);
715 if (buffer_it == buffers.end()) { 715 if (buffer_it == buffers.end()) {
716 LOG(ERROR) << "Invalid GpuMemoryBuffer ID for client."; 716 LOG(ERROR) << "Invalid GpuMemoryBuffer ID for client.";
717 return; 717 return;
718 } 718 }
719 719
720 // This can happen if a client managed to call this while a buffer is in the 720 // This can happen if a client managed to call this while a buffer is in the
721 // process of being allocated. 721 // process of being allocated.
722 if (buffer_it->second.type == gfx::EMPTY_BUFFER) { 722 if (buffer_it->second.type == gfx::EMPTY_BUFFER) {
723 LOG(ERROR) << "Invalid GpuMemoryBuffer type."; 723 LOG(ERROR) << "Invalid GpuMemoryBuffer type.";
724 return; 724 return;
725 } 725 }
726 726
727 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); 727 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id);
728 if (host) 728 if (host)
729 host->DestroyGpuMemoryBuffer(id, client_id, sync_token); 729 host->DestroyGpuMemoryBuffer(id, client_id, sync_point);
730 730
731 buffers.erase(buffer_it); 731 buffers.erase(buffer_it);
732 } 732 }
733 733
734 uint64_t BrowserGpuMemoryBufferManager::ClientIdToTracingProcessId( 734 uint64_t BrowserGpuMemoryBufferManager::ClientIdToTracingProcessId(
735 int client_id) const { 735 int client_id) const {
736 if (client_id == gpu_client_id_) { 736 if (client_id == gpu_client_id_) {
737 // The gpu_client uses a fixed tracing ID. 737 // The gpu_client uses a fixed tracing ID.
738 return gpu_client_tracing_id_; 738 return gpu_client_tracing_id_;
739 } 739 }
740 740
741 // In normal cases, |client_id| is a child process id, so we can perform 741 // In normal cases, |client_id| is a child process id, so we can perform
742 // the standard conversion. 742 // the standard conversion.
743 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( 743 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId(
744 client_id); 744 client_id);
745 } 745 }
746 746
747 } // namespace content 747 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/browser_gpu_memory_buffer_manager.h ('k') | content/browser/gpu/gpu_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698