Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(965)

Side by Side Diff: content/browser/android/in_process/synchronous_compositor_factory_impl.cc

Issue 1317743002: cc: Implement shared worker contexts. (v1) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tear down Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (shared_worker_context_) {
175 base::AutoLock lock(*shared_worker_context_->GetLock());
176 if (shared_worker_context_->ContextGL()->GetGraphicsResetStatusKHR() !=
177 GL_NO_ERROR) {
178 shared_worker_context_->Destroy();
179 shared_worker_context_ = nullptr;
180 }
181 }
182 // Note: shared worker context support requires |use_ipc_command_buffer_|.
183 if (!shared_worker_context_ && use_ipc_command_buffer_) {
184 // TODO(reveman): This limit is based on the usage required by async
185 // uploads. Determine what a good limit is now that async uploads are
186 // no longer used.
187 unsigned int mapped_memory_reclaim_limit =
188 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024;
189 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits;
190 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit;
191 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context =
192 CreateContext3D(0, GetDefaultAttribs(), mem_limits);
193 shared_worker_context_ =
194 make_scoped_refptr(new SynchronousCompositorContextProvider(
195 context.Pass(), RENDER_WORKER_CONTEXT));
196 if (!shared_worker_context_->BindToCurrentThread())
197 shared_worker_context_ = nullptr;
198 if (shared_worker_context_)
199 shared_worker_context_->SetupLock();
200 }
174 201
175 return make_scoped_ptr(new SynchronousCompositorOutputSurface( 202 return make_scoped_ptr(new SynchronousCompositorOutputSurface(
176 onscreen_context, worker_context, routing_id, frame_swap_message_queue)); 203 onscreen_context, shared_worker_context_, routing_id,
204 frame_swap_message_queue));
177 } 205 }
178 206
179 InputHandlerManagerClient* 207 InputHandlerManagerClient*
180 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { 208 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() {
181 return synchronous_input_event_filter(); 209 return synchronous_input_event_filter();
182 } 210 }
183 211
184 scoped_ptr<cc::BeginFrameSource> 212 scoped_ptr<cc::BeginFrameSource>
185 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( 213 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource(
186 int routing_id) { 214 int routing_id) {
(...skipping 17 matching lines...) Expand all
204 debug_name); 232 debug_name);
205 } 233 }
206 234
207 scoped_refptr<cc::ContextProvider> 235 scoped_refptr<cc::ContextProvider>
208 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor( 236 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor(
209 int surface_id, 237 int surface_id,
210 CommandBufferContextType type) { 238 CommandBufferContextType type) {
211 // This is half of what RenderWidget uses because synchronous compositor 239 // 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 240 // pipeline is only one frame deep. But twice of half for low end here
213 // because 16bit texture is not supported. 241 // because 16bit texture is not supported.
242 // TODO(reveman): This limit is based on the usage required by async
243 // uploads. Determine what a good limit is now that async uploads are
244 // no longer used.
214 unsigned int mapped_memory_reclaim_limit = 245 unsigned int mapped_memory_reclaim_limit =
215 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; 246 (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024;
216 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); 247 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs();
217 248
218 if (use_ipc_command_buffer_) { 249 if (use_ipc_command_buffer_) {
219 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; 250 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits;
220 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; 251 mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit;
221 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = 252 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context =
222 CreateContext3D(surface_id, GetDefaultAttribs(), mem_limits); 253 CreateContext3D(surface_id, GetDefaultAttribs(), mem_limits);
223 return make_scoped_refptr( 254 return make_scoped_refptr(
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 android_view_service_->sync_point_manager()); 373 android_view_service_->sync_point_manager());
343 } 374 }
344 return gpu_thread_service_; 375 return gpu_thread_service_;
345 } 376 }
346 377
347 void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() { 378 void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() {
348 use_ipc_command_buffer_ = true; 379 use_ipc_command_buffer_ = true;
349 } 380 }
350 381
351 } // namespace content 382 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698