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

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

Issue 685983005: gpu: Associate all GpuMemoryBuffers with unique IDs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more ozone build fix Created 6 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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/gpu_memory_buffer_factory_host_impl.h" 5 #include "content/browser/gpu/gpu_memory_buffer_factory_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/gpu/gpu_process_host.h" 8 #include "content/browser/gpu/gpu_process_host.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "ui/gfx/gpu_memory_buffer.h" 10 #include "ui/gfx/gpu_memory_buffer.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 GpuMemoryBufferFactoryHostImpl::GpuMemoryBufferFactoryHostImpl() 14 GpuMemoryBufferFactoryHostImpl::GpuMemoryBufferFactoryHostImpl()
15 : gpu_host_id_(0), next_create_gpu_memory_buffer_request_id_(0) { 15 : gpu_host_id_(0), next_create_gpu_memory_buffer_request_id_(0) {
16 } 16 }
17 17
18 GpuMemoryBufferFactoryHostImpl::~GpuMemoryBufferFactoryHostImpl() { 18 GpuMemoryBufferFactoryHostImpl::~GpuMemoryBufferFactoryHostImpl() {
19 } 19 }
20 20
21 void GpuMemoryBufferFactoryHostImpl::CreateGpuMemoryBuffer( 21 void GpuMemoryBufferFactoryHostImpl::CreateGpuMemoryBuffer(
22 const gfx::GpuMemoryBufferHandle& handle, 22 gfx::GpuMemoryBufferType type,
23 gfx::GpuMemoryBufferId id,
23 const gfx::Size& size, 24 const gfx::Size& size,
24 gfx::GpuMemoryBuffer::Format format, 25 gfx::GpuMemoryBuffer::Format format,
25 gfx::GpuMemoryBuffer::Usage usage, 26 gfx::GpuMemoryBuffer::Usage usage,
26 const CreateGpuMemoryBufferCallback& callback) { 27 int client_id,
27 BrowserThread::PostTask(
28 BrowserThread::IO,
29 FROM_HERE,
30 base::Bind(&GpuMemoryBufferFactoryHostImpl::CreateGpuMemoryBufferOnIO,
31 base::Unretained(this),
32 handle,
33 size,
34 format,
35 usage,
36 callback));
37 }
38
39 void GpuMemoryBufferFactoryHostImpl::CreateGpuMemoryBufferOnIO(
40 const gfx::GpuMemoryBufferHandle& handle,
41 const gfx::Size& size,
42 gfx::GpuMemoryBuffer::Format format,
43 gfx::GpuMemoryBuffer::Usage usage,
44 const CreateGpuMemoryBufferCallback& callback) { 28 const CreateGpuMemoryBufferCallback& callback) {
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
46 30
47 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); 31 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_);
48 if (!host) { 32 if (!host) {
49 callback.Run(gfx::GpuMemoryBufferHandle()); 33 callback.Run(gfx::GpuMemoryBufferHandle());
50 return; 34 return;
51 } 35 }
52 36
53 uint32 request_id = next_create_gpu_memory_buffer_request_id_++; 37 uint32 request_id = next_create_gpu_memory_buffer_request_id_++;
54 create_gpu_memory_buffer_requests_[request_id] = callback; 38 create_gpu_memory_buffer_requests_[request_id] = callback;
55 39
56 host->CreateGpuMemoryBuffer( 40 host->CreateGpuMemoryBuffer(
57 handle, 41 type,
42 id,
58 size, 43 size,
59 format, 44 format,
60 usage, 45 usage,
46 client_id,
61 base::Bind(&GpuMemoryBufferFactoryHostImpl::OnGpuMemoryBufferCreated, 47 base::Bind(&GpuMemoryBufferFactoryHostImpl::OnGpuMemoryBufferCreated,
62 base::Unretained(this), 48 base::Unretained(this),
63 request_id)); 49 request_id));
64 } 50 }
65 51
66 void GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBuffer( 52 void GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBuffer(
67 const gfx::GpuMemoryBufferHandle& handle, 53 gfx::GpuMemoryBufferType type,
54 gfx::GpuMemoryBufferId id,
55 int client_id,
68 int32 sync_point) { 56 int32 sync_point) {
69 BrowserThread::PostTask( 57 BrowserThread::PostTask(
70 BrowserThread::IO, 58 BrowserThread::IO,
71 FROM_HERE, 59 FROM_HERE,
72 base::Bind(&GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBufferOnIO, 60 base::Bind(&GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBufferOnIO,
73 base::Unretained(this), 61 base::Unretained(this),
74 handle, 62 type,
63 id,
64 client_id,
75 sync_point)); 65 sync_point));
76 } 66 }
77 67
78 void GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBufferOnIO( 68 void GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBufferOnIO(
79 const gfx::GpuMemoryBufferHandle& handle, 69 gfx::GpuMemoryBufferType type,
70 gfx::GpuMemoryBufferId id,
71 int client_id,
80 int32 sync_point) { 72 int32 sync_point) {
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
82 74
83 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); 75 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_);
84 if (!host) 76 if (!host)
85 return; 77 return;
86 78
87 host->DestroyGpuMemoryBuffer(handle, sync_point); 79 host->DestroyGpuMemoryBuffer(type, id, client_id, sync_point);
88 } 80 }
89 81
90 void GpuMemoryBufferFactoryHostImpl::OnGpuMemoryBufferCreated( 82 void GpuMemoryBufferFactoryHostImpl::OnGpuMemoryBufferCreated(
91 uint32 request_id, 83 uint32 request_id,
92 const gfx::GpuMemoryBufferHandle& handle) { 84 const gfx::GpuMemoryBufferHandle& handle) {
93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
94 86
95 CreateGpuMemoryBufferCallbackMap::iterator iter = 87 CreateGpuMemoryBufferCallbackMap::iterator iter =
96 create_gpu_memory_buffer_requests_.find(request_id); 88 create_gpu_memory_buffer_requests_.find(request_id);
97 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); 89 DCHECK(iter != create_gpu_memory_buffer_requests_.end());
98 iter->second.Run(handle); 90 iter->second.Run(handle);
99 create_gpu_memory_buffer_requests_.erase(iter); 91 create_gpu_memory_buffer_requests_.erase(iter);
100 } 92 }
101 93
102 } // namespace content 94 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_memory_buffer_factory_host_impl.h ('k') | content/browser/gpu/gpu_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698