OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 const base::CommandLine& command_line = | 998 const base::CommandLine& command_line = |
999 *base::CommandLine::ForCurrentProcess(); | 999 *base::CommandLine::ForCurrentProcess(); |
1000 bool use_software = fallback; | 1000 bool use_software = fallback; |
1001 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) | 1001 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) |
1002 use_software = true; | 1002 use_software = true; |
1003 | 1003 |
1004 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 1004 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
1005 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider; | 1005 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider; |
1006 if (!use_software) { | 1006 if (!use_software) { |
1007 context_provider = ContextProviderCommandBuffer::Create( | 1007 context_provider = ContextProviderCommandBuffer::Create( |
1008 CreateGraphicsContext3D(), RENDER_COMPOSITOR_CONTEXT); | 1008 CreateGraphicsContext3D(true), RENDER_COMPOSITOR_CONTEXT); |
1009 if (!context_provider.get()) { | 1009 if (!context_provider.get()) { |
1010 // Cause the compositor to wait and try again. | 1010 // Cause the compositor to wait and try again. |
1011 return scoped_ptr<cc::OutputSurface>(); | 1011 return scoped_ptr<cc::OutputSurface>(); |
1012 } | 1012 } |
1013 | 1013 |
1014 worker_context_provider = ContextProviderCommandBuffer::Create( | 1014 worker_context_provider = ContextProviderCommandBuffer::Create( |
1015 CreateGraphicsContext3D(), RENDER_WORKER_CONTEXT); | 1015 CreateGraphicsContext3D(false), RENDER_WORKER_CONTEXT); |
1016 if (!worker_context_provider.get()) { | 1016 if (!worker_context_provider.get()) { |
1017 // Cause the compositor to wait and try again. | 1017 // Cause the compositor to wait and try again. |
1018 return scoped_ptr<cc::OutputSurface>(); | 1018 return scoped_ptr<cc::OutputSurface>(); |
1019 } | 1019 } |
1020 } | 1020 } |
1021 | 1021 |
1022 uint32 output_surface_id = next_output_surface_id_++; | 1022 uint32 output_surface_id = next_output_surface_id_++; |
1023 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) { | 1023 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) { |
1024 DCHECK(compositor_deps_->GetCompositorImplThreadTaskRunner()); | 1024 DCHECK(compositor_deps_->GetCompositorImplThreadTaskRunner()); |
1025 return scoped_ptr<cc::OutputSurface>(new DelegatedCompositorOutputSurface( | 1025 return scoped_ptr<cc::OutputSurface>(new DelegatedCompositorOutputSurface( |
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2351 #if defined(OS_ANDROID) | 2351 #if defined(OS_ANDROID) |
2352 text_field_is_dirty_ = true; | 2352 text_field_is_dirty_ = true; |
2353 #endif | 2353 #endif |
2354 } | 2354 } |
2355 | 2355 |
2356 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { | 2356 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { |
2357 return true; | 2357 return true; |
2358 } | 2358 } |
2359 | 2359 |
2360 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 2360 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
2361 RenderWidget::CreateGraphicsContext3D() { | 2361 RenderWidget::CreateGraphicsContext3D(bool compositor) { |
2362 if (!webwidget_) | 2362 if (!webwidget_) |
2363 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2363 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
2364 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2364 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
2365 switches::kDisableGpuCompositing)) | 2365 switches::kDisableGpuCompositing)) |
2366 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2366 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
2367 if (!RenderThreadImpl::current()) | 2367 if (!RenderThreadImpl::current()) |
2368 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2368 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
2369 CauseForGpuLaunch cause = | 2369 CauseForGpuLaunch cause = |
2370 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 2370 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
2371 scoped_refptr<GpuChannelHost> gpu_channel_host( | 2371 scoped_refptr<GpuChannelHost> gpu_channel_host( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2406 const size_t kMillisecondsPerFrame = 16; | 2406 const size_t kMillisecondsPerFrame = 16; |
2407 // Assuming a two frame deep pipeline between the CPU and the GPU. | 2407 // Assuming a two frame deep pipeline between the CPU and the GPU. |
2408 size_t max_transfer_buffer_usage_mb = | 2408 size_t max_transfer_buffer_usage_mb = |
2409 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); | 2409 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); |
2410 static const size_t kBytesPerMegabyte = 1024 * 1024; | 2410 static const size_t kBytesPerMegabyte = 1024 * 1024; |
2411 // We keep the MappedMemoryReclaimLimit the same as the upload limit | 2411 // We keep the MappedMemoryReclaimLimit the same as the upload limit |
2412 // to avoid unnecessarily stalling the compositor thread. | 2412 // to avoid unnecessarily stalling the compositor thread. |
2413 limits.mapped_memory_reclaim_limit = | 2413 limits.mapped_memory_reclaim_limit = |
2414 max_transfer_buffer_usage_mb * kBytesPerMegabyte; | 2414 max_transfer_buffer_usage_mb * kBytesPerMegabyte; |
2415 #endif | 2415 #endif |
| 2416 if (compositor) |
| 2417 limits.command_buffer_size = 64 * 1024; |
2416 | 2418 |
2417 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 2419 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
2418 new WebGraphicsContext3DCommandBufferImpl(surface_id(), | 2420 new WebGraphicsContext3DCommandBufferImpl(surface_id(), |
2419 GetURLForGraphicsContext3D(), | 2421 GetURLForGraphicsContext3D(), |
2420 gpu_channel_host.get(), | 2422 gpu_channel_host.get(), |
2421 attributes, | 2423 attributes, |
2422 lose_context_when_out_of_memory, | 2424 lose_context_when_out_of_memory, |
2423 limits, | 2425 limits, |
2424 NULL)); | 2426 NULL)); |
2425 return context.Pass(); | 2427 return context.Pass(); |
(...skipping 19 matching lines...) Expand all Loading... |
2445 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2447 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2446 video_hole_frames_.AddObserver(frame); | 2448 video_hole_frames_.AddObserver(frame); |
2447 } | 2449 } |
2448 | 2450 |
2449 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2451 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2450 video_hole_frames_.RemoveObserver(frame); | 2452 video_hole_frames_.RemoveObserver(frame); |
2451 } | 2453 } |
2452 #endif // defined(VIDEO_HOLE) | 2454 #endif // defined(VIDEO_HOLE) |
2453 | 2455 |
2454 } // namespace content | 2456 } // namespace content |
OLD | NEW |