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

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

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: rebase Created 6 years, 2 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
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 unsigned internalformat, 24 gfx::GpuMemoryBuffer::Format format,
25 unsigned usage, 25 gfx::GpuMemoryBuffer::Usage usage,
26 const CreateGpuMemoryBufferCallback& callback) { 26 const CreateGpuMemoryBufferCallback& callback) {
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
28 28
29 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); 29 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_);
30 if (!host) { 30 if (!host) {
31 callback.Run(gfx::GpuMemoryBufferHandle()); 31 callback.Run(gfx::GpuMemoryBufferHandle());
32 return; 32 return;
33 } 33 }
34 34
35 uint32 request_id = next_create_gpu_memory_buffer_request_id_++; 35 uint32 request_id = next_create_gpu_memory_buffer_request_id_++;
36 create_gpu_memory_buffer_requests_[request_id] = callback; 36 create_gpu_memory_buffer_requests_[request_id] = callback;
37 37
38 host->CreateGpuMemoryBuffer( 38 host->CreateGpuMemoryBuffer(
39 handle, 39 handle,
40 size, 40 size,
41 internalformat, 41 format,
42 usage, 42 usage,
43 base::Bind(&GpuMemoryBufferFactoryHostImpl::OnGpuMemoryBufferCreated, 43 base::Bind(&GpuMemoryBufferFactoryHostImpl::OnGpuMemoryBufferCreated,
44 base::Unretained(this), 44 base::Unretained(this),
45 request_id)); 45 request_id));
46 } 46 }
47 47
48 void GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBuffer( 48 void GpuMemoryBufferFactoryHostImpl::DestroyGpuMemoryBuffer(
49 const gfx::GpuMemoryBufferHandle& handle, 49 const gfx::GpuMemoryBufferHandle& handle,
50 int32 sync_point) { 50 int32 sync_point) {
51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 11 matching lines...) Expand all
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
64 64
65 CreateGpuMemoryBufferCallbackMap::iterator iter = 65 CreateGpuMemoryBufferCallbackMap::iterator iter =
66 create_gpu_memory_buffer_requests_.find(request_id); 66 create_gpu_memory_buffer_requests_.find(request_id);
67 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); 67 DCHECK(iter != create_gpu_memory_buffer_requests_.end());
68 iter->second.Run(handle); 68 iter->second.Run(handle);
69 create_gpu_memory_buffer_requests_.erase(iter); 69 create_gpu_memory_buffer_requests_.erase(iter);
70 } 70 }
71 71
72 } // namespace content 72 } // 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