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

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: cc_perftests build fix 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
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.h ('k') | gpu/command_buffer_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 client_share_group = 94 client_share_group =
95 options.share_group_manager->gles2_implementation()->share_group(); 95 options.share_group_manager->gles2_implementation()->share_group();
96 } 96 }
97 97
98 gfx::GLContext* real_gl_context = NULL; 98 gfx::GLContext* real_gl_context = NULL;
99 if (options.virtual_manager) { 99 if (options.virtual_manager) {
100 real_gl_context = options.virtual_manager->context(); 100 real_gl_context = options.virtual_manager->context();
101 } 101 }
102 102
103 // From <EGL/egl.h>. 103 // From <EGL/egl.h>.
104 #ifndef EGL_ALPHA_SIZE
piman 2013/08/14 20:43:26 Why is this needed suddenly?
reveman 2013/08/15 15:00:54 this file now has to include gpu_control_service.h
104 const int32 EGL_ALPHA_SIZE = 0x3021; 105 const int32 EGL_ALPHA_SIZE = 0x3021;
106 #endif
107 #ifndef EGL_BLUE_SIZE
105 const int32 EGL_BLUE_SIZE = 0x3022; 108 const int32 EGL_BLUE_SIZE = 0x3022;
109 #endif
110 #ifndef EGL_GREEN_SIZE
106 const int32 EGL_GREEN_SIZE = 0x3023; 111 const int32 EGL_GREEN_SIZE = 0x3023;
112 #endif
113 #ifndef EGL_RED_SIZE
107 const int32 EGL_RED_SIZE = 0x3024; 114 const int32 EGL_RED_SIZE = 0x3024;
115 #endif
116 #ifndef EGL_DEPTH_SIZE
108 const int32 EGL_DEPTH_SIZE = 0x3025; 117 const int32 EGL_DEPTH_SIZE = 0x3025;
118 #endif
119 #ifndef EGL_NONE
109 const int32 EGL_NONE = 0x3038; 120 const int32 EGL_NONE = 0x3038;
121 #endif
110 122
111 mailbox_manager_ = 123 mailbox_manager_ =
112 mailbox_manager ? mailbox_manager : new gles2::MailboxManager; 124 mailbox_manager ? mailbox_manager : new gles2::MailboxManager;
113 share_group_ = 125 share_group_ =
114 share_group ? share_group : new gfx::GLShareGroup; 126 share_group ? share_group : new gfx::GLShareGroup;
115 127
116 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu); 128 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu);
117 const char* allowed_extensions = "*"; 129 const char* allowed_extensions = "*";
118 std::vector<int32> attribs; 130 std::vector<int32> attribs;
119 attribs.push_back(EGL_RED_SIZE); 131 attribs.push_back(EGL_RED_SIZE);
(...skipping 16 matching lines...) Expand all
136 options.bind_generates_resource); 148 options.bind_generates_resource);
137 } 149 }
138 150
139 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group)); 151 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group));
140 152
141 command_buffer_.reset(new CommandBufferService( 153 command_buffer_.reset(new CommandBufferService(
142 decoder_->GetContextGroup()->transfer_buffer_manager())); 154 decoder_->GetContextGroup()->transfer_buffer_manager()));
143 ASSERT_TRUE(command_buffer_->Initialize()) 155 ASSERT_TRUE(command_buffer_->Initialize())
144 << "could not create command buffer service"; 156 << "could not create command buffer service";
145 157
158 gpu_control_.reset(
159 new GpuControlService(decoder_->GetContextGroup()->image_manager(),
160 options.gpu_memory_buffer_factory));
161
146 gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(), 162 gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(),
147 decoder_.get(), 163 decoder_.get(),
148 decoder_.get())); 164 decoder_.get()));
149 165
150 decoder_->set_engine(gpu_scheduler_.get()); 166 decoder_->set_engine(gpu_scheduler_.get());
151 167
152 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(options.size); 168 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(options.size);
153 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface"; 169 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface";
154 170
155 if (real_gl_context) { 171 if (real_gl_context) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 209
194 // Create a transfer buffer. 210 // Create a transfer buffer.
195 transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get())); 211 transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get()));
196 212
197 // Create the object exposing the OpenGL API. 213 // Create the object exposing the OpenGL API.
198 gles2_implementation_.reset(new gles2::GLES2Implementation( 214 gles2_implementation_.reset(new gles2::GLES2Implementation(
199 gles2_helper_.get(), 215 gles2_helper_.get(),
200 client_share_group, 216 client_share_group,
201 transfer_buffer_.get(), 217 transfer_buffer_.get(),
202 options.bind_generates_resource, 218 options.bind_generates_resource,
203 options.image_factory)); 219 gpu_control_.get()));
204 220
205 ASSERT_TRUE(gles2_implementation_->Initialize( 221 ASSERT_TRUE(gles2_implementation_->Initialize(
206 kStartTransferBufferSize, 222 kStartTransferBufferSize,
207 kMinTransferBufferSize, 223 kMinTransferBufferSize,
208 kMaxTransferBufferSize)) << "Could not init GLES2Implementation"; 224 kMaxTransferBufferSize)) << "Could not init GLES2Implementation";
209 225
210 MakeCurrent(); 226 MakeCurrent();
211 } 227 }
212 228
213 void GLManager::SetupBaseContext() { 229 void GLManager::SetupBaseContext() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 if (!context_lost_allowed_) { 280 if (!context_lost_allowed_) {
265 ASSERT_EQ(::gpu::error::kNoError, state.error); 281 ASSERT_EQ(::gpu::error::kNoError, state.error);
266 } 282 }
267 } 283 }
268 284
269 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) { 285 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) {
270 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); 286 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id);
271 } 287 }
272 288
273 } // namespace gpu 289 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.h ('k') | gpu/command_buffer_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698