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

Side by Side Diff: gpu/command_buffer/tests/gl_manager.cc

Issue 235563002: gpu: Separate GpuControlService from GpuControl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "gpu/command_buffer/tests/gl_manager.h" 5 #include "gpu/command_buffer/tests/gl_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "gpu/command_buffer/client/gles2_implementation.h" 11 #include "gpu/command_buffer/client/gles2_implementation.h"
12 #include "gpu/command_buffer/client/gles2_lib.h" 12 #include "gpu/command_buffer/client/gles2_lib.h"
13 #include "gpu/command_buffer/client/gpu_memory_buffer_factory.h"
13 #include "gpu/command_buffer/client/transfer_buffer.h" 14 #include "gpu/command_buffer/client/transfer_buffer.h"
14 #include "gpu/command_buffer/common/constants.h" 15 #include "gpu/command_buffer/common/constants.h"
15 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 16 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
16 #include "gpu/command_buffer/service/command_buffer_service.h" 17 #include "gpu/command_buffer/service/command_buffer_service.h"
17 #include "gpu/command_buffer/service/context_group.h" 18 #include "gpu/command_buffer/service/context_group.h"
18 #include "gpu/command_buffer/service/gl_context_virtual.h" 19 #include "gpu/command_buffer/service/gl_context_virtual.h"
19 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 20 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
20 #include "gpu/command_buffer/service/gpu_control_service.h" 21 #include "gpu/command_buffer/service/gpu_control_service.h"
21 #include "gpu/command_buffer/service/gpu_scheduler.h" 22 #include "gpu/command_buffer/service/gpu_scheduler.h"
22 #include "gpu/command_buffer/service/image_manager.h" 23 #include "gpu/command_buffer/service/image_manager.h"
(...skipping 14 matching lines...) Expand all
37 : size(4, 4), 38 : size(4, 4),
38 share_group_manager(NULL), 39 share_group_manager(NULL),
39 share_mailbox_manager(NULL), 40 share_mailbox_manager(NULL),
40 virtual_manager(NULL), 41 virtual_manager(NULL),
41 bind_generates_resource(false), 42 bind_generates_resource(false),
42 lose_context_when_out_of_memory(false), 43 lose_context_when_out_of_memory(false),
43 context_lost_allowed(false), 44 context_lost_allowed(false),
44 image_manager(NULL) {} 45 image_manager(NULL) {}
45 46
46 GLManager::GLManager() 47 GLManager::GLManager()
47 : context_lost_allowed_(false) { 48 : context_lost_allowed_(false), gpu_memory_buffer_factory_(NULL) {
48 SetupBaseContext(); 49 SetupBaseContext();
49 } 50 }
50 51
51 GLManager::~GLManager() { 52 GLManager::~GLManager() {
52 --use_count_; 53 --use_count_;
53 if (!use_count_) { 54 if (!use_count_) {
54 if (base_share_group_) { 55 if (base_share_group_) {
55 delete base_context_; 56 delete base_context_;
56 base_context_ = NULL; 57 base_context_ = NULL;
57 } 58 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); 165 ASSERT_TRUE(context_->MakeCurrent(surface_.get()));
165 166
166 ASSERT_TRUE(decoder_->Initialize( 167 ASSERT_TRUE(decoder_->Initialize(
167 surface_.get(), 168 surface_.get(),
168 context_.get(), 169 context_.get(),
169 true, 170 true,
170 options.size, 171 options.size,
171 ::gpu::gles2::DisallowedFeatures(), 172 ::gpu::gles2::DisallowedFeatures(),
172 attribs)) << "could not initialize decoder"; 173 attribs)) << "could not initialize decoder";
173 174
174 gpu_control_.reset( 175 gpu_control_service_.reset(
175 new GpuControlService(decoder_->GetContextGroup()->image_manager(), 176 new GpuControlService(decoder_->GetContextGroup()->image_manager(),
176 options.gpu_memory_buffer_factory,
177 decoder_->GetContextGroup()->mailbox_manager(), 177 decoder_->GetContextGroup()->mailbox_manager(),
178 decoder_->GetQueryManager(), 178 decoder_->GetQueryManager()));
179 decoder_->GetCapabilities())); 179 gpu_memory_buffer_factory_ = options.gpu_memory_buffer_factory;
180 180
181 command_buffer_->SetPutOffsetChangeCallback( 181 command_buffer_->SetPutOffsetChangeCallback(
182 base::Bind(&GLManager::PumpCommands, base::Unretained(this))); 182 base::Bind(&GLManager::PumpCommands, base::Unretained(this)));
183 command_buffer_->SetGetBufferChangeCallback( 183 command_buffer_->SetGetBufferChangeCallback(
184 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this))); 184 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this)));
185 185
186 // Create the GLES2 helper, which writes the command buffer protocol. 186 // Create the GLES2 helper, which writes the command buffer protocol.
187 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); 187 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get()));
188 ASSERT_TRUE(gles2_helper_->Initialize(kCommandBufferSize)); 188 ASSERT_TRUE(gles2_helper_->Initialize(kCommandBufferSize));
189 189
190 // Create a transfer buffer. 190 // Create a transfer buffer.
191 transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get())); 191 transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get()));
192 192
193 // Create the object exposing the OpenGL API. 193 // Create the object exposing the OpenGL API.
194 gles2_implementation_.reset( 194 gles2_implementation_.reset(
195 new gles2::GLES2Implementation(gles2_helper_.get(), 195 new gles2::GLES2Implementation(gles2_helper_.get(),
196 client_share_group, 196 client_share_group,
197 transfer_buffer_.get(), 197 transfer_buffer_.get(),
198 options.bind_generates_resource, 198 options.bind_generates_resource,
199 options.lose_context_when_out_of_memory, 199 options.lose_context_when_out_of_memory,
200 gpu_control_.get())); 200 this));
201 201
202 ASSERT_TRUE(gles2_implementation_->Initialize( 202 ASSERT_TRUE(gles2_implementation_->Initialize(
203 kStartTransferBufferSize, 203 kStartTransferBufferSize,
204 kMinTransferBufferSize, 204 kMinTransferBufferSize,
205 kMaxTransferBufferSize, 205 kMaxTransferBufferSize,
206 gpu::gles2::GLES2Implementation::kNoLimit)) 206 gpu::gles2::GLES2Implementation::kNoLimit))
207 << "Could not init GLES2Implementation"; 207 << "Could not init GLES2Implementation";
208 208
209 MakeCurrent(); 209 MakeCurrent();
210 } 210 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ::gpu::CommandBuffer::State state = command_buffer_->GetState(); 262 ::gpu::CommandBuffer::State state = command_buffer_->GetState();
263 if (!context_lost_allowed_) { 263 if (!context_lost_allowed_) {
264 ASSERT_EQ(::gpu::error::kNoError, state.error); 264 ASSERT_EQ(::gpu::error::kNoError, state.error);
265 } 265 }
266 } 266 }
267 267
268 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) { 268 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) {
269 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); 269 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id);
270 } 270 }
271 271
272 Capabilities GLManager::GetCapabilities() {
273 return decoder_->GetCapabilities();
274 }
275
276 gfx::GpuMemoryBuffer* GLManager::CreateGpuMemoryBuffer(
277 size_t width,
278 size_t height,
279 unsigned internalformat,
280 int32* id) {
281 *id = -1;
282 scoped_ptr<gfx::GpuMemoryBuffer> buffer(
283 gpu_memory_buffer_factory_->CreateGpuMemoryBuffer(
284 width, height, internalformat));
285 if (!buffer.get())
286 return NULL;
287
288 static int32 next_id = 1;
289 *id = next_id++;
290 gpu_control_service_->RegisterGpuMemoryBuffer(
291 *id, buffer->GetHandle(), width, height, internalformat);
292 gfx::GpuMemoryBuffer* raw_buffer = buffer.get();
293 memory_buffers_.add(*id, buffer.Pass());
294 return raw_buffer;
295 }
296
297 void GLManager::DestroyGpuMemoryBuffer(int32 id) {
298 memory_buffers_.erase(id);
299 gpu_control_service_->DestroyGpuMemoryBuffer(id);
300 }
301
302 uint32 GLManager::InsertSyncPoint() {
303 NOTIMPLEMENTED();
no sievers 2014/04/23 23:57:29 Looks like gl_tests do (I mean did, even before yo
boliu 2014/04/24 00:04:02 Can I do this in follow up?
304 return 0u;
305 }
306
307 void GLManager::SignalSyncPoint(uint32 sync_point,
308 const base::Closure& callback) {
309 NOTIMPLEMENTED();
310 }
311
312 void GLManager::SignalQuery(uint32 query, const base::Closure& callback) {
313 NOTIMPLEMENTED();
314 }
315
316 void GLManager::SetSurfaceVisible(bool visible) {
317 NOTIMPLEMENTED();
318 }
319
320 void GLManager::SendManagedMemoryStats(const ManagedMemoryStats& stats) {
321 NOTIMPLEMENTED();
322 }
323
324 void GLManager::Echo(const base::Closure& callback) {
325 NOTIMPLEMENTED();
326 }
327
328 uint32 GLManager::CreateStreamTexture(uint32 texture_id) {
329 NOTIMPLEMENTED();
330 return 0;
331 }
332
272 } // namespace gpu 333 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698