| OLD | NEW |
| 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 16 matching lines...) Expand all Loading... |
| 27 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 27 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 28 #include "gpu/command_buffer/common/sync_token.h" | 28 #include "gpu/command_buffer/common/sync_token.h" |
| 29 #include "gpu/command_buffer/service/command_buffer_service.h" | 29 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 30 #include "gpu/command_buffer/service/command_executor.h" | 30 #include "gpu/command_buffer/service/command_executor.h" |
| 31 #include "gpu/command_buffer/service/context_group.h" | 31 #include "gpu/command_buffer/service/context_group.h" |
| 32 #include "gpu/command_buffer/service/gl_context_virtual.h" | 32 #include "gpu/command_buffer/service/gl_context_virtual.h" |
| 33 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 33 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 34 #include "gpu/command_buffer/service/image_manager.h" | 34 #include "gpu/command_buffer/service/image_manager.h" |
| 35 #include "gpu/command_buffer/service/mailbox_manager_impl.h" | 35 #include "gpu/command_buffer/service/mailbox_manager_impl.h" |
| 36 #include "gpu/command_buffer/service/memory_tracking.h" | 36 #include "gpu/command_buffer/service/memory_tracking.h" |
| 37 #include "gpu/command_buffer/service/service_utils.h" | |
| 38 #include "gpu/command_buffer/service/sync_point_manager.h" | 37 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 39 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 38 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 40 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
| 41 #include "ui/gfx/buffer_format_util.h" | 40 #include "ui/gfx/buffer_format_util.h" |
| 42 #include "ui/gfx/gpu_memory_buffer.h" | 41 #include "ui/gfx/gpu_memory_buffer.h" |
| 43 #include "ui/gl/gl_context.h" | 42 #include "ui/gl/gl_context.h" |
| 44 #include "ui/gl/gl_image_ref_counted_memory.h" | 43 #include "ui/gl/gl_image_ref_counted_memory.h" |
| 45 #include "ui/gl/gl_share_group.h" | 44 #include "ui/gl/gl_share_group.h" |
| 46 #include "ui/gl/gl_surface.h" | 45 #include "ui/gl/gl_surface.h" |
| 47 #include "ui/gl/init/gl_factory.h" | 46 #include "ui/gl/init/gl_factory.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 decoder_.get())); | 318 decoder_.get())); |
| 320 | 319 |
| 321 decoder_->set_engine(executor_.get()); | 320 decoder_->set_engine(executor_.get()); |
| 322 | 321 |
| 323 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); | 322 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); |
| 324 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface"; | 323 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface"; |
| 325 | 324 |
| 326 if (base_context_) { | 325 if (base_context_) { |
| 327 context_ = scoped_refptr<gl::GLContext>(new gpu::GLContextVirtual( | 326 context_ = scoped_refptr<gl::GLContext>(new gpu::GLContextVirtual( |
| 328 share_group_.get(), base_context_->get(), decoder_->AsWeakPtr())); | 327 share_group_.get(), base_context_->get(), decoder_->AsWeakPtr())); |
| 329 ASSERT_TRUE(context_->Initialize( | 328 ASSERT_TRUE(context_->Initialize(surface_.get(), attribs.gpu_preference)); |
| 330 surface_.get(), | |
| 331 GenerateGLContextAttribs(attribs, context_group->gpu_preferences()))); | |
| 332 } else { | 329 } else { |
| 333 if (real_gl_context) { | 330 if (real_gl_context) { |
| 334 context_ = scoped_refptr<gl::GLContext>(new gpu::GLContextVirtual( | 331 context_ = scoped_refptr<gl::GLContext>(new gpu::GLContextVirtual( |
| 335 share_group_.get(), real_gl_context, decoder_->AsWeakPtr())); | 332 share_group_.get(), real_gl_context, decoder_->AsWeakPtr())); |
| 336 ASSERT_TRUE(context_->Initialize( | 333 ASSERT_TRUE( |
| 337 surface_.get(), | 334 context_->Initialize(surface_.get(), attribs.gpu_preference)); |
| 338 GenerateGLContextAttribs(attribs, context_group->gpu_preferences()))); | |
| 339 } else { | 335 } else { |
| 340 context_ = gl::init::CreateGLContext( | 336 context_ = gl::init::CreateGLContext(share_group_.get(), surface_.get(), |
| 341 share_group_.get(), surface_.get(), | 337 attribs.gpu_preference); |
| 342 GenerateGLContextAttribs(attribs, context_group->gpu_preferences())); | |
| 343 } | 338 } |
| 344 } | 339 } |
| 345 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context"; | 340 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context"; |
| 346 | 341 |
| 347 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); | 342 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); |
| 348 | 343 |
| 349 if (!decoder_->Initialize(surface_.get(), context_.get(), true, | 344 if (!decoder_->Initialize(surface_.get(), context_.get(), true, |
| 350 ::gpu::gles2::DisallowedFeatures(), attribs)) { | 345 ::gpu::gles2::DisallowedFeatures(), attribs)) { |
| 351 return; | 346 return; |
| 352 } | 347 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } | 391 } |
| 397 | 392 |
| 398 void GLManager::SetupBaseContext() { | 393 void GLManager::SetupBaseContext() { |
| 399 if (use_count_) { | 394 if (use_count_) { |
| 400 #if defined(OS_ANDROID) | 395 #if defined(OS_ANDROID) |
| 401 base_share_group_ = | 396 base_share_group_ = |
| 402 new scoped_refptr<gl::GLShareGroup>(new gl::GLShareGroup); | 397 new scoped_refptr<gl::GLShareGroup>(new gl::GLShareGroup); |
| 403 gfx::Size size(4, 4); | 398 gfx::Size size(4, 4); |
| 404 base_surface_ = new scoped_refptr<gl::GLSurface>( | 399 base_surface_ = new scoped_refptr<gl::GLSurface>( |
| 405 gl::init::CreateOffscreenGLSurface(size)); | 400 gl::init::CreateOffscreenGLSurface(size)); |
| 401 gl::GpuPreference gpu_preference(gl::PreferDiscreteGpu); |
| 406 base_context_ = new scoped_refptr<gl::GLContext>(gl::init::CreateGLContext( | 402 base_context_ = new scoped_refptr<gl::GLContext>(gl::init::CreateGLContext( |
| 407 base_share_group_->get(), base_surface_->get(), | 403 base_share_group_->get(), base_surface_->get(), gpu_preference)); |
| 408 gl::GLContextAttribs())); | |
| 409 #endif | 404 #endif |
| 410 } | 405 } |
| 411 ++use_count_; | 406 ++use_count_; |
| 412 } | 407 } |
| 413 | 408 |
| 414 void GLManager::OnFenceSyncRelease(uint64_t release) { | 409 void GLManager::OnFenceSyncRelease(uint64_t release) { |
| 415 DCHECK(sync_point_client_); | 410 DCHECK(sync_point_client_); |
| 416 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); | 411 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); |
| 417 sync_point_client_->ReleaseFenceSync(release); | 412 sync_point_client_->ReleaseFenceSync(release); |
| 418 } | 413 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 | 630 |
| 636 // Something went wrong, just run the callback now. | 631 // Something went wrong, just run the callback now. |
| 637 callback.Run(); | 632 callback.Run(); |
| 638 } | 633 } |
| 639 | 634 |
| 640 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { | 635 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { |
| 641 return false; | 636 return false; |
| 642 } | 637 } |
| 643 | 638 |
| 644 } // namespace gpu | 639 } // namespace gpu |
| OLD | NEW |