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