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 "content/browser/android/in_process/synchronous_compositor_factory_impl
.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_factory_impl
.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
11 #include "content/browser/android/in_process/context_provider_in_process.h" | 11 #include "content/browser/android/in_process/context_provider_in_process.h" |
12 #include "content/browser/android/in_process/synchronous_compositor_context_prov
ider.h" | 12 #include "content/browser/android/in_process/synchronous_compositor_context_prov
ider.h" |
13 #include "content/browser/android/in_process/synchronous_compositor_external_beg
in_frame_source.h" | 13 #include "content/browser/android/in_process/synchronous_compositor_external_beg
in_frame_source.h" |
14 #include "content/browser/android/in_process/synchronous_compositor_impl.h" | 14 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
15 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 15 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
16 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 16 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
17 #include "content/common/gpu/client/gpu_channel_host.h" | 17 #include "content/common/gpu/client/gpu_channel_host.h" |
18 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 18 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
19 #include "content/gpu/in_process_gpu_thread.h" | 19 #include "content/gpu/in_process_gpu_thread.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/gpu_data_manager.h" | 21 #include "content/public/browser/gpu_data_manager.h" |
22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
23 #include "content/renderer/gpu/frame_swap_message_queue.h" | 23 #include "content/renderer/gpu/frame_swap_message_queue.h" |
24 #include "content/renderer/render_thread_impl.h" | 24 #include "content/renderer/render_thread_impl.h" |
25 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" | 25 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" |
26 #include "gpu/command_buffer/client/gl_in_process_context.h" | 26 #include "gpu/command_buffer/client/gl_in_process_context.h" |
| 27 #include "gpu/command_buffer/client/gles2_interface.h" |
27 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 28 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
28 #include "ui/gl/android/surface_texture.h" | 29 #include "ui/gl/android/surface_texture.h" |
29 #include "ui/gl/gl_surface.h" | 30 #include "ui/gl/gl_surface.h" |
30 #include "ui/gl/gl_surface_stub.h" | 31 #include "ui/gl/gl_surface_stub.h" |
31 | 32 |
32 using cc_blink::ContextProviderWebContext; | 33 using cc_blink::ContextProviderWebContext; |
33 using gpu_blink::WebGraphicsContext3DImpl; | 34 using gpu_blink::WebGraphicsContext3DImpl; |
34 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; | 35 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; |
35 | 36 |
36 namespace content { | 37 namespace content { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | 163 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
163 } | 164 } |
164 | 165 |
165 scoped_ptr<cc::OutputSurface> | 166 scoped_ptr<cc::OutputSurface> |
166 SynchronousCompositorFactoryImpl::CreateOutputSurface( | 167 SynchronousCompositorFactoryImpl::CreateOutputSurface( |
167 int routing_id, | 168 int routing_id, |
168 int surface_id, | 169 int surface_id, |
169 scoped_refptr<content::FrameSwapMessageQueue> frame_swap_message_queue) { | 170 scoped_refptr<content::FrameSwapMessageQueue> frame_swap_message_queue) { |
170 scoped_refptr<cc::ContextProvider> onscreen_context = | 171 scoped_refptr<cc::ContextProvider> onscreen_context = |
171 CreateContextProviderForCompositor(surface_id, RENDER_COMPOSITOR_CONTEXT); | 172 CreateContextProviderForCompositor(surface_id, RENDER_COMPOSITOR_CONTEXT); |
172 scoped_refptr<cc::ContextProvider> worker_context = | 173 |
173 CreateContextProviderForCompositor(0, RENDER_WORKER_CONTEXT); | 174 bool shared_worker_context_lost = false; |
| 175 if (shared_worker_context_) { |
| 176 base::AutoLock lock(*shared_worker_context_->GetLock()); |
| 177 if (shared_worker_context_->ContextGL()->GetGraphicsResetStatusKHR() != |
| 178 GL_NO_ERROR) { |
| 179 shared_worker_context_lost = true; |
| 180 } |
| 181 } |
| 182 // Note: shared worker context support requires |use_ipc_command_buffer_|. |
| 183 if (use_ipc_command_buffer_ && |
| 184 (!shared_worker_context_ || shared_worker_context_lost)) { |
| 185 // TODO(reveman): This limit is based on the usage required by async |
| 186 // uploads. Determine what a good limit is now that async uploads are |
| 187 // no longer used. |
| 188 unsigned int mapped_memory_reclaim_limit = |
| 189 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; |
| 190 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; |
| 191 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; |
| 192 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = |
| 193 CreateContext3D(0, GetDefaultAttribs(), mem_limits); |
| 194 shared_worker_context_ = |
| 195 make_scoped_refptr(new SynchronousCompositorContextProvider( |
| 196 context.Pass(), RENDER_WORKER_CONTEXT)); |
| 197 if (!shared_worker_context_->BindToCurrentThread()) |
| 198 shared_worker_context_ = nullptr; |
| 199 if (shared_worker_context_) |
| 200 shared_worker_context_->SetupLock(); |
| 201 } |
174 | 202 |
175 return make_scoped_ptr(new SynchronousCompositorOutputSurface( | 203 return make_scoped_ptr(new SynchronousCompositorOutputSurface( |
176 onscreen_context, worker_context, routing_id, frame_swap_message_queue)); | 204 onscreen_context, shared_worker_context_, routing_id, |
| 205 frame_swap_message_queue)); |
177 } | 206 } |
178 | 207 |
179 InputHandlerManagerClient* | 208 InputHandlerManagerClient* |
180 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { | 209 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { |
181 return synchronous_input_event_filter(); | 210 return synchronous_input_event_filter(); |
182 } | 211 } |
183 | 212 |
184 scoped_ptr<cc::BeginFrameSource> | 213 scoped_ptr<cc::BeginFrameSource> |
185 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( | 214 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( |
186 int routing_id) { | 215 int routing_id) { |
(...skipping 17 matching lines...) Expand all Loading... |
204 debug_name); | 233 debug_name); |
205 } | 234 } |
206 | 235 |
207 scoped_refptr<cc::ContextProvider> | 236 scoped_refptr<cc::ContextProvider> |
208 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor( | 237 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor( |
209 int surface_id, | 238 int surface_id, |
210 CommandBufferContextType type) { | 239 CommandBufferContextType type) { |
211 // This is half of what RenderWidget uses because synchronous compositor | 240 // This is half of what RenderWidget uses because synchronous compositor |
212 // pipeline is only one frame deep. But twice of half for low end here | 241 // pipeline is only one frame deep. But twice of half for low end here |
213 // because 16bit texture is not supported. | 242 // because 16bit texture is not supported. |
| 243 // TODO(reveman): This limit is based on the usage required by async |
| 244 // uploads. Determine what a good limit is now that async uploads are |
| 245 // no longer used. |
214 unsigned int mapped_memory_reclaim_limit = | 246 unsigned int mapped_memory_reclaim_limit = |
215 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; | 247 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; |
216 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); | 248 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); |
217 | 249 |
218 if (use_ipc_command_buffer_) { | 250 if (use_ipc_command_buffer_) { |
219 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; | 251 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; |
220 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; | 252 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; |
221 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = | 253 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = |
222 CreateContext3D(surface_id, GetDefaultAttribs(), mem_limits); | 254 CreateContext3D(surface_id, GetDefaultAttribs(), mem_limits); |
223 return make_scoped_refptr( | 255 return make_scoped_refptr( |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 android_view_service_->sync_point_manager()); | 374 android_view_service_->sync_point_manager()); |
343 } | 375 } |
344 return gpu_thread_service_; | 376 return gpu_thread_service_; |
345 } | 377 } |
346 | 378 |
347 void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() { | 379 void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() { |
348 use_ipc_command_buffer_ = true; | 380 use_ipc_command_buffer_ = true; |
349 } | 381 } |
350 | 382 |
351 } // namespace content | 383 } // namespace content |
OLD | NEW |