| 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 25 matching lines...) Expand all Loading... |
| 36 #include "gpu/command_buffer/service/memory_tracking.h" | 36 #include "gpu/command_buffer/service/memory_tracking.h" |
| 37 #include "gpu/command_buffer/service/sync_point_manager.h" | 37 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 38 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 38 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
| 40 #include "ui/gfx/buffer_format_util.h" | 40 #include "ui/gfx/buffer_format_util.h" |
| 41 #include "ui/gfx/gpu_memory_buffer.h" | 41 #include "ui/gfx/gpu_memory_buffer.h" |
| 42 #include "ui/gl/gl_context.h" | 42 #include "ui/gl/gl_context.h" |
| 43 #include "ui/gl/gl_image_ref_counted_memory.h" | 43 #include "ui/gl/gl_image_ref_counted_memory.h" |
| 44 #include "ui/gl/gl_share_group.h" | 44 #include "ui/gl/gl_share_group.h" |
| 45 #include "ui/gl/gl_surface.h" | 45 #include "ui/gl/gl_surface.h" |
| 46 #include "ui/gl/init/gl_factory.h" |
| 46 | 47 |
| 47 #if defined(OS_MACOSX) | 48 #if defined(OS_MACOSX) |
| 48 #include "ui/gfx/mac/io_surface.h" | 49 #include "ui/gfx/mac/io_surface.h" |
| 49 #include "ui/gl/gl_image_io_surface.h" | 50 #include "ui/gl/gl_image_io_surface.h" |
| 50 #endif | 51 #endif |
| 51 | 52 |
| 52 namespace gpu { | 53 namespace gpu { |
| 53 namespace { | 54 namespace { |
| 54 | 55 |
| 55 uint64_t g_next_command_buffer_id = 0; | 56 uint64_t g_next_command_buffer_id = 0; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 decoder_->SetForceShaderNameHashingForTest(true); | 306 decoder_->SetForceShaderNameHashingForTest(true); |
| 306 } | 307 } |
| 307 command_buffer_.reset(new CommandBufferService( | 308 command_buffer_.reset(new CommandBufferService( |
| 308 decoder_->GetContextGroup()->transfer_buffer_manager())); | 309 decoder_->GetContextGroup()->transfer_buffer_manager())); |
| 309 | 310 |
| 310 executor_.reset(new CommandExecutor(command_buffer_.get(), decoder_.get(), | 311 executor_.reset(new CommandExecutor(command_buffer_.get(), decoder_.get(), |
| 311 decoder_.get())); | 312 decoder_.get())); |
| 312 | 313 |
| 313 decoder_->set_engine(executor_.get()); | 314 decoder_->set_engine(executor_.get()); |
| 314 | 315 |
| 315 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); | 316 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); |
| 316 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface"; | 317 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface"; |
| 317 | 318 |
| 318 if (base_context_) { | 319 if (base_context_) { |
| 319 context_ = scoped_refptr<gfx::GLContext>(new gpu::GLContextVirtual( | 320 context_ = scoped_refptr<gfx::GLContext>(new gpu::GLContextVirtual( |
| 320 share_group_.get(), base_context_->get(), decoder_->AsWeakPtr())); | 321 share_group_.get(), base_context_->get(), decoder_->AsWeakPtr())); |
| 321 ASSERT_TRUE(context_->Initialize( | 322 ASSERT_TRUE(context_->Initialize( |
| 322 surface_.get(), gfx::PreferIntegratedGpu)); | 323 surface_.get(), gfx::PreferIntegratedGpu)); |
| 323 } else { | 324 } else { |
| 324 if (real_gl_context) { | 325 if (real_gl_context) { |
| 325 context_ = scoped_refptr<gfx::GLContext>(new gpu::GLContextVirtual( | 326 context_ = scoped_refptr<gfx::GLContext>(new gpu::GLContextVirtual( |
| 326 share_group_.get(), real_gl_context, decoder_->AsWeakPtr())); | 327 share_group_.get(), real_gl_context, decoder_->AsWeakPtr())); |
| 327 ASSERT_TRUE(context_->Initialize( | 328 ASSERT_TRUE(context_->Initialize( |
| 328 surface_.get(), gfx::PreferIntegratedGpu)); | 329 surface_.get(), gfx::PreferIntegratedGpu)); |
| 329 } else { | 330 } else { |
| 330 context_ = gfx::GLContext::CreateGLContext(share_group_.get(), | 331 context_ = gl::init::CreateGLContext(share_group_.get(), surface_.get(), |
| 331 surface_.get(), | 332 gpu_preference); |
| 332 gpu_preference); | |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context"; | 335 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context"; |
| 336 | 336 |
| 337 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); | 337 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); |
| 338 | 338 |
| 339 if (!decoder_->Initialize(surface_.get(), context_.get(), true, options.size, | 339 if (!decoder_->Initialize(surface_.get(), context_.get(), true, options.size, |
| 340 ::gpu::gles2::DisallowedFeatures(), attribs)) { | 340 ::gpu::gles2::DisallowedFeatures(), attribs)) { |
| 341 return; | 341 return; |
| 342 } | 342 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 MakeCurrent(); | 385 MakeCurrent(); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void GLManager::SetupBaseContext() { | 388 void GLManager::SetupBaseContext() { |
| 389 if (use_count_) { | 389 if (use_count_) { |
| 390 #if defined(OS_ANDROID) | 390 #if defined(OS_ANDROID) |
| 391 base_share_group_ = new scoped_refptr<gfx::GLShareGroup>( | 391 base_share_group_ = new scoped_refptr<gfx::GLShareGroup>( |
| 392 new gfx::GLShareGroup); | 392 new gfx::GLShareGroup); |
| 393 gfx::Size size(4, 4); | 393 gfx::Size size(4, 4); |
| 394 base_surface_ = new scoped_refptr<gfx::GLSurface>( | 394 base_surface_ = new scoped_refptr<gfx::GLSurface>( |
| 395 gfx::GLSurface::CreateOffscreenGLSurface(size)); | 395 gl::init::CreateOffscreenGLSurface(size)); |
| 396 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu); | 396 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu); |
| 397 base_context_ = new scoped_refptr<gfx::GLContext>( | 397 base_context_ = |
| 398 gfx::GLContext::CreateGLContext(base_share_group_->get(), | 398 new scoped_refptr<gfx::GLContext>(gl::init::CreateGLContext( |
| 399 base_surface_->get(), | 399 base_share_group_->get(), base_surface_->get(), gpu_preference)); |
| 400 gpu_preference)); | |
| 401 #endif | 400 #endif |
| 402 } | 401 } |
| 403 ++use_count_; | 402 ++use_count_; |
| 404 } | 403 } |
| 405 | 404 |
| 406 void GLManager::OnFenceSyncRelease(uint64_t release) { | 405 void GLManager::OnFenceSyncRelease(uint64_t release) { |
| 407 DCHECK(sync_point_client_); | 406 DCHECK(sync_point_client_); |
| 408 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); | 407 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); |
| 409 sync_point_client_->ReleaseFenceSync(release); | 408 sync_point_client_->ReleaseFenceSync(release); |
| 410 } | 409 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 | 626 |
| 628 // Something went wrong, just run the callback now. | 627 // Something went wrong, just run the callback now. |
| 629 callback.Run(); | 628 callback.Run(); |
| 630 } | 629 } |
| 631 | 630 |
| 632 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { | 631 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { |
| 633 return false; | 632 return false; |
| 634 } | 633 } |
| 635 | 634 |
| 636 } // namespace gpu | 635 } // namespace gpu |
| OLD | NEW |