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

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

Issue 1835173003: gpu: Remove GPU service side GMB creation from handle. Base URL: https://chromium.googlesource.com/chromium/src.git@ozone-gmb-gpu-process-refactor
Patch Set: Created 4 years, 8 months 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
« no previous file with comments | « no previous file | content/browser/gpu/gpu_process_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 24 matching lines...) Expand all
35 gfx::GpuMemoryBufferId id, 35 gfx::GpuMemoryBufferId id,
36 const gfx::Size& size, 36 const gfx::Size& size,
37 gfx::BufferFormat format, 37 gfx::BufferFormat format,
38 gfx::BufferUsage usage, 38 gfx::BufferUsage usage,
39 int client_id, 39 int client_id,
40 const BrowserGpuMemoryBufferManager::CreateCallback& callback) { 40 const BrowserGpuMemoryBufferManager::CreateCallback& callback) {
41 host->CreateGpuMemoryBuffer(id, size, format, usage, client_id, surface_id, 41 host->CreateGpuMemoryBuffer(id, size, format, usage, client_id, surface_id,
42 callback); 42 callback);
43 } 43 }
44 44
45 void HostCreateGpuMemoryBufferFromHandle(
46 const gfx::GpuMemoryBufferHandle& handle,
47 GpuProcessHost* host,
48 gfx::GpuMemoryBufferId id,
49 const gfx::Size& size,
50 gfx::BufferFormat format,
51 gfx::BufferUsage usage,
52 int client_id,
53 const BrowserGpuMemoryBufferManager::CreateCallback& callback) {
54 host->CreateGpuMemoryBufferFromHandle(handle, id, size, format, client_id,
55 callback);
56 }
57
58 void GpuMemoryBufferDeleted( 45 void GpuMemoryBufferDeleted(
59 scoped_refptr<base::SingleThreadTaskRunner> destruction_task_runner, 46 scoped_refptr<base::SingleThreadTaskRunner> destruction_task_runner,
60 const GpuMemoryBufferImpl::DestructionCallback& destruction_callback, 47 const GpuMemoryBufferImpl::DestructionCallback& destruction_callback,
61 const gpu::SyncToken& sync_token) { 48 const gpu::SyncToken& sync_token) {
62 destruction_task_runner->PostTask( 49 destruction_task_runner->PostTask(
63 FROM_HERE, base::Bind(destruction_callback, sync_token)); 50 FROM_HERE, base::Bind(destruction_callback, sync_token));
64 } 51 }
65 52
66 bool IsNativeGpuMemoryBufferFactoryConfigurationSupported( 53 bool IsNativeGpuMemoryBufferFactoryConfigurationSupported(
67 gfx::BufferFormat format, 54 gfx::BufferFormat format,
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 480
494 // Use service side allocation for native types. 481 // Use service side allocation for native types.
495 if (request->handle.type != gfx::SHARED_MEMORY_BUFFER) { 482 if (request->handle.type != gfx::SHARED_MEMORY_BUFFER) {
496 // Early out if service side allocation is not supported. 483 // Early out if service side allocation is not supported.
497 if (request->handle.type != gpu::GetNativeGpuMemoryBufferType() || 484 if (request->handle.type != gpu::GetNativeGpuMemoryBufferType() ||
498 !IsNativeGpuMemoryBufferConfiguration(request->format, 485 !IsNativeGpuMemoryBufferConfiguration(request->format,
499 request->usage)) { 486 request->usage)) {
500 request->event.Signal(); 487 request->event.Signal();
501 return; 488 return;
502 } 489 }
503 // Note: Unretained is safe as this is only used for synchronous allocation 490
504 // from a non-IO thread. 491 BufferMap& buffers = clients_[request->client_id];
505 CreateGpuMemoryBufferOnIO( 492
506 base::Bind(&HostCreateGpuMemoryBufferFromHandle, request->handle), 493 auto insert_result = buffers.insert(std::make_pair(
507 new_id, request->size, request->format, request->usage, 494 new_id, BufferInfo(request->size, request->handle.type, request->format,
508 request->client_id, false, 495 request->usage, 0)));
496 DCHECK(insert_result.second);
497
498 gfx::GpuMemoryBufferHandle handle = request->handle;
499 handle.id = new_id;
500
501 // Note: Unretained is safe as IO thread is stopped before manager is
502 // destroyed.
503 request->result = GpuMemoryBufferImpl::CreateFromHandle(
504 handle, request->size, request->format, request->usage,
509 base::Bind( 505 base::Bind(
510 &BrowserGpuMemoryBufferManager::HandleGpuMemoryBufferCreatedOnIO, 506 &GpuMemoryBufferDeleted,
511 base::Unretained(this), base::Unretained(request))); 507 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
508 base::Bind(
509 &BrowserGpuMemoryBufferManager::DestroyGpuMemoryBufferOnIO,
510 base::Unretained(this), handle.id, request->client_id)));
511 request->event.Signal();
512 return; 512 return;
513 } 513 }
514 514
515 DCHECK(GpuMemoryBufferImplSharedMemory::IsUsageSupported(request->usage)) 515 DCHECK(GpuMemoryBufferImplSharedMemory::IsUsageSupported(request->usage))
516 << static_cast<int>(request->usage); 516 << static_cast<int>(request->usage);
517 517
518 BufferMap& buffers = clients_[request->client_id]; 518 BufferMap& buffers = clients_[request->client_id];
519 519
520 // Allocate shared memory buffer. 520 // Allocate shared memory buffer.
521 auto insert_result = buffers.insert(std::make_pair( 521 auto insert_result = buffers.insert(std::make_pair(
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 return gpu_client_tracing_id_; 724 return gpu_client_tracing_id_;
725 } 725 }
726 726
727 // In normal cases, |client_id| is a child process id, so we can perform 727 // In normal cases, |client_id| is a child process id, so we can perform
728 // the standard conversion. 728 // the standard conversion.
729 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( 729 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId(
730 client_id); 730 client_id);
731 } 731 }
732 732
733 } // namespace content 733 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/gpu/gpu_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698