| 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" | |
| 28 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 27 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 29 #include "ui/gl/android/surface_texture.h" | 28 #include "ui/gl/android/surface_texture.h" |
| 30 #include "ui/gl/gl_surface.h" | 29 #include "ui/gl/gl_surface.h" |
| 31 #include "ui/gl/gl_surface_stub.h" | 30 #include "ui/gl/gl_surface_stub.h" |
| 32 | 31 |
| 33 using cc_blink::ContextProviderWebContext; | 32 using cc_blink::ContextProviderWebContext; |
| 34 using gpu_blink::WebGraphicsContext3DImpl; | 33 using gpu_blink::WebGraphicsContext3DImpl; |
| 35 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; | 34 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; |
| 36 | 35 |
| 37 namespace content { | 36 namespace content { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | 162 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
| 164 } | 163 } |
| 165 | 164 |
| 166 scoped_ptr<cc::OutputSurface> | 165 scoped_ptr<cc::OutputSurface> |
| 167 SynchronousCompositorFactoryImpl::CreateOutputSurface( | 166 SynchronousCompositorFactoryImpl::CreateOutputSurface( |
| 168 int routing_id, | 167 int routing_id, |
| 169 int surface_id, | 168 int surface_id, |
| 170 scoped_refptr<content::FrameSwapMessageQueue> frame_swap_message_queue) { | 169 scoped_refptr<content::FrameSwapMessageQueue> frame_swap_message_queue) { |
| 171 scoped_refptr<cc::ContextProvider> onscreen_context = | 170 scoped_refptr<cc::ContextProvider> onscreen_context = |
| 172 CreateContextProviderForCompositor(surface_id, RENDER_COMPOSITOR_CONTEXT); | 171 CreateContextProviderForCompositor(surface_id, RENDER_COMPOSITOR_CONTEXT); |
| 173 | 172 scoped_refptr<cc::ContextProvider> worker_context = |
| 174 bool shared_worker_context_lost = false; | 173 CreateContextProviderForCompositor(0, RENDER_WORKER_CONTEXT); |
| 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_ && | |
| 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 } | |
| 203 | 174 |
| 204 return make_scoped_ptr(new SynchronousCompositorOutputSurface( | 175 return make_scoped_ptr(new SynchronousCompositorOutputSurface( |
| 205 onscreen_context, shared_worker_context_, routing_id, | 176 onscreen_context, worker_context, routing_id, frame_swap_message_queue)); |
| 206 frame_swap_message_queue)); | |
| 207 } | 177 } |
| 208 | 178 |
| 209 InputHandlerManagerClient* | 179 InputHandlerManagerClient* |
| 210 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { | 180 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { |
| 211 return synchronous_input_event_filter(); | 181 return synchronous_input_event_filter(); |
| 212 } | 182 } |
| 213 | 183 |
| 214 scoped_ptr<cc::BeginFrameSource> | 184 scoped_ptr<cc::BeginFrameSource> |
| 215 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( | 185 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( |
| 216 int routing_id) { | 186 int routing_id) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 234 debug_name); | 204 debug_name); |
| 235 } | 205 } |
| 236 | 206 |
| 237 scoped_refptr<cc::ContextProvider> | 207 scoped_refptr<cc::ContextProvider> |
| 238 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor( | 208 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor( |
| 239 int surface_id, | 209 int surface_id, |
| 240 CommandBufferContextType type) { | 210 CommandBufferContextType type) { |
| 241 // This is half of what RenderWidget uses because synchronous compositor | 211 // This is half of what RenderWidget uses because synchronous compositor |
| 242 // pipeline is only one frame deep. But twice of half for low end here | 212 // pipeline is only one frame deep. But twice of half for low end here |
| 243 // because 16bit texture is not supported. | 213 // 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. | |
| 247 unsigned int mapped_memory_reclaim_limit = | 214 unsigned int mapped_memory_reclaim_limit = |
| 248 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; | 215 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; |
| 249 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); | 216 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); |
| 250 | 217 |
| 251 if (use_ipc_command_buffer_) { | 218 if (use_ipc_command_buffer_) { |
| 252 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; | 219 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; |
| 253 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; | 220 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; |
| 254 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = | 221 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = |
| 255 CreateContext3D(surface_id, GetDefaultAttribs(), mem_limits); | 222 CreateContext3D(surface_id, GetDefaultAttribs(), mem_limits); |
| 256 return make_scoped_refptr( | 223 return make_scoped_refptr( |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 android_view_service_->sync_point_manager()); | 342 android_view_service_->sync_point_manager()); |
| 376 } | 343 } |
| 377 return gpu_thread_service_; | 344 return gpu_thread_service_; |
| 378 } | 345 } |
| 379 | 346 |
| 380 void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() { | 347 void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() { |
| 381 use_ipc_command_buffer_ = true; | 348 use_ipc_command_buffer_ = true; |
| 382 } | 349 } |
| 383 | 350 |
| 384 } // namespace content | 351 } // namespace content |
| OLD | NEW |