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

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

Issue 769703005: Move AW renderer compositor context to gpu thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ready Created 5 years, 11 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/observer_list.h" 8 #include "base/observer_list.h"
8 #include "content/browser/android/in_process/synchronous_compositor_external_beg in_frame_source.h" 9 #include "content/browser/android/in_process/synchronous_compositor_external_beg in_frame_source.h"
9 #include "content/browser/android/in_process/synchronous_compositor_impl.h" 10 #include "content/browser/android/in_process/synchronous_compositor_impl.h"
10 #include "content/browser/android/in_process/synchronous_compositor_output_surfa ce.h" 11 #include "content/browser/android/in_process/synchronous_compositor_output_surfa ce.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 #include "content/renderer/gpu/frame_swap_message_queue.h" 13 #include "content/renderer/gpu/frame_swap_message_queue.h"
13 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" 14 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h"
14 #include "gpu/command_buffer/client/gl_in_process_context.h" 15 #include "gpu/command_buffer/client/gl_in_process_context.h"
15 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 16 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
17 #include "gpu/command_buffer/service/gpu_switches.h"
16 #include "ui/gl/android/surface_texture.h" 18 #include "ui/gl/android/surface_texture.h"
17 #include "ui/gl/gl_surface.h" 19 #include "ui/gl/gl_surface.h"
18 #include "ui/gl/gl_surface_stub.h" 20 #include "ui/gl/gl_surface_stub.h"
19 #include "webkit/common/gpu/context_provider_in_process.h" 21 #include "webkit/common/gpu/context_provider_in_process.h"
20 22
21 using gpu_blink::WebGraphicsContext3DImpl; 23 using gpu_blink::WebGraphicsContext3DImpl;
22 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; 24 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl;
23 using webkit::gpu::ContextProviderWebContext; 25 using webkit::gpu::ContextProviderWebContext;
24 26
25 namespace content { 27 namespace content {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 in_process_attribs, 59 in_process_attribs,
58 gpu_preference, 60 gpu_preference,
59 gpu::GLInProcessContextSharedMemoryLimits(), 61 gpu::GLInProcessContextSharedMemoryLimits(),
60 nullptr, 62 nullptr,
61 nullptr)); 63 nullptr));
62 return context.Pass(); 64 return context.Pass();
63 } 65 }
64 66
65 scoped_ptr<gpu::GLInProcessContext> CreateContext( 67 scoped_ptr<gpu::GLInProcessContext> CreateContext(
66 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, 68 scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
67 const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) { 69 const gpu::GLInProcessContextSharedMemoryLimits& mem_limits,
70 bool is_offscreen) {
68 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; 71 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
69 gpu::gles2::ContextCreationAttribHelper in_process_attribs; 72 gpu::gles2::ContextCreationAttribHelper in_process_attribs;
70 WebGraphicsContext3DImpl::ConvertAttributes( 73 WebGraphicsContext3DImpl::ConvertAttributes(
71 GetDefaultAttribs(), &in_process_attribs); 74 GetDefaultAttribs(), &in_process_attribs);
72 in_process_attribs.lose_context_when_out_of_memory = true; 75 in_process_attribs.lose_context_when_out_of_memory = true;
73 76
74 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( 77 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create(
75 service, 78 service,
76 NULL /* surface */, 79 NULL /* surface */,
77 false /* is_offscreen */, 80 is_offscreen,
78 gfx::kNullAcceleratedWidget, 81 gfx::kNullAcceleratedWidget,
79 gfx::Size(1, 1), 82 gfx::Size(1, 1),
80 NULL /* share_context */, 83 NULL /* share_context */,
81 false /* share_resources */, 84 false /* share_resources */,
82 in_process_attribs, 85 in_process_attribs,
83 gpu_preference, 86 gpu_preference,
84 mem_limits, 87 mem_limits,
85 nullptr, 88 nullptr,
86 nullptr)); 89 nullptr));
87 return context.Pass(); 90 return context.Pass();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 214 }
212 215
213 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: 216 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl::
214 CreateOnscreenContextProviderForCompositorThread() { 217 CreateOnscreenContextProviderForCompositorThread() {
215 DCHECK(service_.get()); 218 DCHECK(service_.get());
216 219
217 gpu::GLInProcessContextSharedMemoryLimits mem_limits; 220 gpu::GLInProcessContextSharedMemoryLimits mem_limits;
218 // This is half of what RenderWidget uses because synchronous compositor 221 // This is half of what RenderWidget uses because synchronous compositor
219 // pipeline is only one frame deep. 222 // pipeline is only one frame deep.
220 mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; 223 mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024;
224
225 scoped_refptr<gpu::InProcessCommandBuffer::Service> service;
226 bool is_offscreen = true;
227 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
228 switches::kEnableAsyncPixelWithThreadedTextureMailboxes)) {
229 service = service_;
230 is_offscreen = false;
231 }
221 return webkit::gpu::ContextProviderInProcess::Create( 232 return webkit::gpu::ContextProviderInProcess::Create(
222 WrapContext(CreateContext(service_, mem_limits)), 233 WrapContext(CreateContext(service, mem_limits, is_offscreen)),
223 "Child-Compositor"); 234 "Child-Compositor");
224 } 235 }
225 236
226 scoped_refptr<StreamTextureFactory> 237 scoped_refptr<StreamTextureFactory>
227 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { 238 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) {
228 scoped_refptr<StreamTextureFactorySynchronousImpl> factory( 239 scoped_refptr<StreamTextureFactorySynchronousImpl> factory(
229 StreamTextureFactorySynchronousImpl::Create( 240 StreamTextureFactorySynchronousImpl::Create(
230 base::Bind( 241 base::Bind(
231 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory, 242 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory,
232 base::Unretained(this)), 243 base::Unretained(this)),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // |video_context_provider_| to null is also not safe since it makes 292 // |video_context_provider_| to null is also not safe since it makes
282 // synchronous destruction uncontrolled and possibly deadlock. 293 // synchronous destruction uncontrolled and possibly deadlock.
283 if (!CanCreateMainThreadContext()) { 294 if (!CanCreateMainThreadContext()) {
284 return 295 return
285 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>(); 296 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>();
286 } 297 }
287 298
288 if (!video_context_provider_.get()) { 299 if (!video_context_provider_.get()) {
289 DCHECK(service_.get()); 300 DCHECK(service_.get());
290 301
291 video_context_provider_ = new VideoContextProvider( 302 video_context_provider_ = new VideoContextProvider(CreateContext(
292 CreateContext(service_, 303 service_, gpu::GLInProcessContextSharedMemoryLimits(), false));
no sievers 2015/01/15 20:26:05 Can you put a comment that this needs to be treate
boliu 2015/01/21 02:08:01 I put something generic. Can you look again? What
no sievers 2015/01/23 21:48:35 Yes you cannot create another texture from a Surfa
293 gpu::GLInProcessContextSharedMemoryLimits()));
294 } 304 }
295 return video_context_provider_; 305 return video_context_provider_;
296 } 306 }
297 307
298 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( 308 void SynchronousCompositorFactoryImpl::SetDeferredGpuService(
299 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { 309 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) {
300 DCHECK(!service_.get()); 310 DCHECK(!service_.get());
301 service_ = service; 311 service_ = service;
302 } 312 }
303 313
304 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( 314 void SynchronousCompositorFactoryImpl::SetRecordFullDocument(
305 bool record_full_document) { 315 bool record_full_document) {
306 record_full_layer_ = record_full_document; 316 record_full_layer_ = record_full_document;
307 } 317 }
308 318
309 } // namespace content 319 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698