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

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

Issue 1998723002: Move code in ui/gl/* from gfx:: to gl:: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.h ('k') | gpu/command_buffer/tests/gl_unittests_android.cc » ('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 <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <GLES2/gl2extchromium.h> 9 #include <GLES2/gl2extchromium.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 bool mapped_; 164 bool mapped_;
165 IOSurfaceRef iosurface_; 165 IOSurfaceRef iosurface_;
166 const gfx::Size size_; 166 const gfx::Size size_;
167 gfx::BufferFormat format_; 167 gfx::BufferFormat format_;
168 }; 168 };
169 #endif // defined(OS_MACOSX) 169 #endif // defined(OS_MACOSX)
170 170
171 } // namespace 171 } // namespace
172 172
173 int GLManager::use_count_; 173 int GLManager::use_count_;
174 scoped_refptr<gfx::GLShareGroup>* GLManager::base_share_group_; 174 scoped_refptr<gl::GLShareGroup>* GLManager::base_share_group_;
175 scoped_refptr<gfx::GLSurface>* GLManager::base_surface_; 175 scoped_refptr<gl::GLSurface>* GLManager::base_surface_;
176 scoped_refptr<gfx::GLContext>* GLManager::base_context_; 176 scoped_refptr<gl::GLContext>* GLManager::base_context_;
177 177
178 GLManager::Options::Options() 178 GLManager::Options::Options()
179 : size(4, 4), 179 : size(4, 4),
180 sync_point_manager(NULL), 180 sync_point_manager(NULL),
181 share_group_manager(NULL), 181 share_group_manager(NULL),
182 share_mailbox_manager(NULL), 182 share_mailbox_manager(NULL),
183 virtual_manager(NULL), 183 virtual_manager(NULL),
184 bind_generates_resource(false), 184 bind_generates_resource(false),
185 lose_context_when_out_of_memory(false), 185 lose_context_when_out_of_memory(false),
186 context_lost_allowed(false), 186 context_lost_allowed(false),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 context_lost_allowed_ = options.context_lost_allowed; 247 context_lost_allowed_ = options.context_lost_allowed;
248 248
249 gles2::MailboxManager* mailbox_manager = NULL; 249 gles2::MailboxManager* mailbox_manager = NULL;
250 if (options.share_mailbox_manager) { 250 if (options.share_mailbox_manager) {
251 mailbox_manager = options.share_mailbox_manager->mailbox_manager(); 251 mailbox_manager = options.share_mailbox_manager->mailbox_manager();
252 } else if (options.share_group_manager) { 252 } else if (options.share_group_manager) {
253 mailbox_manager = options.share_group_manager->mailbox_manager(); 253 mailbox_manager = options.share_group_manager->mailbox_manager();
254 } 254 }
255 255
256 gfx::GLShareGroup* share_group = NULL; 256 gl::GLShareGroup* share_group = NULL;
257 if (options.share_group_manager) { 257 if (options.share_group_manager) {
258 share_group = options.share_group_manager->share_group(); 258 share_group = options.share_group_manager->share_group();
259 } else if (options.share_mailbox_manager) { 259 } else if (options.share_mailbox_manager) {
260 share_group = options.share_mailbox_manager->share_group(); 260 share_group = options.share_mailbox_manager->share_group();
261 } 261 }
262 262
263 gles2::ContextGroup* context_group = NULL; 263 gles2::ContextGroup* context_group = NULL;
264 scoped_refptr<gles2::ShareGroup> client_share_group; 264 scoped_refptr<gles2::ShareGroup> client_share_group;
265 if (options.share_group_manager) { 265 if (options.share_group_manager) {
266 context_group = options.share_group_manager->decoder_->GetContextGroup(); 266 context_group = options.share_group_manager->decoder_->GetContextGroup();
267 client_share_group = 267 client_share_group =
268 options.share_group_manager->gles2_implementation()->share_group(); 268 options.share_group_manager->gles2_implementation()->share_group();
269 } 269 }
270 270
271 gfx::GLContext* real_gl_context = NULL; 271 gl::GLContext* real_gl_context = NULL;
272 if (options.virtual_manager) { 272 if (options.virtual_manager) {
273 real_gl_context = options.virtual_manager->context(); 273 real_gl_context = options.virtual_manager->context();
274 } 274 }
275 275
276 mailbox_manager_ = 276 mailbox_manager_ =
277 mailbox_manager ? mailbox_manager : new gles2::MailboxManagerImpl; 277 mailbox_manager ? mailbox_manager : new gles2::MailboxManagerImpl;
278 share_group_ = 278 share_group_ = share_group ? share_group : new gl::GLShareGroup;
279 share_group ? share_group : new gfx::GLShareGroup;
280 279
281 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu); 280 gl::GpuPreference gpu_preference(gl::PreferDiscreteGpu);
282 gles2::ContextCreationAttribHelper attribs; 281 gles2::ContextCreationAttribHelper attribs;
283 attribs.red_size = 8; 282 attribs.red_size = 8;
284 attribs.green_size = 8; 283 attribs.green_size = 8;
285 attribs.blue_size = 8; 284 attribs.blue_size = 8;
286 attribs.alpha_size = 8; 285 attribs.alpha_size = 8;
287 attribs.depth_size = 16; 286 attribs.depth_size = 16;
288 attribs.stencil_size = 8; 287 attribs.stencil_size = 8;
289 attribs.context_type = options.context_type; 288 attribs.context_type = options.context_type;
290 attribs.samples = options.multisampled ? 4 : 0; 289 attribs.samples = options.multisampled ? 4 : 0;
291 attribs.sample_buffers = options.multisampled ? 1 : 0; 290 attribs.sample_buffers = options.multisampled ? 1 : 0;
(...skipping 18 matching lines...) Expand all
310 309
311 executor_.reset(new CommandExecutor(command_buffer_.get(), decoder_.get(), 310 executor_.reset(new CommandExecutor(command_buffer_.get(), decoder_.get(),
312 decoder_.get())); 311 decoder_.get()));
313 312
314 decoder_->set_engine(executor_.get()); 313 decoder_->set_engine(executor_.get());
315 314
316 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); 315 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size());
317 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface"; 316 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface";
318 317
319 if (base_context_) { 318 if (base_context_) {
320 context_ = scoped_refptr<gfx::GLContext>(new gpu::GLContextVirtual( 319 context_ = scoped_refptr<gl::GLContext>(new gpu::GLContextVirtual(
321 share_group_.get(), base_context_->get(), decoder_->AsWeakPtr())); 320 share_group_.get(), base_context_->get(), decoder_->AsWeakPtr()));
322 ASSERT_TRUE(context_->Initialize( 321 ASSERT_TRUE(context_->Initialize(surface_.get(), gl::PreferIntegratedGpu));
323 surface_.get(), gfx::PreferIntegratedGpu));
324 } else { 322 } else {
325 if (real_gl_context) { 323 if (real_gl_context) {
326 context_ = scoped_refptr<gfx::GLContext>(new gpu::GLContextVirtual( 324 context_ = scoped_refptr<gl::GLContext>(new gpu::GLContextVirtual(
327 share_group_.get(), real_gl_context, decoder_->AsWeakPtr())); 325 share_group_.get(), real_gl_context, decoder_->AsWeakPtr()));
328 ASSERT_TRUE(context_->Initialize( 326 ASSERT_TRUE(
329 surface_.get(), gfx::PreferIntegratedGpu)); 327 context_->Initialize(surface_.get(), gl::PreferIntegratedGpu));
330 } else { 328 } else {
331 context_ = gl::init::CreateGLContext(share_group_.get(), surface_.get(), 329 context_ = gl::init::CreateGLContext(share_group_.get(), surface_.get(),
332 gpu_preference); 330 gpu_preference);
333 } 331 }
334 } 332 }
335 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context"; 333 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context";
336 334
337 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); 335 ASSERT_TRUE(context_->MakeCurrent(surface_.get()));
338 336
339 if (!decoder_->Initialize(surface_.get(), context_.get(), true, options.size, 337 if (!decoder_->Initialize(surface_.get(), context_.get(), true, options.size,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 kStartTransferBufferSize, kMinTransferBufferSize, kMaxTransferBufferSize, 379 kStartTransferBufferSize, kMinTransferBufferSize, kMaxTransferBufferSize,
382 SharedMemoryLimits::kNoLimit)) 380 SharedMemoryLimits::kNoLimit))
383 << "Could not init GLES2Implementation"; 381 << "Could not init GLES2Implementation";
384 382
385 MakeCurrent(); 383 MakeCurrent();
386 } 384 }
387 385
388 void GLManager::SetupBaseContext() { 386 void GLManager::SetupBaseContext() {
389 if (use_count_) { 387 if (use_count_) {
390 #if defined(OS_ANDROID) 388 #if defined(OS_ANDROID)
391 base_share_group_ = new scoped_refptr<gfx::GLShareGroup>( 389 base_share_group_ =
392 new gfx::GLShareGroup); 390 new scoped_refptr<gl::GLShareGroup>(new gl::GLShareGroup);
393 gfx::Size size(4, 4); 391 gfx::Size size(4, 4);
394 base_surface_ = new scoped_refptr<gfx::GLSurface>( 392 base_surface_ = new scoped_refptr<gl::GLSurface>(
395 gl::init::CreateOffscreenGLSurface(size)); 393 gl::init::CreateOffscreenGLSurface(size));
396 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu); 394 gl::GpuPreference gpu_preference(gl::PreferDiscreteGpu);
397 base_context_ = 395 base_context_ = new scoped_refptr<gl::GLContext>(gl::init::CreateGLContext(
398 new scoped_refptr<gfx::GLContext>(gl::init::CreateGLContext( 396 base_share_group_->get(), base_surface_->get(), gpu_preference));
399 base_share_group_->get(), base_surface_->get(), gpu_preference));
400 #endif 397 #endif
401 } 398 }
402 ++use_count_; 399 ++use_count_;
403 } 400 }
404 401
405 void GLManager::OnFenceSyncRelease(uint64_t release) { 402 void GLManager::OnFenceSyncRelease(uint64_t release) {
406 DCHECK(sync_point_client_); 403 DCHECK(sync_point_client_);
407 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); 404 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release));
408 sync_point_client_->ReleaseFenceSync(release); 405 sync_point_client_->ReleaseFenceSync(release);
409 } 406 }
(...skipping 11 matching lines...) Expand all
421 // GLManager does not support being multithreaded at this point, so the fence 418 // GLManager does not support being multithreaded at this point, so the fence
422 // sync must be released by the time wait is called. 419 // sync must be released by the time wait is called.
423 DCHECK(release_state->IsFenceSyncReleased(release)); 420 DCHECK(release_state->IsFenceSyncReleased(release));
424 return true; 421 return true;
425 } 422 }
426 423
427 void GLManager::MakeCurrent() { 424 void GLManager::MakeCurrent() {
428 ::gles2::SetGLContext(gles2_implementation_.get()); 425 ::gles2::SetGLContext(gles2_implementation_.get());
429 } 426 }
430 427
431 void GLManager::SetSurface(gfx::GLSurface* surface) { 428 void GLManager::SetSurface(gl::GLSurface* surface) {
432 decoder_->SetSurface(surface); 429 decoder_->SetSurface(surface);
433 } 430 }
434 431
435 void GLManager::Destroy() { 432 void GLManager::Destroy() {
436 if (gles2_implementation_.get()) { 433 if (gles2_implementation_.get()) {
437 MakeCurrent(); 434 MakeCurrent();
438 EXPECT_TRUE(glGetError() == GL_NONE); 435 EXPECT_TRUE(glGetError() == GL_NONE);
439 gles2_implementation_->Flush(); 436 gles2_implementation_->Flush();
440 gles2_implementation_.reset(); 437 gles2_implementation_.reset();
441 } 438 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 623
627 // Something went wrong, just run the callback now. 624 // Something went wrong, just run the callback now.
628 callback.Run(); 625 callback.Run();
629 } 626 }
630 627
631 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { 628 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) {
632 return false; 629 return false;
633 } 630 }
634 631
635 } // namespace gpu 632 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.h ('k') | gpu/command_buffer/tests/gl_unittests_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698