| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 gpu::GLInProcessContextSharedMemoryLimits())); |
| 58 return context.Pass(); | 58 return context.Pass(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 scoped_ptr<gpu::GLInProcessContext> CreateContext( | 61 scoped_ptr<gpu::GLInProcessContext> CreateContext( |
| 62 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 62 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
| 63 gpu::GLInProcessContext* share_context, | |
| 64 const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) { | 63 const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) { |
| 65 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 64 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| 66 gpu::gles2::ContextCreationAttribHelper in_process_attribs; | 65 gpu::gles2::ContextCreationAttribHelper in_process_attribs; |
| 67 WebGraphicsContext3DImpl::ConvertAttributes( | 66 WebGraphicsContext3DImpl::ConvertAttributes( |
| 68 GetDefaultAttribs(), &in_process_attribs); | 67 GetDefaultAttribs(), &in_process_attribs); |
| 69 in_process_attribs.lose_context_when_out_of_memory = true; | 68 in_process_attribs.lose_context_when_out_of_memory = true; |
| 70 | 69 |
| 71 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( | 70 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( |
| 72 service, | 71 service, |
| 73 NULL /* surface */, | 72 NULL /* surface */, |
| 74 false /* is_offscreen */, | 73 false /* is_offscreen */, |
| 75 gfx::kNullAcceleratedWidget, | 74 gfx::kNullAcceleratedWidget, |
| 76 gfx::Size(1, 1), | 75 gfx::Size(1, 1), |
| 77 share_context, | 76 NULL /* share_context */, |
| 78 false /* share_resources */, | 77 false /* share_resources */, |
| 79 in_process_attribs, | 78 in_process_attribs, |
| 80 gpu_preference, | 79 gpu_preference, |
| 81 mem_limits)); | 80 mem_limits)); |
| 82 return context.Pass(); | 81 return context.Pass(); |
| 83 } | 82 } |
| 84 | 83 |
| 85 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WrapContext( | 84 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WrapContext( |
| 86 scoped_ptr<gpu::GLInProcessContext> context) { | 85 scoped_ptr<gpu::GLInProcessContext> context) { |
| 87 if (!context.get()) | 86 if (!context.get()) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 scoped_ptr<gpu::GLInProcessContext> context = | 179 scoped_ptr<gpu::GLInProcessContext> context = |
| 181 CreateOffscreenContext(attributes); | 180 CreateOffscreenContext(attributes); |
| 182 return webkit::gpu::ContextProviderInProcess::Create( | 181 return webkit::gpu::ContextProviderInProcess::Create( |
| 183 WrapContext(context.Pass()), debug_name); | 182 WrapContext(context.Pass()), debug_name); |
| 184 } | 183 } |
| 185 | 184 |
| 186 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: | 185 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: |
| 187 CreateOnscreenContextProviderForCompositorThread() { | 186 CreateOnscreenContextProviderForCompositorThread() { |
| 188 DCHECK(service_); | 187 DCHECK(service_); |
| 189 | 188 |
| 190 if (!share_context_.get()) { | |
| 191 share_context_ = CreateContext( | |
| 192 service_, NULL, gpu::GLInProcessContextSharedMemoryLimits()); | |
| 193 } | |
| 194 gpu::GLInProcessContextSharedMemoryLimits mem_limits; | 189 gpu::GLInProcessContextSharedMemoryLimits mem_limits; |
| 195 // This is half of what RenderWidget uses because synchronous compositor | 190 // This is half of what RenderWidget uses because synchronous compositor |
| 196 // pipeline is only one frame deep. | 191 // pipeline is only one frame deep. |
| 197 mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; | 192 mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; |
| 198 return webkit::gpu::ContextProviderInProcess::Create( | 193 return webkit::gpu::ContextProviderInProcess::Create( |
| 199 WrapContext(CreateContext(service_, share_context_.get(), mem_limits)), | 194 WrapContext(CreateContext(service_, mem_limits)), |
| 200 "Child-Compositor"); | 195 "Child-Compositor"); |
| 201 } | 196 } |
| 202 | 197 |
| 203 gpu::GLInProcessContext* SynchronousCompositorFactoryImpl::GetShareContext() { | |
| 204 DCHECK(share_context_.get()); | |
| 205 return share_context_.get(); | |
| 206 } | |
| 207 | |
| 208 scoped_refptr<StreamTextureFactory> | 198 scoped_refptr<StreamTextureFactory> |
| 209 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { | 199 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { |
| 210 scoped_refptr<StreamTextureFactorySynchronousImpl> factory( | 200 scoped_refptr<StreamTextureFactorySynchronousImpl> factory( |
| 211 StreamTextureFactorySynchronousImpl::Create( | 201 StreamTextureFactorySynchronousImpl::Create( |
| 212 base::Bind( | 202 base::Bind( |
| 213 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory, | 203 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory, |
| 214 base::Unretained(this)), | 204 base::Unretained(this)), |
| 215 frame_id)); | 205 frame_id)); |
| 216 return factory; | 206 return factory; |
| 217 } | 207 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 245 // This is to avoid synchronous calls that may deadlock. Setting | 235 // This is to avoid synchronous calls that may deadlock. Setting |
| 246 // |video_context_provider_| to null is also not safe since it makes | 236 // |video_context_provider_| to null is also not safe since it makes |
| 247 // synchronous destruction uncontrolled and possibly deadlock. | 237 // synchronous destruction uncontrolled and possibly deadlock. |
| 248 if (!CanCreateMainThreadContext()) { | 238 if (!CanCreateMainThreadContext()) { |
| 249 return | 239 return |
| 250 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>(); | 240 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>(); |
| 251 } | 241 } |
| 252 | 242 |
| 253 if (!video_context_provider_) { | 243 if (!video_context_provider_) { |
| 254 DCHECK(service_); | 244 DCHECK(service_); |
| 255 DCHECK(share_context_.get()); | |
| 256 | 245 |
| 257 video_context_provider_ = new VideoContextProvider( | 246 video_context_provider_ = new VideoContextProvider( |
| 258 CreateContext(service_, | 247 CreateContext(service_, |
| 259 share_context_.get(), | |
| 260 gpu::GLInProcessContextSharedMemoryLimits())); | 248 gpu::GLInProcessContextSharedMemoryLimits())); |
| 261 } | 249 } |
| 262 return video_context_provider_; | 250 return video_context_provider_; |
| 263 } | 251 } |
| 264 | 252 |
| 265 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( | 253 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( |
| 266 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { | 254 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
| 267 DCHECK(!service_); | 255 DCHECK(!service_); |
| 268 service_ = service; | 256 service_ = service; |
| 269 } | 257 } |
| 270 | 258 |
| 271 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( | 259 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( |
| 272 bool record_full_document) { | 260 bool record_full_document) { |
| 273 record_full_layer_ = record_full_document; | 261 record_full_layer_ = record_full_document; |
| 274 } | 262 } |
| 275 | 263 |
| 276 } // namespace content | 264 } // namespace content |
| OLD | NEW |