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

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

Issue 20017005: gpu: Refactor GpuMemoryBuffer framework for multi-process support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add GpuControl interface Created 7 years, 4 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/transfer_buffer.h" 13 #include "gpu/command_buffer/client/transfer_buffer.h"
14 #include "gpu/command_buffer/common/constants.h" 14 #include "gpu/command_buffer/common/constants.h"
15 #include "gpu/command_buffer/service/command_buffer_service.h" 15 #include "gpu/command_buffer/service/command_buffer_service.h"
16 #include "gpu/command_buffer/service/context_group.h" 16 #include "gpu/command_buffer/service/context_group.h"
17 #include "gpu/command_buffer/service/gl_context_virtual.h" 17 #include "gpu/command_buffer/service/gl_context_virtual.h"
18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
19 #include "gpu/command_buffer/service/gpu_control_service.h"
19 #include "gpu/command_buffer/service/gpu_scheduler.h" 20 #include "gpu/command_buffer/service/gpu_scheduler.h"
20 #include "gpu/command_buffer/service/image_manager.h" 21 #include "gpu/command_buffer/service/image_manager.h"
21 #include "gpu/command_buffer/service/mailbox_manager.h" 22 #include "gpu/command_buffer/service/mailbox_manager.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 #include "ui/gl/gl_context.h" 24 #include "ui/gl/gl_context.h"
24 #include "ui/gl/gl_share_group.h" 25 #include "ui/gl/gl_share_group.h"
25 #include "ui/gl/gl_surface.h" 26 #include "ui/gl/gl_surface.h"
26 27
27 namespace gpu { 28 namespace gpu {
28 29
29 int GLManager::use_count_; 30 int GLManager::use_count_;
30 scoped_refptr<gfx::GLShareGroup>* GLManager::base_share_group_; 31 scoped_refptr<gfx::GLShareGroup>* GLManager::base_share_group_;
31 scoped_refptr<gfx::GLSurface>* GLManager::base_surface_; 32 scoped_refptr<gfx::GLSurface>* GLManager::base_surface_;
32 scoped_refptr<gfx::GLContext>* GLManager::base_context_; 33 scoped_refptr<gfx::GLContext>* GLManager::base_context_;
33 34
34 GLManager::Options::Options() 35 GLManager::Options::Options()
35 : size(4, 4), 36 : size(4, 4),
36 share_group_manager(NULL), 37 share_group_manager(NULL),
37 share_mailbox_manager(NULL), 38 share_mailbox_manager(NULL),
38 virtual_manager(NULL), 39 virtual_manager(NULL),
39 bind_generates_resource(false), 40 bind_generates_resource(false),
40 context_lost_allowed(false), 41 context_lost_allowed(false),
41 image_manager(NULL), 42 image_manager(NULL) {
42 image_factory(NULL) {
43 } 43 }
44 44
45 GLManager::GLManager() 45 GLManager::GLManager()
46 : context_lost_allowed_(false) { 46 : context_lost_allowed_(false) {
47 SetupBaseContext(); 47 SetupBaseContext();
48 } 48 }
49 49
50 GLManager::~GLManager() { 50 GLManager::~GLManager() {
51 --use_count_; 51 --use_count_;
52 if (!use_count_) { 52 if (!use_count_) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 options.bind_generates_resource); 136 options.bind_generates_resource);
137 } 137 }
138 138
139 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group)); 139 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group));
140 140
141 command_buffer_.reset(new CommandBufferService( 141 command_buffer_.reset(new CommandBufferService(
142 decoder_->GetContextGroup()->transfer_buffer_manager())); 142 decoder_->GetContextGroup()->transfer_buffer_manager()));
143 ASSERT_TRUE(command_buffer_->Initialize()) 143 ASSERT_TRUE(command_buffer_->Initialize())
144 << "could not create command buffer service"; 144 << "could not create command buffer service";
145 145
146 gpu_control_.reset(
147 new GpuControlService(decoder_->GetContextGroup()->image_manager(),
148 options.gpu_memory_buffer_factory));
149
146 gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(), 150 gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(),
147 decoder_.get(), 151 decoder_.get(),
148 decoder_.get())); 152 decoder_.get()));
149 153
150 decoder_->set_engine(gpu_scheduler_.get()); 154 decoder_->set_engine(gpu_scheduler_.get());
151 155
152 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(options.size); 156 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(options.size);
153 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface"; 157 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface";
154 158
155 if (real_gl_context) { 159 if (real_gl_context) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 197
194 // Create a transfer buffer. 198 // Create a transfer buffer.
195 transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get())); 199 transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get()));
196 200
197 // Create the object exposing the OpenGL API. 201 // Create the object exposing the OpenGL API.
198 gles2_implementation_.reset(new gles2::GLES2Implementation( 202 gles2_implementation_.reset(new gles2::GLES2Implementation(
199 gles2_helper_.get(), 203 gles2_helper_.get(),
200 client_share_group, 204 client_share_group,
201 transfer_buffer_.get(), 205 transfer_buffer_.get(),
202 options.bind_generates_resource, 206 options.bind_generates_resource,
203 options.image_factory)); 207 gpu_control_.get()));
204 208
205 ASSERT_TRUE(gles2_implementation_->Initialize( 209 ASSERT_TRUE(gles2_implementation_->Initialize(
206 kStartTransferBufferSize, 210 kStartTransferBufferSize,
207 kMinTransferBufferSize, 211 kMinTransferBufferSize,
208 kMaxTransferBufferSize)) << "Could not init GLES2Implementation"; 212 kMaxTransferBufferSize)) << "Could not init GLES2Implementation";
209 213
210 MakeCurrent(); 214 MakeCurrent();
211 } 215 }
212 216
213 void GLManager::SetupBaseContext() { 217 void GLManager::SetupBaseContext() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 if (!context_lost_allowed_) { 268 if (!context_lost_allowed_) {
265 ASSERT_EQ(::gpu::error::kNoError, state.error); 269 ASSERT_EQ(::gpu::error::kNoError, state.error);
266 } 270 }
267 } 271 }
268 272
269 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) { 273 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) {
270 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); 274 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id);
271 } 275 }
272 276
273 } // namespace gpu 277 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698