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 // Note: If context is lost, we delete reference after releasing the lock. | |
177 base::AutoLock lock(*shared_worker_context_->GetLock()); | |
178 if (shared_worker_context_->ContextGL()->GetGraphicsResetStatusKHR() != | |
179 GL_NO_ERROR) { | |
180 shared_worker_context_lost = true; | |
181 } | |
182 } | |
183 // Note: shared worker context support requires |use_ipc_command_buffer_|. | |
184 if (use_ipc_command_buffer_ && | |
boliu
2015/09/17 20:58:10
FYI we found a blocker in android webview for ipc
reveman
2015/09/18 14:51:35
Added !use_ipc_command_buffer_ support to latest p
| |
185 (!shared_worker_context_ || shared_worker_context_lost)) { | |
186 // TODO(reveman): This limit is based on the usage required by async | |
187 // uploads. Determine what a good limit is now that async uploads are | |
188 // no longer used. | |
189 unsigned int mapped_memory_reclaim_limit = | |
190 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; | |
191 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; | |
192 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; | |
193 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = | |
194 CreateContext3D(0, GetDefaultAttribs(), mem_limits); | |
195 shared_worker_context_ = | |
196 make_scoped_refptr(new SynchronousCompositorContextProvider( | |
197 context.Pass(), RENDER_WORKER_CONTEXT)); | |
198 if (!shared_worker_context_->BindToCurrentThread()) | |
199 shared_worker_context_ = nullptr; | |
200 if (shared_worker_context_) | |
201 shared_worker_context_->SetupLock(); | |
202 } | |
174 | 203 |
175 return make_scoped_ptr(new SynchronousCompositorOutputSurface( | 204 return make_scoped_ptr(new SynchronousCompositorOutputSurface( |
176 onscreen_context, worker_context, routing_id, frame_swap_message_queue)); | 205 onscreen_context, shared_worker_context_, routing_id, |
206 frame_swap_message_queue)); | |
177 } | 207 } |
178 | 208 |
179 InputHandlerManagerClient* | 209 InputHandlerManagerClient* |
180 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { | 210 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { |
181 return synchronous_input_event_filter(); | 211 return synchronous_input_event_filter(); |
182 } | 212 } |
183 | 213 |
184 scoped_ptr<cc::BeginFrameSource> | 214 scoped_ptr<cc::BeginFrameSource> |
185 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( | 215 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( |
186 int routing_id) { | 216 int routing_id) { |
(...skipping 17 matching lines...) Expand all Loading... | |
204 debug_name); | 234 debug_name); |
205 } | 235 } |
206 | 236 |
207 scoped_refptr<cc::ContextProvider> | 237 scoped_refptr<cc::ContextProvider> |
208 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor( | 238 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor( |
209 int surface_id, | 239 int surface_id, |
210 CommandBufferContextType type) { | 240 CommandBufferContextType type) { |
211 // This is half of what RenderWidget uses because synchronous compositor | 241 // 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 | 242 // pipeline is only one frame deep. But twice of half for low end here |
213 // because 16bit texture is not supported. | 243 // because 16bit texture is not supported. |
244 // TODO(reveman): This limit is based on the usage required by async | |
245 // uploads. Determine what a good limit is now that async uploads are | |
246 // no longer used. | |
214 unsigned int mapped_memory_reclaim_limit = | 247 unsigned int mapped_memory_reclaim_limit = |
215 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; | 248 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; |
216 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); | 249 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); |
217 | 250 |
218 if (use_ipc_command_buffer_) { | 251 if (use_ipc_command_buffer_) { |
219 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; | 252 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; |
220 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; | 253 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; |
221 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = | 254 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = |
222 CreateContext3D(surface_id, GetDefaultAttribs(), mem_limits); | 255 CreateContext3D(surface_id, GetDefaultAttribs(), mem_limits); |
223 return make_scoped_refptr( | 256 return make_scoped_refptr( |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 android_view_service_->sync_point_manager()); | 375 android_view_service_->sync_point_manager()); |
343 } | 376 } |
344 return gpu_thread_service_; | 377 return gpu_thread_service_; |
345 } | 378 } |
346 | 379 |
347 void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() { | 380 void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() { |
348 use_ipc_command_buffer_ = true; | 381 use_ipc_command_buffer_ = true; |
349 } | 382 } |
350 | 383 |
351 } // namespace content | 384 } // namespace content |
OLD | NEW |