OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "gpu/command_buffer/service/gpu_control_service.h" | |
6 | |
7 #include "gpu/command_buffer/client/gpu_memory_buffer_factory.h" | |
8 #include "gpu/command_buffer/service/gpu_memory_buffer_manager.h" | |
9 | |
10 namespace gpu { | |
11 | |
12 GpuControlService::GpuControlService( | |
13 GpuMemoryBufferManagerInterface* gpu_memory_buffer_manager, | |
14 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | |
15 : gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | |
16 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { | |
17 } | |
18 | |
19 GpuControlService::~GpuControlService() { | |
20 } | |
21 | |
22 gfx::GpuMemoryBuffer* GpuControlService::CreateGpuMemoryBuffer( | |
23 size_t width, | |
24 size_t height, | |
25 unsigned internalformat, | |
26 int32* id) { | |
27 *id = -1; | |
28 | |
29 CHECK(gpu_memory_buffer_factory_) << "No GPU memory buffer factory provided"; | |
30 linked_ptr<gfx::GpuMemoryBuffer> buffer = make_linked_ptr( | |
31 gpu_memory_buffer_factory_->CreateGpuMemoryBuffer(width, | |
32 height, | |
33 internalformat)); | |
34 if (!buffer.get()) | |
35 return NULL; | |
36 | |
37 static int32 next_id = 1; | |
no sievers
2013/08/14 03:43:02
Do you think we could either let the client pass i
reveman
2013/08/14 15:48:59
I don't want register of a buffer with the gpu pro
| |
38 *id = next_id++; | |
39 | |
40 if (!RegisterGpuMemoryBuffer(*id, | |
41 buffer->GetHandle(), | |
42 width, | |
43 height, | |
44 internalformat)) { | |
45 *id = -1; | |
46 return NULL; | |
47 } | |
48 | |
49 gpu_memory_buffers_[*id] = buffer; | |
50 return buffer.get(); | |
51 } | |
52 | |
53 void GpuControlService::DestroyGpuMemoryBuffer(int32 id) { | |
54 GpuMemoryBufferMap::iterator it = gpu_memory_buffers_.find(id); | |
55 if (it != gpu_memory_buffers_.end()) | |
56 gpu_memory_buffers_.erase(it); | |
57 | |
58 gpu_memory_buffer_manager_->DestroyGpuMemoryBuffer(id); | |
59 } | |
60 | |
61 bool GpuControlService::RegisterGpuMemoryBuffer( | |
62 int32 id, | |
63 gfx::GpuMemoryBufferHandle buffer, | |
64 size_t width, | |
65 size_t height, | |
66 unsigned internalformat) { | |
67 return gpu_memory_buffer_manager_->RegisterGpuMemoryBuffer(id, | |
68 buffer, | |
69 width, | |
70 height, | |
71 internalformat); | |
72 } | |
73 | |
74 } // namespace gpu | |
OLD | NEW |