| 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/ipc/service/gpu_command_buffer_stub.h" | 5 #include "gpu/ipc/service/gpu_command_buffer_stub.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/hash.h" | 11 #include "base/hash.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "gpu/command_buffer/common/constants.h" | 19 #include "gpu/command_buffer/common/constants.h" |
| 20 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" | 20 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" |
| 21 #include "gpu/command_buffer/common/mailbox.h" | 21 #include "gpu/command_buffer/common/mailbox.h" |
| 22 #include "gpu/command_buffer/common/sync_token.h" | 22 #include "gpu/command_buffer/common/sync_token.h" |
| 23 #include "gpu/command_buffer/service/gl_context_virtual.h" | 23 #include "gpu/command_buffer/service/gl_context_virtual.h" |
| 24 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" | 24 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" |
| 25 #include "gpu/command_buffer/service/image_manager.h" | 25 #include "gpu/command_buffer/service/image_manager.h" |
| 26 #include "gpu/command_buffer/service/logger.h" | 26 #include "gpu/command_buffer/service/logger.h" |
| 27 #include "gpu/command_buffer/service/mailbox_manager.h" | 27 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 28 #include "gpu/command_buffer/service/memory_tracking.h" | 28 #include "gpu/command_buffer/service/memory_tracking.h" |
| 29 #include "gpu/command_buffer/service/query_manager.h" | 29 #include "gpu/command_buffer/service/query_manager.h" |
| 30 #include "gpu/command_buffer/service/service_utils.h" |
| 30 #include "gpu/command_buffer/service/sync_point_manager.h" | 31 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 31 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 32 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 32 #include "gpu/ipc/common/gpu_messages.h" | 33 #include "gpu/ipc/common/gpu_messages.h" |
| 33 #include "gpu/ipc/service/gpu_channel.h" | 34 #include "gpu/ipc/service/gpu_channel.h" |
| 34 #include "gpu/ipc/service/gpu_channel_manager.h" | 35 #include "gpu/ipc/service/gpu_channel_manager.h" |
| 35 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 36 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
| 36 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" | 37 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" |
| 37 #include "gpu/ipc/service/gpu_memory_manager.h" | 38 #include "gpu/ipc/service/gpu_memory_manager.h" |
| 38 #include "gpu/ipc/service/gpu_memory_tracking.h" | 39 #include "gpu/ipc/service/gpu_memory_tracking.h" |
| 39 #include "gpu/ipc/service/gpu_watchdog_thread.h" | 40 #include "gpu/ipc/service/gpu_watchdog_thread.h" |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 DLOG(ERROR) << "Failed to create surface."; | 531 DLOG(ERROR) << "Failed to create surface."; |
| 531 return false; | 532 return false; |
| 532 } | 533 } |
| 533 } | 534 } |
| 534 | 535 |
| 535 scoped_refptr<gl::GLContext> context; | 536 scoped_refptr<gl::GLContext> context; |
| 536 gl::GLShareGroup* gl_share_group = channel_->share_group(); | 537 gl::GLShareGroup* gl_share_group = channel_->share_group(); |
| 537 if (use_virtualized_gl_context_ && gl_share_group) { | 538 if (use_virtualized_gl_context_ && gl_share_group) { |
| 538 context = gl_share_group->GetSharedContext(surface_.get()); | 539 context = gl_share_group->GetSharedContext(surface_.get()); |
| 539 if (!context.get()) { | 540 if (!context.get()) { |
| 540 context = gl::init::CreateGLContext(gl_share_group, surface_.get(), | 541 context = gl::init::CreateGLContext( |
| 541 init_params.attribs.gpu_preference); | 542 gl_share_group, surface_.get(), |
| 543 GenerateGLContextAttribs(init_params.attribs, |
| 544 context_group_->gpu_preferences())); |
| 542 if (!context.get()) { | 545 if (!context.get()) { |
| 543 DLOG(ERROR) << "Failed to create shared context for virtualization."; | 546 DLOG(ERROR) << "Failed to create shared context for virtualization."; |
| 544 return false; | 547 return false; |
| 545 } | 548 } |
| 546 // Ensure that context creation did not lose track of the intended | 549 // Ensure that context creation did not lose track of the intended |
| 547 // gl_share_group. | 550 // gl_share_group. |
| 548 DCHECK(context->share_group() == gl_share_group); | 551 DCHECK(context->share_group() == gl_share_group); |
| 549 gl_share_group->SetSharedContext(surface_.get(), context.get()); | 552 gl_share_group->SetSharedContext(surface_.get(), context.get()); |
| 550 } | 553 } |
| 551 // This should be either: | 554 // This should be either: |
| 552 // (1) a non-virtual GL context, or | 555 // (1) a non-virtual GL context, or |
| 553 // (2) a mock context. | 556 // (2) a mock context. |
| 554 DCHECK(context->GetHandle() || | 557 DCHECK(context->GetHandle() || |
| 555 gl::GetGLImplementation() == gl::kGLImplementationMockGL); | 558 gl::GetGLImplementation() == gl::kGLImplementationMockGL); |
| 556 context = new GLContextVirtual( | 559 context = new GLContextVirtual( |
| 557 gl_share_group, context.get(), decoder_->AsWeakPtr()); | 560 gl_share_group, context.get(), decoder_->AsWeakPtr()); |
| 558 if (!context->Initialize(surface_.get(), | 561 if (!context->Initialize( |
| 559 init_params.attribs.gpu_preference)) { | 562 surface_.get(), |
| 563 GenerateGLContextAttribs(init_params.attribs, |
| 564 context_group_->gpu_preferences()))) { |
| 560 // The real context created above for the default offscreen surface | 565 // The real context created above for the default offscreen surface |
| 561 // might not be compatible with this surface. | 566 // might not be compatible with this surface. |
| 562 context = NULL; | 567 context = NULL; |
| 563 DLOG(ERROR) << "Failed to initialize virtual GL context."; | 568 DLOG(ERROR) << "Failed to initialize virtual GL context."; |
| 564 return false; | 569 return false; |
| 565 } | 570 } |
| 566 } | 571 } |
| 567 if (!context.get()) { | 572 if (!context.get()) { |
| 568 context = gl::init::CreateGLContext(gl_share_group, surface_.get(), | 573 context = gl::init::CreateGLContext( |
| 569 init_params.attribs.gpu_preference); | 574 gl_share_group, surface_.get(), |
| 575 GenerateGLContextAttribs(init_params.attribs, |
| 576 context_group_->gpu_preferences())); |
| 570 } | 577 } |
| 571 if (!context.get()) { | 578 if (!context.get()) { |
| 572 DLOG(ERROR) << "Failed to create context."; | 579 DLOG(ERROR) << "Failed to create context."; |
| 573 return false; | 580 return false; |
| 574 } | 581 } |
| 575 | 582 |
| 576 if (!context->MakeCurrent(surface_.get())) { | 583 if (!context->MakeCurrent(surface_.get())) { |
| 577 LOG(ERROR) << "Failed to make context current."; | 584 LOG(ERROR) << "Failed to make context current."; |
| 578 return false; | 585 return false; |
| 579 } | 586 } |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params)); | 1120 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params)); |
| 1114 } | 1121 } |
| 1115 | 1122 |
| 1116 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1123 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
| 1117 base::TimeDelta interval) { | 1124 base::TimeDelta interval) { |
| 1118 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1125 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
| 1119 interval)); | 1126 interval)); |
| 1120 } | 1127 } |
| 1121 | 1128 |
| 1122 } // namespace gpu | 1129 } // namespace gpu |
| OLD | NEW |