| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "services/ui/common/switches.h" | 22 #include "services/ui/common/switches.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 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 26 | 26 |
| 27 namespace ui { | 27 namespace ui { |
| 28 | 28 |
| 29 SurfacesContextProvider::SurfacesContextProvider( | 29 SurfacesContextProvider::SurfacesContextProvider( |
| 30 gfx::AcceleratedWidget widget, | 30 gfx::AcceleratedWidget widget, |
| 31 scoped_refptr<gpu::GpuChannelHost> gpu_channel) | 31 scoped_refptr<gpu::GpuChannelHost> gpu_channel) |
| 32 : delegate_(nullptr), widget_(widget) { | 32 : delegate_(nullptr), |
| 33 widget_(widget), |
| 34 task_runner_(base::ThreadTaskRunnerHandle::Get()) { |
| 33 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; | 35 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; |
| 34 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; | 36 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; |
| 35 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; | 37 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; |
| 36 gpu::gles2::ContextCreationAttribHelper attributes; | 38 gpu::gles2::ContextCreationAttribHelper attributes; |
| 37 attributes.alpha_size = -1; | 39 attributes.alpha_size = -1; |
| 38 attributes.depth_size = 0; | 40 attributes.depth_size = 0; |
| 39 attributes.stencil_size = 0; | 41 attributes.stencil_size = 0; |
| 40 attributes.samples = 0; | 42 attributes.samples = 0; |
| 41 attributes.sample_buffers = 0; | 43 attributes.sample_buffers = 0; |
| 42 attributes.bind_generates_resource = false; | 44 attributes.bind_generates_resource = false; |
| 43 attributes.lose_context_when_out_of_memory = true; | 45 attributes.lose_context_when_out_of_memory = true; |
| 44 GURL active_url; | 46 GURL active_url; |
| 45 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | |
| 46 base::ThreadTaskRunnerHandle::Get(); | |
| 47 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( | 47 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( |
| 48 std::move(gpu_channel), widget, shared_command_buffer, stream_id, | 48 std::move(gpu_channel), widget, shared_command_buffer, stream_id, |
| 49 stream_priority, attributes, active_url, task_runner); | 49 stream_priority, attributes, active_url, task_runner_); |
| 50 CHECK(command_buffer_proxy_impl_); | 50 CHECK(command_buffer_proxy_impl_); |
| 51 command_buffer_proxy_impl_->SetSwapBuffersCompletionCallback( | 51 command_buffer_proxy_impl_->SetSwapBuffersCompletionCallback( |
| 52 base::Bind(&SurfacesContextProvider::OnGpuSwapBuffersCompleted, | 52 base::Bind(&SurfacesContextProvider::OnGpuSwapBuffersCompleted, |
| 53 base::Unretained(this))); | 53 base::Unretained(this))); |
| 54 command_buffer_proxy_impl_->SetUpdateVSyncParametersCallback( | 54 command_buffer_proxy_impl_->SetUpdateVSyncParametersCallback( |
| 55 base::Bind(&SurfacesContextProvider::OnUpdateVSyncParameters, | 55 base::Bind(&SurfacesContextProvider::OnUpdateVSyncParameters, |
| 56 base::Unretained(this))); | 56 base::Unretained(this))); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void SurfacesContextProvider::SetDelegate( | 59 void SurfacesContextProvider::SetDelegate( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 87 !!capabilities_.bind_generates_resource_chromium; | 87 !!capabilities_.bind_generates_resource_chromium; |
| 88 // TODO(piman): Some contexts (such as compositor) want this to be true, so | 88 // TODO(piman): Some contexts (such as compositor) want this to be true, so |
| 89 // this needs to be a public parameter. | 89 // this needs to be a public parameter. |
| 90 bool lose_context_when_out_of_memory = false; | 90 bool lose_context_when_out_of_memory = false; |
| 91 bool support_client_side_arrays = false; | 91 bool support_client_side_arrays = false; |
| 92 implementation_.reset(new gpu::gles2::GLES2Implementation( | 92 implementation_.reset(new gpu::gles2::GLES2Implementation( |
| 93 gles2_helper_.get(), NULL, transfer_buffer_.get(), | 93 gles2_helper_.get(), NULL, transfer_buffer_.get(), |
| 94 bind_generates_resource, lose_context_when_out_of_memory, | 94 bind_generates_resource, lose_context_when_out_of_memory, |
| 95 support_client_side_arrays, gpu_control)); | 95 support_client_side_arrays, gpu_control)); |
| 96 cache_controller_.reset( | 96 cache_controller_.reset( |
| 97 new cc::ContextCacheController(implementation_.get())); | 97 new cc::ContextCacheController(implementation_.get(), task_runner_)); |
| 98 return implementation_->Initialize( | 98 return implementation_->Initialize( |
| 99 default_limits.start_transfer_buffer_size, | 99 default_limits.start_transfer_buffer_size, |
| 100 default_limits.min_transfer_buffer_size, | 100 default_limits.min_transfer_buffer_size, |
| 101 default_limits.max_transfer_buffer_size, | 101 default_limits.max_transfer_buffer_size, |
| 102 default_limits.mapped_memory_reclaim_limit); | 102 default_limits.mapped_memory_reclaim_limit); |
| 103 } | 103 } |
| 104 | 104 |
| 105 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() { | 105 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() { |
| 106 DCHECK(implementation_); | 106 DCHECK(implementation_); |
| 107 return implementation_.get(); | 107 return implementation_.get(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (delegate_) | 159 if (delegate_) |
| 160 delegate_->OnVSyncParametersUpdated(timebase, interval); | 160 delegate_->OnVSyncParametersUpdated(timebase, interval); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( | 163 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( |
| 164 gl::GLSurface::SwapCompletionCallback callback) { | 164 gl::GLSurface::SwapCompletionCallback callback) { |
| 165 swap_buffers_completion_callback_ = callback; | 165 swap_buffers_completion_callback_ = callback; |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace ui | 168 } // namespace ui |
| OLD | NEW |