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

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

Issue 455083002: Add memory limits struct to in-process context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
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 "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
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
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 mem_limits.mapped_memory_reclaim_limit =
196 static_cast<size_t>(6.4 * 1024 * 1024);
piman 2014/08/19 22:58:13 nit: it's odd to use doubles to select a memory li
boliu 2014/08/19 23:06:38 It's from this code in render_widget.cc, but using
189 return webkit::gpu::ContextProviderInProcess::Create( 197 return webkit::gpu::ContextProviderInProcess::Create(
190 WrapContext(CreateContext(service_, share_context_.get())), 198 WrapContext(CreateContext(service_, share_context_.get(), mem_limits)),
191 "Child-Compositor"); 199 "Child-Compositor");
192 } 200 }
193 201
194 gpu::GLInProcessContext* SynchronousCompositorFactoryImpl::GetShareContext() { 202 gpu::GLInProcessContext* SynchronousCompositorFactoryImpl::GetShareContext() {
195 DCHECK(share_context_.get()); 203 DCHECK(share_context_.get());
196 return share_context_.get(); 204 return share_context_.get();
197 } 205 }
198 206
199 scoped_refptr<StreamTextureFactory> 207 scoped_refptr<StreamTextureFactory>
200 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { 208 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 context_provider; 249 context_provider;
242 // This check only guarantees the main thread context is created after 250 // This check only guarantees the main thread context is created after
243 // a compositor did successfully initialize hardware draw in the past. 251 // a compositor did successfully initialize hardware draw in the past.
244 // When all compositors have released hardware draw, main thread context 252 // When all compositors have released hardware draw, main thread context
245 // creation is guaranteed to fail. 253 // creation is guaranteed to fail.
246 if (CanCreateMainThreadContext() && !video_context_provider_) { 254 if (CanCreateMainThreadContext() && !video_context_provider_) {
247 DCHECK(service_); 255 DCHECK(service_);
248 DCHECK(share_context_.get()); 256 DCHECK(share_context_.get());
249 257
250 video_context_provider_ = new VideoContextProvider( 258 video_context_provider_ = new VideoContextProvider(
251 CreateContext(service_, share_context_.get())); 259 CreateContext(service_,
260 share_context_.get(),
261 gpu::GLInProcessContextSharedMemoryLimits()));
252 } 262 }
253 return video_context_provider_; 263 return video_context_provider_;
254 } 264 }
255 265
256 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( 266 void SynchronousCompositorFactoryImpl::SetDeferredGpuService(
257 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { 267 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) {
258 DCHECK(!service_); 268 DCHECK(!service_);
259 service_ = service; 269 service_ = service;
260 } 270 }
261 271
262 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( 272 void SynchronousCompositorFactoryImpl::SetRecordFullDocument(
263 bool record_full_document) { 273 bool record_full_document) {
264 record_full_layer_ = record_full_document; 274 record_full_layer_ = record_full_document;
265 } 275 }
266 276
267 } // namespace content 277 } // namespace content
OLDNEW
« no previous file with comments | « cc/test/test_in_process_context_provider.cc ('k') | gpu/command_buffer/client/gl_in_process_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698