| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/hash.h" | 9 #include "base/hash.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "content/common/gpu/gpu_channel.h" | 13 #include "content/common/gpu/gpu_channel.h" |
| 14 #include "content/common/gpu/gpu_channel_manager.h" | 14 #include "content/common/gpu/gpu_channel_manager.h" |
| 15 #include "content/common/gpu/gpu_command_buffer_stub.h" | 15 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 16 #include "content/common/gpu/gpu_memory_manager.h" | 16 #include "content/common/gpu/gpu_memory_manager.h" |
| 17 #include "content/common/gpu/gpu_memory_tracking.h" | 17 #include "content/common/gpu/gpu_memory_tracking.h" |
| 18 #include "content/common/gpu/gpu_messages.h" | 18 #include "content/common/gpu/gpu_messages.h" |
| 19 #include "content/common/gpu/gpu_watchdog.h" | 19 #include "content/common/gpu/gpu_watchdog.h" |
| 20 #include "content/common/gpu/image_transport_surface.h" | 20 #include "content/common/gpu/image_transport_surface.h" |
| 21 #include "content/common/gpu/media/gl_surface_capturer.h" | 21 #include "content/common/gpu/media/gl_surface_capturer.h" |
| 22 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 22 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 23 #include "content/common/gpu/sync_point_manager.h" | 23 #include "content/common/gpu/sync_point_manager.h" |
| 24 #include "content/public/common/content_client.h" | 24 #include "content/public/common/content_client.h" |
| 25 #include "content/public/common/content_switches.h" | |
| 26 #include "gpu/command_buffer/common/constants.h" | 25 #include "gpu/command_buffer/common/constants.h" |
| 27 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 28 #include "gpu/command_buffer/common/mailbox.h" | 27 #include "gpu/command_buffer/common/mailbox.h" |
| 29 #include "gpu/command_buffer/service/gl_context_virtual.h" | 28 #include "gpu/command_buffer/service/gl_context_virtual.h" |
| 30 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" | 29 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" |
| 31 #include "gpu/command_buffer/service/logger.h" | 30 #include "gpu/command_buffer/service/logger.h" |
| 32 #include "gpu/command_buffer/service/memory_tracking.h" | 31 #include "gpu/command_buffer/service/memory_tracking.h" |
| 33 #include "gpu/command_buffer/service/query_manager.h" | 32 #include "gpu/command_buffer/service/query_manager.h" |
| 34 #include "ui/gl/gl_bindings.h" | 33 #include "ui/gl/gl_bindings.h" |
| 35 #include "ui/gl/gl_switches.h" | 34 #include "ui/gl/gl_switches.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 #if defined(OS_ANDROID) | 143 #if defined(OS_ANDROID) |
| 145 stream_texture_manager = channel_->stream_texture_manager(); | 144 stream_texture_manager = channel_->stream_texture_manager(); |
| 146 #endif | 145 #endif |
| 147 context_group_ = new gpu::gles2::ContextGroup( | 146 context_group_ = new gpu::gles2::ContextGroup( |
| 148 mailbox_manager, | 147 mailbox_manager, |
| 149 image_manager, | 148 image_manager, |
| 150 new GpuCommandBufferMemoryTracker(channel), | 149 new GpuCommandBufferMemoryTracker(channel), |
| 151 stream_texture_manager, | 150 stream_texture_manager, |
| 152 true); | 151 true); |
| 153 } | 152 } |
| 153 |
| 154 if (!use_virtualized_gl_context_) { |
| 155 use_virtualized_gl_context_ = context_group_->feature_info() |
| 156 ->workarounds() |
| 157 .use_virtualized_gl_contexts; |
| 158 } |
| 154 } | 159 } |
| 155 | 160 |
| 156 GpuCommandBufferStub::~GpuCommandBufferStub() { | 161 GpuCommandBufferStub::~GpuCommandBufferStub() { |
| 157 Destroy(); | 162 Destroy(); |
| 158 | 163 |
| 159 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 164 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
| 160 gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer(surface_id())); | 165 gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer(surface_id())); |
| 161 } | 166 } |
| 162 | 167 |
| 163 GpuMemoryManager* GpuCommandBufferStub::GetMemoryManager() { | 168 GpuMemoryManager* GpuCommandBufferStub::GetMemoryManager() { |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 surface_ = manager->GetDefaultOffscreenSurface(); | 437 surface_ = manager->GetDefaultOffscreenSurface(); |
| 433 } | 438 } |
| 434 | 439 |
| 435 if (!surface_.get()) { | 440 if (!surface_.get()) { |
| 436 DLOG(ERROR) << "Failed to create surface.\n"; | 441 DLOG(ERROR) << "Failed to create surface.\n"; |
| 437 OnInitializeFailed(reply_message); | 442 OnInitializeFailed(reply_message); |
| 438 return; | 443 return; |
| 439 } | 444 } |
| 440 | 445 |
| 441 scoped_refptr<gfx::GLContext> context; | 446 scoped_refptr<gfx::GLContext> context; |
| 442 if ((CommandLine::ForCurrentProcess()->HasSwitch( | 447 if (use_virtualized_gl_context_ && channel_->share_group()) { |
| 443 switches::kEnableVirtualGLContexts) || use_virtualized_gl_context_) && | |
| 444 channel_->share_group()) { | |
| 445 context = channel_->share_group()->GetSharedContext(); | 448 context = channel_->share_group()->GetSharedContext(); |
| 446 if (!context.get()) { | 449 if (!context.get()) { |
| 447 context = gfx::GLContext::CreateGLContext( | 450 context = gfx::GLContext::CreateGLContext( |
| 448 channel_->share_group(), | 451 channel_->share_group(), |
| 449 channel_->gpu_channel_manager()->GetDefaultOffscreenSurface(), | 452 channel_->gpu_channel_manager()->GetDefaultOffscreenSurface(), |
| 450 gpu_preference_); | 453 gpu_preference_); |
| 451 channel_->share_group()->SetSharedContext(context.get()); | 454 channel_->share_group()->SetSharedContext(context.get()); |
| 452 } | 455 } |
| 453 // This should be a non-virtual GL context. | 456 // This should be a non-virtual GL context. |
| 454 DCHECK(context->GetHandle()); | 457 DCHECK(context->GetHandle()); |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 command_buffer_->GetState().error == gpu::error::kLostContext) | 956 command_buffer_->GetState().error == gpu::error::kLostContext) |
| 954 return; | 957 return; |
| 955 | 958 |
| 956 command_buffer_->SetContextLostReason(gpu::error::kUnknown); | 959 command_buffer_->SetContextLostReason(gpu::error::kUnknown); |
| 957 if (decoder_) | 960 if (decoder_) |
| 958 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 961 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
| 959 command_buffer_->SetParseError(gpu::error::kLostContext); | 962 command_buffer_->SetParseError(gpu::error::kLostContext); |
| 960 } | 963 } |
| 961 | 964 |
| 962 } // namespace content | 965 } // namespace content |
| OLD | NEW |