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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 return record_full_layer_; | 169 return record_full_layer_; |
169 } | 170 } |
170 | 171 |
171 scoped_ptr<cc::OutputSurface> | 172 scoped_ptr<cc::OutputSurface> |
172 SynchronousCompositorFactoryImpl::CreateOutputSurface( | 173 SynchronousCompositorFactoryImpl::CreateOutputSurface( |
173 int routing_id, | 174 int routing_id, |
174 int surface_id, | 175 int surface_id, |
175 scoped_refptr<content::FrameSwapMessageQueue> frame_swap_message_queue) { | 176 scoped_refptr<content::FrameSwapMessageQueue> frame_swap_message_queue) { |
176 scoped_refptr<cc::ContextProvider> onscreen_context = | 177 scoped_refptr<cc::ContextProvider> onscreen_context = |
177 CreateContextProviderForCompositor(surface_id, RENDER_COMPOSITOR_CONTEXT); | 178 CreateContextProviderForCompositor(surface_id, RENDER_COMPOSITOR_CONTEXT); |
178 scoped_refptr<cc::ContextProvider> worker_context = | 179 |
179 CreateContextProviderForCompositor(0, RENDER_WORKER_CONTEXT); | 180 if (shared_worker_context_) { |
| 181 base::AutoLock lock(*shared_worker_context_->GetLock()); |
| 182 if (shared_worker_context_->ContextGL()->GetGraphicsResetStatusKHR() != |
| 183 GL_NO_ERROR) { |
| 184 shared_worker_context_->Destroy(); |
| 185 shared_worker_context_ = nullptr; |
| 186 } |
| 187 } |
| 188 // Note: shared worker context support requires |use_ipc_command_buffer_|. |
| 189 if (!shared_worker_context_ && use_ipc_command_buffer_) { |
| 190 // TODO(reveman): This limit is based on the usage required by async |
| 191 // uploads. Determine what a good limit is now that async uploads are |
| 192 // no longer used. |
| 193 unsigned int mapped_memory_reclaim_limit = |
| 194 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; |
| 195 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; |
| 196 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; |
| 197 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = |
| 198 CreateContext3D(0, GetDefaultAttribs(), mem_limits); |
| 199 shared_worker_context_ = |
| 200 make_scoped_refptr(new SynchronousCompositorContextProvider( |
| 201 context.Pass(), RENDER_WORKER_CONTEXT)); |
| 202 if (!shared_worker_context_->BindToCurrentThread()) |
| 203 shared_worker_context_ = nullptr; |
| 204 if (shared_worker_context_) |
| 205 shared_worker_context_->SetupLock(); |
| 206 } |
180 | 207 |
181 return make_scoped_ptr(new SynchronousCompositorOutputSurface( | 208 return make_scoped_ptr(new SynchronousCompositorOutputSurface( |
182 onscreen_context, worker_context, routing_id, frame_swap_message_queue)); | 209 onscreen_context, shared_worker_context_, routing_id, |
| 210 frame_swap_message_queue)); |
183 } | 211 } |
184 | 212 |
185 InputHandlerManagerClient* | 213 InputHandlerManagerClient* |
186 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { | 214 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { |
187 return synchronous_input_event_filter(); | 215 return synchronous_input_event_filter(); |
188 } | 216 } |
189 | 217 |
190 scoped_ptr<cc::BeginFrameSource> | 218 scoped_ptr<cc::BeginFrameSource> |
191 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( | 219 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( |
192 int routing_id) { | 220 int routing_id) { |
(...skipping 17 matching lines...) Expand all Loading... |
210 debug_name); | 238 debug_name); |
211 } | 239 } |
212 | 240 |
213 scoped_refptr<cc::ContextProvider> | 241 scoped_refptr<cc::ContextProvider> |
214 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor( | 242 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor( |
215 int surface_id, | 243 int surface_id, |
216 CommandBufferContextType type) { | 244 CommandBufferContextType type) { |
217 // This is half of what RenderWidget uses because synchronous compositor | 245 // This is half of what RenderWidget uses because synchronous compositor |
218 // pipeline is only one frame deep. But twice of half for low end here | 246 // pipeline is only one frame deep. But twice of half for low end here |
219 // because 16bit texture is not supported. | 247 // because 16bit texture is not supported. |
| 248 // TODO(reveman): This limit is based on the usage required by async |
| 249 // uploads. Determine what a good limit is now that async uploads are |
| 250 // no longer used. |
220 unsigned int mapped_memory_reclaim_limit = | 251 unsigned int mapped_memory_reclaim_limit = |
221 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; | 252 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; |
222 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); | 253 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); |
223 | 254 |
224 if (use_ipc_command_buffer_) { | 255 if (use_ipc_command_buffer_) { |
225 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; | 256 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; |
226 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; | 257 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; |
227 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = | 258 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = |
228 CreateContext3D(surface_id, GetDefaultAttribs(), mem_limits); | 259 CreateContext3D(surface_id, GetDefaultAttribs(), mem_limits); |
229 return make_scoped_refptr( | 260 return make_scoped_refptr( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( | 384 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( |
354 bool record_full_document) { | 385 bool record_full_document) { |
355 record_full_layer_ = record_full_document; | 386 record_full_layer_ = record_full_document; |
356 } | 387 } |
357 | 388 |
358 void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() { | 389 void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() { |
359 use_ipc_command_buffer_ = true; | 390 use_ipc_command_buffer_ = true; |
360 } | 391 } |
361 | 392 |
362 } // namespace content | 393 } // namespace content |
OLD | NEW |