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

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: Remove MailboxManager Created 6 years, 7 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_->GetQueryManager()));
177 decoder_->GetContextGroup()->mailbox_manager(), 178 gpu_memory_buffer_factory_ = options.gpu_memory_buffer_factory;
178 decoder_->GetQueryManager(),
179 decoder_->GetCapabilities()));
180 179
181 command_buffer_->SetPutOffsetChangeCallback( 180 command_buffer_->SetPutOffsetChangeCallback(
182 base::Bind(&GLManager::PumpCommands, base::Unretained(this))); 181 base::Bind(&GLManager::PumpCommands, base::Unretained(this)));
183 command_buffer_->SetGetBufferChangeCallback( 182 command_buffer_->SetGetBufferChangeCallback(
184 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this))); 183 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this)));
185 184
186 // Create the GLES2 helper, which writes the command buffer protocol. 185 // Create the GLES2 helper, which writes the command buffer protocol.
187 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); 186 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get()));
188 ASSERT_TRUE(gles2_helper_->Initialize(kCommandBufferSize)); 187 ASSERT_TRUE(gles2_helper_->Initialize(kCommandBufferSize));
189 188
190 // Create a transfer buffer. 189 // Create a transfer buffer.
191 transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get())); 190 transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get()));
192 191
193 // Create the object exposing the OpenGL API. 192 // Create the object exposing the OpenGL API.
194 gles2_implementation_.reset( 193 gles2_implementation_.reset(
195 new gles2::GLES2Implementation(gles2_helper_.get(), 194 new gles2::GLES2Implementation(gles2_helper_.get(),
196 client_share_group, 195 client_share_group,
197 transfer_buffer_.get(), 196 transfer_buffer_.get(),
198 options.bind_generates_resource, 197 options.bind_generates_resource,
199 options.lose_context_when_out_of_memory, 198 options.lose_context_when_out_of_memory,
200 gpu_control_.get())); 199 this));
201 200
202 ASSERT_TRUE(gles2_implementation_->Initialize( 201 ASSERT_TRUE(gles2_implementation_->Initialize(
203 kStartTransferBufferSize, 202 kStartTransferBufferSize,
204 kMinTransferBufferSize, 203 kMinTransferBufferSize,
205 kMaxTransferBufferSize, 204 kMaxTransferBufferSize,
206 gpu::gles2::GLES2Implementation::kNoLimit)) 205 gpu::gles2::GLES2Implementation::kNoLimit))
207 << "Could not init GLES2Implementation"; 206 << "Could not init GLES2Implementation";
208 207
209 MakeCurrent(); 208 MakeCurrent();
210 } 209 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ::gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 261 ::gpu::CommandBuffer::State state = command_buffer_->GetLastState();
263 if (!context_lost_allowed_) { 262 if (!context_lost_allowed_) {
264 ASSERT_EQ(::gpu::error::kNoError, state.error); 263 ASSERT_EQ(::gpu::error::kNoError, state.error);
265 } 264 }
266 } 265 }
267 266
268 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) { 267 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) {
269 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); 268 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id);
270 } 269 }
271 270
271 Capabilities GLManager::GetCapabilities() {
272 return decoder_->GetCapabilities();
273 }
274
275 gfx::GpuMemoryBuffer* GLManager::CreateGpuMemoryBuffer(
276 size_t width,
277 size_t height,
278 unsigned internalformat,
279 int32* id) {
280 *id = -1;
281 scoped_ptr<gfx::GpuMemoryBuffer> buffer(
282 gpu_memory_buffer_factory_->CreateGpuMemoryBuffer(
283 width, height, internalformat));
284 if (!buffer.get())
285 return NULL;
286
287 static int32 next_id = 1;
288 *id = next_id++;
289 gpu_control_service_->RegisterGpuMemoryBuffer(
290 *id, buffer->GetHandle(), width, height, internalformat);
291 gfx::GpuMemoryBuffer* raw_buffer = buffer.get();
292 memory_buffers_.add(*id, buffer.Pass());
293 return raw_buffer;
294 }
295
296 void GLManager::DestroyGpuMemoryBuffer(int32 id) {
297 memory_buffers_.erase(id);
298 gpu_control_service_->UnregisterGpuMemoryBuffer(id);
299 }
300
301 uint32 GLManager::InsertSyncPoint() {
302 NOTIMPLEMENTED();
303 return 0u;
304 }
305
306 void GLManager::SignalSyncPoint(uint32 sync_point,
307 const base::Closure& callback) {
308 NOTIMPLEMENTED();
309 }
310
311 void GLManager::SignalQuery(uint32 query, const base::Closure& callback) {
312 NOTIMPLEMENTED();
313 }
314
315 void GLManager::SetSurfaceVisible(bool visible) {
316 NOTIMPLEMENTED();
317 }
318
319 void GLManager::SendManagedMemoryStats(const ManagedMemoryStats& stats) {
320 NOTIMPLEMENTED();
321 }
322
323 void GLManager::Echo(const base::Closure& callback) {
324 NOTIMPLEMENTED();
325 }
326
327 uint32 GLManager::CreateStreamTexture(uint32 texture_id) {
328 NOTIMPLEMENTED();
329 return 0;
330 }
331
272 } // namespace gpu 332 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698