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 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 | 962 |
963 GURL RenderWidget::GetURLForGraphicsContext3D() { | 963 GURL RenderWidget::GetURLForGraphicsContext3D() { |
964 return GURL(); | 964 return GURL(); |
965 } | 965 } |
966 | 966 |
967 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { | 967 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { |
968 // For widgets that are never visible, we don't start the compositor, so we | 968 // For widgets that are never visible, we don't start the compositor, so we |
969 // never get a request for a cc::OutputSurface. | 969 // never get a request for a cc::OutputSurface. |
970 DCHECK(!compositor_never_visible_); | 970 DCHECK(!compositor_never_visible_); |
971 | 971 |
972 #if defined(OS_ANDROID) | |
973 if (SynchronousCompositorFactory* factory = | |
974 SynchronousCompositorFactory::GetInstance()) { | |
975 return factory->CreateOutputSurface(routing_id(), | |
976 frame_swap_message_queue_); | |
977 } | |
978 #endif | |
979 | |
980 const base::CommandLine& command_line = | 972 const base::CommandLine& command_line = |
981 *base::CommandLine::ForCurrentProcess(); | 973 *base::CommandLine::ForCurrentProcess(); |
982 bool use_software = fallback; | 974 bool use_software = fallback; |
983 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) | 975 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) |
984 use_software = true; | 976 use_software = true; |
985 | 977 |
986 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 978 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
987 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider; | 979 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider; |
988 if (!use_software) { | 980 if (!use_software) { |
989 context_provider = ContextProviderCommandBuffer::Create( | 981 context_provider = ContextProviderCommandBuffer::Create( |
990 CreateGraphicsContext3D(true), RENDER_COMPOSITOR_CONTEXT); | 982 CreateGraphicsContext3D(true), RENDER_COMPOSITOR_CONTEXT); |
991 if (!context_provider.get()) { | 983 if (!context_provider.get()) { |
992 // Cause the compositor to wait and try again. | 984 // Cause the compositor to wait and try again. |
993 return nullptr; | 985 return nullptr; |
994 } | 986 } |
995 worker_context_provider = | 987 worker_context_provider = |
996 RenderThreadImpl::current()->SharedWorkerContextProvider(); | 988 RenderThreadImpl::current()->SharedWorkerContextProvider(); |
997 if (!worker_context_provider) { | 989 if (!worker_context_provider) { |
998 // Cause the compositor to wait and try again. | 990 // Cause the compositor to wait and try again. |
999 return nullptr; | 991 return nullptr; |
1000 } | 992 } |
| 993 |
| 994 #if defined(OS_ANDROID) |
| 995 if (SynchronousCompositorFactory* factory = |
| 996 SynchronousCompositorFactory::GetInstance()) { |
| 997 return factory->CreateOutputSurface( |
| 998 routing_id(), frame_swap_message_queue_, context_provider, |
| 999 worker_context_provider); |
| 1000 } |
| 1001 #endif |
1001 } | 1002 } |
1002 | 1003 |
1003 uint32 output_surface_id = next_output_surface_id_++; | 1004 uint32 output_surface_id = next_output_surface_id_++; |
1004 // Composite-to-mailbox is currently used for layout tests in order to cause | 1005 // Composite-to-mailbox is currently used for layout tests in order to cause |
1005 // them to draw inside in the renderer to do the readback there. This should | 1006 // them to draw inside in the renderer to do the readback there. This should |
1006 // no longer be the case when crbug.com/311404 is fixed. | 1007 // no longer be the case when crbug.com/311404 is fixed. |
1007 if (!RenderThreadImpl::current() || | 1008 if (!RenderThreadImpl::current() || |
1008 !RenderThreadImpl::current()->layout_test_mode()) { | 1009 !RenderThreadImpl::current()->layout_test_mode()) { |
1009 DCHECK(compositor_deps_->GetCompositorImplThreadTaskRunner()); | 1010 DCHECK(compositor_deps_->GetCompositorImplThreadTaskRunner()); |
1010 return make_scoped_ptr(new DelegatedCompositorOutputSurface( | 1011 return make_scoped_ptr(new DelegatedCompositorOutputSurface( |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2318 // disparities we explicitly disable antialiasing. | 2319 // disparities we explicitly disable antialiasing. |
2319 blink::WebGraphicsContext3D::Attributes attributes; | 2320 blink::WebGraphicsContext3D::Attributes attributes; |
2320 attributes.antialias = false; | 2321 attributes.antialias = false; |
2321 attributes.shareResources = true; | 2322 attributes.shareResources = true; |
2322 attributes.noAutomaticFlushes = true; | 2323 attributes.noAutomaticFlushes = true; |
2323 attributes.depth = false; | 2324 attributes.depth = false; |
2324 attributes.stencil = false; | 2325 attributes.stencil = false; |
2325 bool lose_context_when_out_of_memory = true; | 2326 bool lose_context_when_out_of_memory = true; |
2326 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | 2327 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
2327 #if defined(OS_ANDROID) | 2328 #if defined(OS_ANDROID) |
| 2329 bool using_synchronous_compositing = |
| 2330 SynchronousCompositorFactory::GetInstance(); |
2328 // If we raster too fast we become upload bound, and pending | 2331 // If we raster too fast we become upload bound, and pending |
2329 // uploads consume memory. For maximum upload throughput, we would | 2332 // uploads consume memory. For maximum upload throughput, we would |
2330 // want to allow for upload_throughput * pipeline_time of pending | 2333 // want to allow for upload_throughput * pipeline_time of pending |
2331 // uploads, after which we are just wasting memory. Since we don't | 2334 // uploads, after which we are just wasting memory. Since we don't |
2332 // know our upload throughput yet, this just caps our memory usage. | 2335 // know our upload throughput yet, this just caps our memory usage. |
2333 size_t divider = 1; | 2336 // Synchronous compositor uses half because synchronous compositor |
| 2337 // pipeline is only one frame deep. But twice of half for low end |
| 2338 // because 16bit texture is not supported. |
| 2339 size_t divider = using_synchronous_compositing ? 2 : 1; |
2334 if (base::SysInfo::IsLowEndDevice()) | 2340 if (base::SysInfo::IsLowEndDevice()) |
2335 divider = 6; | 2341 divider = 6; |
2336 // For reference Nexus10 can upload 1MB in about 2.5ms. | 2342 // For reference Nexus10 can upload 1MB in about 2.5ms. |
2337 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); | 2343 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); |
2338 // Deadline to draw a frame to achieve 60 frames per second. | 2344 // Deadline to draw a frame to achieve 60 frames per second. |
2339 const size_t kMillisecondsPerFrame = 16; | 2345 const size_t kMillisecondsPerFrame = 16; |
2340 // Assuming a two frame deep pipeline between the CPU and the GPU. | 2346 // Assuming a two frame deep pipeline between the CPU and the GPU. |
2341 size_t max_transfer_buffer_usage_mb = | 2347 size_t max_transfer_buffer_usage_mb = |
2342 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); | 2348 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); |
2343 static const size_t kBytesPerMegabyte = 1024 * 1024; | 2349 static const size_t kBytesPerMegabyte = 1024 * 1024; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2385 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2380 video_hole_frames_.AddObserver(frame); | 2386 video_hole_frames_.AddObserver(frame); |
2381 } | 2387 } |
2382 | 2388 |
2383 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2389 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2384 video_hole_frames_.RemoveObserver(frame); | 2390 video_hole_frames_.RemoveObserver(frame); |
2385 } | 2391 } |
2386 #endif // defined(VIDEO_HOLE) | 2392 #endif // defined(VIDEO_HOLE) |
2387 | 2393 |
2388 } // namespace content | 2394 } // namespace content |
OLD | NEW |