| 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 "cc/output/context_cache_controller.h" | 15 #include "cc/output/context_cache_controller.h" |
| 16 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 16 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 17 #include "gpu/command_buffer/client/gles2_implementation.h" | 17 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 18 #include "gpu/command_buffer/client/shared_memory_limits.h" | 18 #include "gpu/command_buffer/client/shared_memory_limits.h" |
| 19 #include "gpu/command_buffer/client/transfer_buffer.h" | 19 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 20 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 20 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 21 #include "services/ui/common/switches.h" | 21 #include "services/ui/common/switches.h" |
| 22 #include "services/ui/gpu/gpu_service_internal.h" | 22 #include "services/ui/gpu/gpu_service_internal.h" |
| 23 #include "services/ui/surfaces/surfaces_context_provider_delegate.h" | 23 #include "services/ui/surfaces/surfaces_context_provider_delegate.h" |
| 24 #include "ui/gl/gpu_preference.h" | 24 #include "ui/gl/gpu_preference.h" |
| 25 | 25 |
| 26 namespace ui { | 26 namespace ui { |
| 27 | 27 |
| 28 SurfacesContextProvider::SurfacesContextProvider(gfx::AcceleratedWidget widget) | 28 SurfacesContextProvider::SurfacesContextProvider(gfx::AcceleratedWidget widget) |
| 29 : delegate_(nullptr), widget_(widget) { | 29 : delegate_(nullptr), widget_(widget), |
| 30 task_runner_(base::ThreadTaskRunnerHandle::Get()) { |
| 30 GpuServiceInternal* service = GpuServiceInternal::GetInstance(); | 31 GpuServiceInternal* service = GpuServiceInternal::GetInstance(); |
| 31 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; | 32 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; |
| 32 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; | 33 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; |
| 33 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; | 34 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; |
| 34 gpu::gles2::ContextCreationAttribHelper attributes; | 35 gpu::gles2::ContextCreationAttribHelper attributes; |
| 35 attributes.alpha_size = -1; | 36 attributes.alpha_size = -1; |
| 36 attributes.depth_size = 0; | 37 attributes.depth_size = 0; |
| 37 attributes.stencil_size = 0; | 38 attributes.stencil_size = 0; |
| 38 attributes.samples = 0; | 39 attributes.samples = 0; |
| 39 attributes.sample_buffers = 0; | 40 attributes.sample_buffers = 0; |
| 40 attributes.bind_generates_resource = false; | 41 attributes.bind_generates_resource = false; |
| 41 attributes.lose_context_when_out_of_memory = true; | 42 attributes.lose_context_when_out_of_memory = true; |
| 42 GURL active_url; | 43 GURL active_url; |
| 43 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | |
| 44 base::ThreadTaskRunnerHandle::Get(); | |
| 45 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( | 44 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( |
| 46 service->gpu_channel_local(), widget, shared_command_buffer, stream_id, | 45 service->gpu_channel_local(), widget, shared_command_buffer, stream_id, |
| 47 stream_priority, attributes, active_url, task_runner); | 46 stream_priority, attributes, active_url, task_runner_); |
| 48 command_buffer_proxy_impl_->SetSwapBuffersCompletionCallback( | 47 command_buffer_proxy_impl_->SetSwapBuffersCompletionCallback( |
| 49 base::Bind(&SurfacesContextProvider::OnGpuSwapBuffersCompleted, | 48 base::Bind(&SurfacesContextProvider::OnGpuSwapBuffersCompleted, |
| 50 base::Unretained(this))); | 49 base::Unretained(this))); |
| 51 command_buffer_proxy_impl_->SetUpdateVSyncParametersCallback( | 50 command_buffer_proxy_impl_->SetUpdateVSyncParametersCallback( |
| 52 base::Bind(&SurfacesContextProvider::OnUpdateVSyncParameters, | 51 base::Bind(&SurfacesContextProvider::OnUpdateVSyncParameters, |
| 53 base::Unretained(this))); | 52 base::Unretained(this))); |
| 54 } | 53 } |
| 55 | 54 |
| 56 void SurfacesContextProvider::SetDelegate( | 55 void SurfacesContextProvider::SetDelegate( |
| 57 SurfacesContextProviderDelegate* delegate) { | 56 SurfacesContextProviderDelegate* delegate) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 84 !!capabilities_.bind_generates_resource_chromium; | 83 !!capabilities_.bind_generates_resource_chromium; |
| 85 // 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 |
| 86 // this needs to be a public parameter. | 85 // this needs to be a public parameter. |
| 87 bool lose_context_when_out_of_memory = false; | 86 bool lose_context_when_out_of_memory = false; |
| 88 bool support_client_side_arrays = false; | 87 bool support_client_side_arrays = false; |
| 89 implementation_.reset(new gpu::gles2::GLES2Implementation( | 88 implementation_.reset(new gpu::gles2::GLES2Implementation( |
| 90 gles2_helper_.get(), NULL, transfer_buffer_.get(), | 89 gles2_helper_.get(), NULL, transfer_buffer_.get(), |
| 91 bind_generates_resource, lose_context_when_out_of_memory, | 90 bind_generates_resource, lose_context_when_out_of_memory, |
| 92 support_client_side_arrays, gpu_control)); | 91 support_client_side_arrays, gpu_control)); |
| 93 cache_controller_.reset( | 92 cache_controller_.reset( |
| 94 new cc::ContextCacheController(implementation_.get())); | 93 new cc::ContextCacheController(implementation_.get(), task_runner_)); |
| 95 return implementation_->Initialize( | 94 return implementation_->Initialize( |
| 96 default_limits.start_transfer_buffer_size, | 95 default_limits.start_transfer_buffer_size, |
| 97 default_limits.min_transfer_buffer_size, | 96 default_limits.min_transfer_buffer_size, |
| 98 default_limits.max_transfer_buffer_size, | 97 default_limits.max_transfer_buffer_size, |
| 99 default_limits.mapped_memory_reclaim_limit); | 98 default_limits.mapped_memory_reclaim_limit); |
| 100 } | 99 } |
| 101 | 100 |
| 102 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() { | 101 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() { |
| 103 DCHECK(implementation_); | 102 DCHECK(implementation_); |
| 104 return implementation_.get(); | 103 return implementation_.get(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (delegate_) | 155 if (delegate_) |
| 157 delegate_->OnVSyncParametersUpdated(timebase, interval); | 156 delegate_->OnVSyncParametersUpdated(timebase, interval); |
| 158 } | 157 } |
| 159 | 158 |
| 160 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( | 159 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( |
| 161 gl::GLSurface::SwapCompletionCallback callback) { | 160 gl::GLSurface::SwapCompletionCallback callback) { |
| 162 swap_buffers_completion_callback_ = callback; | 161 swap_buffers_completion_callback_ = callback; |
| 163 } | 162 } |
| 164 | 163 |
| 165 } // namespace ui | 164 } // namespace ui |
| OLD | NEW |