| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/ui/surfaces/surfaces_context_provider.h" | 5 #include "services/ui/surfaces/surfaces_context_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 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/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 15 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 16 #include "gpu/command_buffer/client/gles2_implementation.h" | 16 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 17 #include "gpu/command_buffer/client/shared_memory_limits.h" | 17 #include "gpu/command_buffer/client/shared_memory_limits.h" |
| 18 #include "gpu/command_buffer/client/transfer_buffer.h" | 18 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 19 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 19 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 20 #include "services/ui/common/switches.h" | 20 #include "services/ui/common/switches.h" |
| 21 #include "services/ui/gpu/gpu_service_mus.h" | 21 #include "services/ui/gpu/gpu_service_mus.h" |
| 22 #include "services/ui/surfaces/surfaces_context_provider_delegate.h" | 22 #include "services/ui/surfaces/surfaces_context_provider_delegate.h" |
| 23 #include "ui/gl/gpu_preference.h" | 23 #include "ui/gl/gpu_preference.h" |
| 24 | 24 |
| 25 namespace ui { | 25 namespace ui { |
| 26 | 26 |
| 27 SurfacesContextProvider::SurfacesContextProvider(gfx::AcceleratedWidget widget) | 27 SurfacesContextProvider::SurfacesContextProvider(gfx::AcceleratedWidget widget) |
| 28 : delegate_(nullptr), widget_(widget) { | 28 : delegate_(nullptr), |
| 29 widget_(widget), |
| 30 task_runner_(base::ThreadTaskRunnerHandle::Get()) { |
| 29 GpuServiceMus* service = GpuServiceMus::GetInstance(); | 31 GpuServiceMus* service = GpuServiceMus::GetInstance(); |
| 30 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; | 32 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; |
| 31 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; | 33 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; |
| 32 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; | 34 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; |
| 33 gpu::gles2::ContextCreationAttribHelper attributes; | 35 gpu::gles2::ContextCreationAttribHelper attributes; |
| 34 attributes.alpha_size = -1; | 36 attributes.alpha_size = -1; |
| 35 attributes.depth_size = 0; | 37 attributes.depth_size = 0; |
| 36 attributes.stencil_size = 0; | 38 attributes.stencil_size = 0; |
| 37 attributes.samples = 0; | 39 attributes.samples = 0; |
| 38 attributes.sample_buffers = 0; | 40 attributes.sample_buffers = 0; |
| 39 attributes.bind_generates_resource = false; | 41 attributes.bind_generates_resource = false; |
| 40 attributes.lose_context_when_out_of_memory = true; | 42 attributes.lose_context_when_out_of_memory = true; |
| 41 GURL active_url; | 43 GURL active_url; |
| 42 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | |
| 43 base::ThreadTaskRunnerHandle::Get(); | |
| 44 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( | 44 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( |
| 45 service->gpu_channel_local(), widget, shared_command_buffer, stream_id, | 45 service->gpu_channel_local(), widget, shared_command_buffer, stream_id, |
| 46 stream_priority, attributes, active_url, task_runner); | 46 stream_priority, attributes, active_url, task_runner_); |
| 47 command_buffer_proxy_impl_->SetSwapBuffersCompletionCallback( | 47 command_buffer_proxy_impl_->SetSwapBuffersCompletionCallback( |
| 48 base::Bind(&SurfacesContextProvider::OnGpuSwapBuffersCompleted, | 48 base::Bind(&SurfacesContextProvider::OnGpuSwapBuffersCompleted, |
| 49 base::Unretained(this))); | 49 base::Unretained(this))); |
| 50 command_buffer_proxy_impl_->SetUpdateVSyncParametersCallback( | 50 command_buffer_proxy_impl_->SetUpdateVSyncParametersCallback( |
| 51 base::Bind(&SurfacesContextProvider::OnUpdateVSyncParameters, | 51 base::Bind(&SurfacesContextProvider::OnUpdateVSyncParameters, |
| 52 base::Unretained(this))); | 52 base::Unretained(this))); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void SurfacesContextProvider::SetDelegate( | 55 void SurfacesContextProvider::SetDelegate( |
| 56 SurfacesContextProviderDelegate* delegate) { | 56 SurfacesContextProviderDelegate* delegate) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 capabilities_ = gpu_control->GetCapabilities(); | 81 capabilities_ = gpu_control->GetCapabilities(); |
| 82 bool bind_generates_resource = | 82 bool bind_generates_resource = |
| 83 !!capabilities_.bind_generates_resource_chromium; | 83 !!capabilities_.bind_generates_resource_chromium; |
| 84 // TODO(piman): Some contexts (such as compositor) want this to be true, so | 84 // TODO(piman): Some contexts (such as compositor) want this to be true, so |
| 85 // this needs to be a public parameter. | 85 // this needs to be a public parameter. |
| 86 bool lose_context_when_out_of_memory = false; | 86 bool lose_context_when_out_of_memory = false; |
| 87 bool support_client_side_arrays = false; | 87 bool support_client_side_arrays = false; |
| 88 implementation_.reset(new gpu::gles2::GLES2Implementation( | 88 implementation_.reset(new gpu::gles2::GLES2Implementation( |
| 89 gles2_helper_.get(), NULL, transfer_buffer_.get(), | 89 gles2_helper_.get(), NULL, transfer_buffer_.get(), |
| 90 bind_generates_resource, lose_context_when_out_of_memory, | 90 bind_generates_resource, lose_context_when_out_of_memory, |
| 91 support_client_side_arrays, gpu_control)); | 91 support_client_side_arrays, gpu_control, task_runner_)); |
| 92 return implementation_->Initialize( | 92 return implementation_->Initialize( |
| 93 default_limits.start_transfer_buffer_size, | 93 default_limits.start_transfer_buffer_size, |
| 94 default_limits.min_transfer_buffer_size, | 94 default_limits.min_transfer_buffer_size, |
| 95 default_limits.max_transfer_buffer_size, | 95 default_limits.max_transfer_buffer_size, |
| 96 default_limits.mapped_memory_reclaim_limit); | 96 default_limits.mapped_memory_reclaim_limit); |
| 97 } | 97 } |
| 98 | 98 |
| 99 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() { | 99 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() { |
| 100 DCHECK(implementation_); | 100 DCHECK(implementation_); |
| 101 return implementation_.get(); | 101 return implementation_.get(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (delegate_) | 149 if (delegate_) |
| 150 delegate_->OnVSyncParametersUpdated(timebase, interval); | 150 delegate_->OnVSyncParametersUpdated(timebase, interval); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( | 153 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( |
| 154 gl::GLSurface::SwapCompletionCallback callback) { | 154 gl::GLSurface::SwapCompletionCallback callback) { |
| 155 swap_buffers_completion_callback_ = callback; | 155 swap_buffers_completion_callback_ = callback; |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace ui | 158 } // namespace ui |
| OLD | NEW |