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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/sys_utils.h" | |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "cc/base/switches.h" | 19 #include "cc/base/switches.h" |
19 #include "cc/debug/benchmark_instrumentation.h" | 20 #include "cc/debug/benchmark_instrumentation.h" |
20 #include "cc/output/output_surface.h" | 21 #include "cc/output/output_surface.h" |
21 #include "cc/trees/layer_tree_host.h" | 22 #include "cc/trees/layer_tree_host.h" |
22 #include "content/child/npapi/webplugin.h" | 23 #include "content/child/npapi/webplugin.h" |
23 #include "content/common/gpu/client/context_provider_command_buffer.h" | 24 #include "content/common/gpu/client/context_provider_command_buffer.h" |
24 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 25 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
25 #include "content/common/gpu/gpu_process_launch_causes.h" | 26 #include "content/common/gpu/gpu_process_launch_causes.h" |
26 #include "content/common/input/synthetic_gesture_packet.h" | 27 #include "content/common/input/synthetic_gesture_packet.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 #include "ui/base/ui_base_switches.h" | 61 #include "ui/base/ui_base_switches.h" |
61 #include "ui/gfx/frame_time.h" | 62 #include "ui/gfx/frame_time.h" |
62 #include "ui/gfx/rect_conversions.h" | 63 #include "ui/gfx/rect_conversions.h" |
63 #include "ui/gfx/size_conversions.h" | 64 #include "ui/gfx/size_conversions.h" |
64 #include "ui/gfx/skia_util.h" | 65 #include "ui/gfx/skia_util.h" |
65 #include "ui/gl/gl_switches.h" | 66 #include "ui/gl/gl_switches.h" |
66 #include "ui/surface/transport_dib.h" | 67 #include "ui/surface/transport_dib.h" |
67 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h" | 68 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h" |
68 | 69 |
69 #if defined(OS_ANDROID) | 70 #if defined(OS_ANDROID) |
70 #include "base/android/sys_utils.h" | |
71 #include "content/renderer/android/synchronous_compositor_factory.h" | 71 #include "content/renderer/android/synchronous_compositor_factory.h" |
72 #endif | 72 #endif |
73 | 73 |
74 #if defined(OS_POSIX) | 74 #if defined(OS_POSIX) |
75 #include "ipc/ipc_channel_posix.h" | 75 #include "ipc/ipc_channel_posix.h" |
76 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 76 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
77 #include "third_party/skia/include/core/SkPixelRef.h" | 77 #include "third_party/skia/include/core/SkPixelRef.h" |
78 #endif // defined(OS_POSIX) | 78 #endif // defined(OS_POSIX) |
79 | 79 |
80 #include "third_party/WebKit/public/web/WebWidget.h" | 80 #include "third_party/WebKit/public/web/WebWidget.h" |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
925 return scoped_ptr<cc::OutputSurface>( | 925 return scoped_ptr<cc::OutputSurface>( |
926 new DelegatedCompositorOutputSurface( | 926 new DelegatedCompositorOutputSurface( |
927 routing_id(), | 927 routing_id(), |
928 output_surface_id, | 928 output_surface_id, |
929 context_provider, | 929 context_provider, |
930 scoped_ptr<cc::SoftwareOutputDevice>())); | 930 scoped_ptr<cc::SoftwareOutputDevice>())); |
931 } | 931 } |
932 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { | 932 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { |
933 DCHECK(is_threaded_compositing_enabled_); | 933 DCHECK(is_threaded_compositing_enabled_); |
934 cc::ResourceFormat format = cc::RGBA_8888; | 934 cc::ResourceFormat format = cc::RGBA_8888; |
935 #if defined(OS_ANDROID) | 935 if (base::SysUtils::IsLowEndDevice()) |
936 if (base::android::SysUtils::IsLowEndDevice()) | |
937 format = cc::RGB_565; | 936 format = cc::RGB_565; |
938 #endif | |
939 return scoped_ptr<cc::OutputSurface>( | 937 return scoped_ptr<cc::OutputSurface>( |
940 new MailboxOutputSurface( | 938 new MailboxOutputSurface( |
941 routing_id(), | 939 routing_id(), |
942 output_surface_id, | 940 output_surface_id, |
943 context_provider, | 941 context_provider, |
944 scoped_ptr<cc::SoftwareOutputDevice>(), | 942 scoped_ptr<cc::SoftwareOutputDevice>(), |
945 format)); | 943 format)); |
946 } | 944 } |
947 bool use_swap_compositor_frame_message = false; | 945 bool use_swap_compositor_frame_message = false; |
948 return scoped_ptr<cc::OutputSurface>( | 946 return scoped_ptr<cc::OutputSurface>( |
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2827 if (!RenderThreadImpl::current()) | 2825 if (!RenderThreadImpl::current()) |
2828 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2826 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
2829 CauseForGpuLaunch cause = | 2827 CauseForGpuLaunch cause = |
2830 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 2828 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
2831 scoped_refptr<GpuChannelHost> gpu_channel_host( | 2829 scoped_refptr<GpuChannelHost> gpu_channel_host( |
2832 RenderThreadImpl::current()->EstablishGpuChannelSync(cause)); | 2830 RenderThreadImpl::current()->EstablishGpuChannelSync(cause)); |
2833 if (!gpu_channel_host) | 2831 if (!gpu_channel_host) |
2834 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2832 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
2835 | 2833 |
2836 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | 2834 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
2837 #if defined(OS_ANDROID) | 2835 |
2838 // If we raster too fast we become upload bound, and pending | 2836 // If we raster too fast we become upload bound, and pending |
2839 // uploads consume memory. For maximum upload throughput, we would | 2837 // uploads consume memory. For maximum upload throughput, we would |
2840 // want to allow for upload_throughput * pipeline_time of pending | 2838 // want to allow for upload_throughput * pipeline_time of pending |
2841 // uploads, after which we are just wasting memory. Since we don't | 2839 // uploads, after which we are just wasting memory. Since we don't |
2842 // know our upload throughput yet, this just caps our memory usage. | 2840 // know our upload throughput yet, this just caps our memory usage. |
2843 size_t divider = 1; | 2841 size_t divider = 1; |
2844 if (base::android::SysUtils::IsLowEndDevice()) | 2842 if (base::SysUtils::IsLowEndDevice()) |
2845 divider = 6; | 2843 divider = 6; |
2846 // For reference Nexus10 can upload 1MB in about 2.5ms. | 2844 // For reference Nexus10 can upload 1MB in about 2.5ms. |
2847 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); | 2845 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); |
2848 // Deadline to draw a frame to achieve 60 frames per second. | 2846 // Deadline to draw a frame to achieve 60 frames per second. |
2849 const size_t kMillisecondsPerFrame = 16; | 2847 const size_t kMillisecondsPerFrame = 16; |
2850 // Assuming a two frame deep pipeline between the CPU and the GPU. | 2848 // Assuming a two frame deep pipeline between the CPU and the GPU. |
2851 size_t max_transfer_buffer_usage_mb = | 2849 size_t max_transfer_buffer_usage_mb = |
2852 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); | 2850 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); |
2853 static const size_t kBytesPerMegabyte = 1024 * 1024; | 2851 static const size_t kBytesPerMegabyte = 1024 * 1024; |
2854 // We keep the MappedMemoryReclaimLimit the same as the upload limit | 2852 // We keep the MappedMemoryReclaimLimit the same as the upload limit |
2855 // to avoid unnecessarily stalling the compositor thread. | 2853 // to avoid unnecessarily stalling the compositor thread. |
2856 limits.mapped_memory_reclaim_limit = | 2854 limits.mapped_memory_reclaim_limit = |
2857 max_transfer_buffer_usage_mb * kBytesPerMegabyte; | 2855 max_transfer_buffer_usage_mb * kBytesPerMegabyte; |
piman
2014/01/08 04:41:50
This changes behavior for non-low-end devices too.
ostap
2014/01/20 08:12:24
Done.
| |
2858 #endif | |
2859 | 2856 |
2860 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 2857 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
2861 new WebGraphicsContext3DCommandBufferImpl( | 2858 new WebGraphicsContext3DCommandBufferImpl( |
2862 surface_id(), | 2859 surface_id(), |
2863 GetURLForGraphicsContext3D(), | 2860 GetURLForGraphicsContext3D(), |
2864 gpu_channel_host.get(), | 2861 gpu_channel_host.get(), |
2865 attributes, | 2862 attributes, |
2866 false /* bind generates resources */, | 2863 false /* bind generates resources */, |
2867 limits)); | 2864 limits)); |
2868 return context.Pass(); | 2865 return context.Pass(); |
2869 } | 2866 } |
2870 | 2867 |
2871 } // namespace content | 2868 } // namespace content |
OLD | NEW |