| 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 "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 7 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/renderer/gpu/frame_swap_message_queue.h" | 9 #include "content/renderer/gpu/frame_swap_message_queue.h" |
| 10 #include "gpu/command_buffer/client/gl_in_process_context.h" | 10 #include "gpu/command_buffer/client/gl_in_process_context.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 scoped_ptr<gpu::GLInProcessContext> CreateOffscreenContext( | 38 scoped_ptr<gpu::GLInProcessContext> CreateOffscreenContext( |
| 39 const blink::WebGraphicsContext3D::Attributes& attributes) { | 39 const blink::WebGraphicsContext3D::Attributes& attributes) { |
| 40 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 40 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| 41 | 41 |
| 42 gpu::gles2::ContextCreationAttribHelper in_process_attribs; | 42 gpu::gles2::ContextCreationAttribHelper in_process_attribs; |
| 43 WebGraphicsContext3DImpl::ConvertAttributes( | 43 WebGraphicsContext3DImpl::ConvertAttributes( |
| 44 attributes, &in_process_attribs); | 44 attributes, &in_process_attribs); |
| 45 in_process_attribs.lose_context_when_out_of_memory = true; | 45 in_process_attribs.lose_context_when_out_of_memory = true; |
| 46 | 46 |
| 47 scoped_ptr<gpu::GLInProcessContext> context( | 47 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( |
| 48 gpu::GLInProcessContext::Create(NULL /* service */, | 48 NULL /* service */, |
| 49 NULL /* surface */, | 49 NULL /* surface */, |
| 50 true /* is_offscreen */, | 50 true /* is_offscreen */, |
| 51 gfx::kNullAcceleratedWidget, | 51 gfx::kNullAcceleratedWidget, |
| 52 gfx::Size(1, 1), | 52 gfx::Size(1, 1), |
| 53 NULL /* share_context */, | 53 NULL /* share_context */, |
| 54 false /* share_resources */, | 54 false /* share_resources */, |
| 55 in_process_attribs, | 55 in_process_attribs, |
| 56 gpu_preference)); | 56 gpu_preference, |
| 57 gpu::GLInProcessContextSharedMemoryLimits())); |
| 57 return context.Pass(); | 58 return context.Pass(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 scoped_ptr<gpu::GLInProcessContext> CreateContext( | 61 scoped_ptr<gpu::GLInProcessContext> CreateContext( |
| 61 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 62 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
| 62 gpu::GLInProcessContext* share_context) { | 63 gpu::GLInProcessContext* share_context, |
| 64 const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) { |
| 63 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 65 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| 64 gpu::gles2::ContextCreationAttribHelper in_process_attribs; | 66 gpu::gles2::ContextCreationAttribHelper in_process_attribs; |
| 65 WebGraphicsContext3DImpl::ConvertAttributes( | 67 WebGraphicsContext3DImpl::ConvertAttributes( |
| 66 GetDefaultAttribs(), &in_process_attribs); | 68 GetDefaultAttribs(), &in_process_attribs); |
| 67 in_process_attribs.lose_context_when_out_of_memory = true; | 69 in_process_attribs.lose_context_when_out_of_memory = true; |
| 68 | 70 |
| 69 scoped_ptr<gpu::GLInProcessContext> context( | 71 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( |
| 70 gpu::GLInProcessContext::Create(service, | 72 service, |
| 71 NULL /* surface */, | 73 NULL /* surface */, |
| 72 false /* is_offscreen */, | 74 false /* is_offscreen */, |
| 73 gfx::kNullAcceleratedWidget, | 75 gfx::kNullAcceleratedWidget, |
| 74 gfx::Size(1, 1), | 76 gfx::Size(1, 1), |
| 75 share_context, | 77 share_context, |
| 76 false /* share_resources */, | 78 false /* share_resources */, |
| 77 in_process_attribs, | 79 in_process_attribs, |
| 78 gpu_preference)); | 80 gpu_preference, |
| 81 mem_limits)); |
| 79 return context.Pass(); | 82 return context.Pass(); |
| 80 } | 83 } |
| 81 | 84 |
| 82 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WrapContext( | 85 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WrapContext( |
| 83 scoped_ptr<gpu::GLInProcessContext> context) { | 86 scoped_ptr<gpu::GLInProcessContext> context) { |
| 84 if (!context.get()) | 87 if (!context.get()) |
| 85 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(); | 88 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(); |
| 86 | 89 |
| 87 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>( | 90 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>( |
| 88 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( | 91 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 scoped_ptr<gpu::GLInProcessContext> context = | 180 scoped_ptr<gpu::GLInProcessContext> context = |
| 178 CreateOffscreenContext(attributes); | 181 CreateOffscreenContext(attributes); |
| 179 return webkit::gpu::ContextProviderInProcess::Create( | 182 return webkit::gpu::ContextProviderInProcess::Create( |
| 180 WrapContext(context.Pass()), debug_name); | 183 WrapContext(context.Pass()), debug_name); |
| 181 } | 184 } |
| 182 | 185 |
| 183 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: | 186 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: |
| 184 CreateOnscreenContextProviderForCompositorThread() { | 187 CreateOnscreenContextProviderForCompositorThread() { |
| 185 DCHECK(service_); | 188 DCHECK(service_); |
| 186 | 189 |
| 187 if (!share_context_.get()) | 190 if (!share_context_.get()) { |
| 188 share_context_ = CreateContext(service_, NULL); | 191 share_context_ = CreateContext( |
| 192 service_, NULL, gpu::GLInProcessContextSharedMemoryLimits()); |
| 193 } |
| 194 gpu::GLInProcessContextSharedMemoryLimits mem_limits; |
| 195 // This is half of what RenderWidget uses because synchronous compositor |
| 196 // pipeline is only one frame deep. |
| 197 mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; |
| 189 return webkit::gpu::ContextProviderInProcess::Create( | 198 return webkit::gpu::ContextProviderInProcess::Create( |
| 190 WrapContext(CreateContext(service_, share_context_.get())), | 199 WrapContext(CreateContext(service_, share_context_.get(), mem_limits)), |
| 191 "Child-Compositor"); | 200 "Child-Compositor"); |
| 192 } | 201 } |
| 193 | 202 |
| 194 gpu::GLInProcessContext* SynchronousCompositorFactoryImpl::GetShareContext() { | 203 gpu::GLInProcessContext* SynchronousCompositorFactoryImpl::GetShareContext() { |
| 195 DCHECK(share_context_.get()); | 204 DCHECK(share_context_.get()); |
| 196 return share_context_.get(); | 205 return share_context_.get(); |
| 197 } | 206 } |
| 198 | 207 |
| 199 scoped_refptr<StreamTextureFactory> | 208 scoped_refptr<StreamTextureFactory> |
| 200 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { | 209 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 context_provider; | 250 context_provider; |
| 242 // This check only guarantees the main thread context is created after | 251 // This check only guarantees the main thread context is created after |
| 243 // a compositor did successfully initialize hardware draw in the past. | 252 // a compositor did successfully initialize hardware draw in the past. |
| 244 // When all compositors have released hardware draw, main thread context | 253 // When all compositors have released hardware draw, main thread context |
| 245 // creation is guaranteed to fail. | 254 // creation is guaranteed to fail. |
| 246 if (CanCreateMainThreadContext() && !video_context_provider_) { | 255 if (CanCreateMainThreadContext() && !video_context_provider_) { |
| 247 DCHECK(service_); | 256 DCHECK(service_); |
| 248 DCHECK(share_context_.get()); | 257 DCHECK(share_context_.get()); |
| 249 | 258 |
| 250 video_context_provider_ = new VideoContextProvider( | 259 video_context_provider_ = new VideoContextProvider( |
| 251 CreateContext(service_, share_context_.get())); | 260 CreateContext(service_, |
| 261 share_context_.get(), |
| 262 gpu::GLInProcessContextSharedMemoryLimits())); |
| 252 } | 263 } |
| 253 return video_context_provider_; | 264 return video_context_provider_; |
| 254 } | 265 } |
| 255 | 266 |
| 256 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( | 267 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( |
| 257 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { | 268 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
| 258 DCHECK(!service_); | 269 DCHECK(!service_); |
| 259 service_ = service; | 270 service_ = service; |
| 260 } | 271 } |
| 261 | 272 |
| 262 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( | 273 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( |
| 263 bool record_full_document) { | 274 bool record_full_document) { |
| 264 record_full_layer_ = record_full_document; | 275 record_full_layer_ = record_full_document; |
| 265 } | 276 } |
| 266 | 277 |
| 267 } // namespace content | 278 } // namespace content |
| OLD | NEW |