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 "gpu/command_buffer/client/gles2_cmd_helper.h" | 16 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
16 #include "gpu/command_buffer/client/gles2_implementation.h" | 17 #include "gpu/command_buffer/client/gles2_implementation.h" |
17 #include "gpu/command_buffer/client/shared_memory_limits.h" | 18 #include "gpu/command_buffer/client/shared_memory_limits.h" |
18 #include "gpu/command_buffer/client/transfer_buffer.h" | 19 #include "gpu/command_buffer/client/transfer_buffer.h" |
19 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 20 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
20 #include "services/ui/common/switches.h" | 21 #include "services/ui/common/switches.h" |
21 #include "services/ui/gpu/gpu_service_internal.h" | 22 #include "services/ui/gpu/gpu_service_internal.h" |
22 #include "services/ui/surfaces/surfaces_context_provider_delegate.h" | 23 #include "services/ui/surfaces/surfaces_context_provider_delegate.h" |
23 #include "ui/gl/gpu_preference.h" | 24 #include "ui/gl/gpu_preference.h" |
24 | 25 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 bool bind_generates_resource = | 83 bool bind_generates_resource = |
83 !!capabilities_.bind_generates_resource_chromium; | 84 !!capabilities_.bind_generates_resource_chromium; |
84 // TODO(piman): Some contexts (such as compositor) want this to be true, so | 85 // TODO(piman): Some contexts (such as compositor) want this to be true, so |
85 // this needs to be a public parameter. | 86 // this needs to be a public parameter. |
86 bool lose_context_when_out_of_memory = false; | 87 bool lose_context_when_out_of_memory = false; |
87 bool support_client_side_arrays = false; | 88 bool support_client_side_arrays = false; |
88 implementation_.reset(new gpu::gles2::GLES2Implementation( | 89 implementation_.reset(new gpu::gles2::GLES2Implementation( |
89 gles2_helper_.get(), NULL, transfer_buffer_.get(), | 90 gles2_helper_.get(), NULL, transfer_buffer_.get(), |
90 bind_generates_resource, lose_context_when_out_of_memory, | 91 bind_generates_resource, lose_context_when_out_of_memory, |
91 support_client_side_arrays, gpu_control)); | 92 support_client_side_arrays, gpu_control)); |
| 93 cache_controller_.reset( |
| 94 new cc::ContextCacheController(implementation_.get())); |
92 return implementation_->Initialize( | 95 return implementation_->Initialize( |
93 default_limits.start_transfer_buffer_size, | 96 default_limits.start_transfer_buffer_size, |
94 default_limits.min_transfer_buffer_size, | 97 default_limits.min_transfer_buffer_size, |
95 default_limits.max_transfer_buffer_size, | 98 default_limits.max_transfer_buffer_size, |
96 default_limits.mapped_memory_reclaim_limit); | 99 default_limits.mapped_memory_reclaim_limit); |
97 } | 100 } |
98 | 101 |
99 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() { | 102 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() { |
100 DCHECK(implementation_); | 103 DCHECK(implementation_); |
101 return implementation_.get(); | 104 return implementation_.get(); |
102 } | 105 } |
103 | 106 |
104 gpu::ContextSupport* SurfacesContextProvider::ContextSupport() { | 107 gpu::ContextSupport* SurfacesContextProvider::ContextSupport() { |
105 return implementation_.get(); | 108 return implementation_.get(); |
106 } | 109 } |
107 | 110 |
108 class GrContext* SurfacesContextProvider::GrContext() { | 111 class GrContext* SurfacesContextProvider::GrContext() { |
109 return NULL; | 112 return NULL; |
110 } | 113 } |
111 | 114 |
| 115 cc::ContextCacheController* SurfacesContextProvider::CacheController() { |
| 116 return cache_controller_.get(); |
| 117 } |
| 118 |
112 void SurfacesContextProvider::InvalidateGrContext(uint32_t state) {} | 119 void SurfacesContextProvider::InvalidateGrContext(uint32_t state) {} |
113 | 120 |
114 gpu::Capabilities SurfacesContextProvider::ContextCapabilities() { | 121 gpu::Capabilities SurfacesContextProvider::ContextCapabilities() { |
115 return capabilities_; | 122 return capabilities_; |
116 } | 123 } |
117 | 124 |
118 base::Lock* SurfacesContextProvider::GetLock() { | 125 base::Lock* SurfacesContextProvider::GetLock() { |
119 // This context provider is not used on multiple threads. | 126 // This context provider is not used on multiple threads. |
120 NOTREACHED(); | 127 NOTREACHED(); |
121 return nullptr; | 128 return nullptr; |
(...skipping 27 matching lines...) Expand all Loading... |
149 if (delegate_) | 156 if (delegate_) |
150 delegate_->OnVSyncParametersUpdated(timebase, interval); | 157 delegate_->OnVSyncParametersUpdated(timebase, interval); |
151 } | 158 } |
152 | 159 |
153 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( | 160 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( |
154 gl::GLSurface::SwapCompletionCallback callback) { | 161 gl::GLSurface::SwapCompletionCallback callback) { |
155 swap_buffers_completion_callback_ = callback; | 162 swap_buffers_completion_callback_ = callback; |
156 } | 163 } |
157 | 164 |
158 } // namespace ui | 165 } // namespace ui |
OLD | NEW |