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

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

Issue 654223006: Cleanup GpuMemoryBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: style nits 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 const gfx::GpuMemoryBufferHandle& handle,
23 const gfx::Size& size, 23 const gfx::Size& size,
24 gfx::GpuMemoryBuffer::Format format, 24 gfx::GpuMemoryBuffer::Format format,
25 gfx::GpuMemoryBuffer::Usage usage, 25 gfx::GpuMemoryBuffer::Usage usage,
26 const CreateGpuMemoryBufferCallback& callback) { 26 const CreateGpuMemoryBufferCallback& callback) {
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) {
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
28 46
29 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); 47 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_);
30 if (!host) { 48 if (!host) {
31 callback.Run(gfx::GpuMemoryBufferHandle()); 49 callback.Run(gfx::GpuMemoryBufferHandle());
32 return; 50 return;
33 } 51 }
34 52
35 uint32 request_id = next_create_gpu_memory_buffer_request_id_++; 53 uint32 request_id = next_create_gpu_memory_buffer_request_id_++;
36 create_gpu_memory_buffer_requests_[request_id] = callback; 54 create_gpu_memory_buffer_requests_[request_id] = callback;
37 55
38 host->CreateGpuMemoryBuffer( 56 host->CreateGpuMemoryBuffer(
39 handle, 57 handle,
40 size, 58 size,
41 format, 59 format,
42 usage, 60 usage,
43 base::Bind(&GpuMemoryBufferFactoryHostImpl::OnGpuMemoryBufferCreated, 61 base::Bind(&GpuMemoryBufferFactoryHostImpl::OnGpuMemoryBufferCreated,
44 base::Unretained(this), 62 base::Unretained(this),
45 request_id)); 63 request_id));
46 } 64 }
47 65
48 void GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBuffer( 66 void GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBuffer(
49 const gfx::GpuMemoryBufferHandle& handle, 67 const gfx::GpuMemoryBufferHandle& handle,
50 int32 sync_point) { 68 int32 sync_point) {
69 BrowserThread::PostTask(
70 BrowserThread::IO,
71 FROM_HERE,
72 base::Bind(&GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBufferOnIO,
73 base::Unretained(this),
74 handle,
75 sync_point));
76 }
77
78 void GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBufferOnIO(
79 const gfx::GpuMemoryBufferHandle& handle,
80 int32 sync_point) {
51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
52 82
53 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); 83 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_);
54 if (!host) 84 if (!host)
55 return; 85 return;
56 86
57 host->DestroyGpuMemoryBuffer(handle, sync_point); 87 host->DestroyGpuMemoryBuffer(handle, sync_point);
58 } 88 }
59 89
60 void GpuMemoryBufferFactoryHostImpl::OnGpuMemoryBufferCreated( 90 void GpuMemoryBufferFactoryHostImpl::OnGpuMemoryBufferCreated(
61 uint32 request_id, 91 uint32 request_id,
62 const gfx::GpuMemoryBufferHandle& handle) { 92 const gfx::GpuMemoryBufferHandle& handle) {
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
64 94
65 CreateGpuMemoryBufferCallbackMap::iterator iter = 95 CreateGpuMemoryBufferCallbackMap::iterator iter =
66 create_gpu_memory_buffer_requests_.find(request_id); 96 create_gpu_memory_buffer_requests_.find(request_id);
67 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); 97 DCHECK(iter != create_gpu_memory_buffer_requests_.end());
68 iter->second.Run(handle); 98 iter->second.Run(handle);
69 create_gpu_memory_buffer_requests_.erase(iter); 99 create_gpu_memory_buffer_requests_.erase(iter);
70 } 100 }
71 101
72 } // namespace content 102 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_memory_buffer_factory_host_impl.h ('k') | content/browser/renderer_host/render_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698