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

Side by Side Diff: content/renderer/render_widget.cc

Issue 119493005: Expose a low-end device mode override flags for non-android OSs as well (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Put low end device detection under the flag for all platforms except android. Created 6 years, 11 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
OLDNEW
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/debug/trace_event_synthetic_delay.h" 10 #include "base/debug/trace_event_synthetic_delay.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/sys_utils.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "cc/base/switches.h" 20 #include "cc/base/switches.h"
20 #include "cc/debug/benchmark_instrumentation.h" 21 #include "cc/debug/benchmark_instrumentation.h"
21 #include "cc/output/output_surface.h" 22 #include "cc/output/output_surface.h"
22 #include "cc/trees/layer_tree_host.h" 23 #include "cc/trees/layer_tree_host.h"
23 #include "content/child/npapi/webplugin.h" 24 #include "content/child/npapi/webplugin.h"
24 #include "content/common/gpu/client/context_provider_command_buffer.h" 25 #include "content/common/gpu/client/context_provider_command_buffer.h"
25 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 26 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
26 #include "content/common/gpu/gpu_process_launch_causes.h" 27 #include "content/common/gpu/gpu_process_launch_causes.h"
27 #include "content/common/input/synthetic_gesture_packet.h" 28 #include "content/common/input/synthetic_gesture_packet.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "ui/base/ui_base_switches.h" 62 #include "ui/base/ui_base_switches.h"
62 #include "ui/gfx/frame_time.h" 63 #include "ui/gfx/frame_time.h"
63 #include "ui/gfx/rect_conversions.h" 64 #include "ui/gfx/rect_conversions.h"
64 #include "ui/gfx/size_conversions.h" 65 #include "ui/gfx/size_conversions.h"
65 #include "ui/gfx/skia_util.h" 66 #include "ui/gfx/skia_util.h"
66 #include "ui/gl/gl_switches.h" 67 #include "ui/gl/gl_switches.h"
67 #include "ui/surface/transport_dib.h" 68 #include "ui/surface/transport_dib.h"
68 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h" 69 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h"
69 70
70 #if defined(OS_ANDROID) 71 #if defined(OS_ANDROID)
71 #include "base/android/sys_utils.h"
72 #include "content/renderer/android/synchronous_compositor_factory.h" 72 #include "content/renderer/android/synchronous_compositor_factory.h"
73 #endif 73 #endif
74 74
75 #if defined(OS_POSIX) 75 #if defined(OS_POSIX)
76 #include "ipc/ipc_channel_posix.h" 76 #include "ipc/ipc_channel_posix.h"
77 #include "third_party/skia/include/core/SkMallocPixelRef.h" 77 #include "third_party/skia/include/core/SkMallocPixelRef.h"
78 #include "third_party/skia/include/core/SkPixelRef.h" 78 #include "third_party/skia/include/core/SkPixelRef.h"
79 #endif // defined(OS_POSIX) 79 #endif // defined(OS_POSIX)
80 80
81 #include "third_party/WebKit/public/web/WebWidget.h" 81 #include "third_party/WebKit/public/web/WebWidget.h"
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 return scoped_ptr<cc::OutputSurface>( 931 return scoped_ptr<cc::OutputSurface>(
932 new DelegatedCompositorOutputSurface( 932 new DelegatedCompositorOutputSurface(
933 routing_id(), 933 routing_id(),
934 output_surface_id, 934 output_surface_id,
935 context_provider, 935 context_provider,
936 scoped_ptr<cc::SoftwareOutputDevice>())); 936 scoped_ptr<cc::SoftwareOutputDevice>()));
937 } 937 }
938 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { 938 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) {
939 DCHECK(is_threaded_compositing_enabled_); 939 DCHECK(is_threaded_compositing_enabled_);
940 cc::ResourceFormat format = cc::RGBA_8888; 940 cc::ResourceFormat format = cc::RGBA_8888;
941 #if defined(OS_ANDROID) 941 if (base::SysUtils::IsLowEndDevice())
942 if (base::android::SysUtils::IsLowEndDevice())
943 format = cc::RGB_565; 942 format = cc::RGB_565;
944 #endif
945 return scoped_ptr<cc::OutputSurface>( 943 return scoped_ptr<cc::OutputSurface>(
946 new MailboxOutputSurface( 944 new MailboxOutputSurface(
947 routing_id(), 945 routing_id(),
948 output_surface_id, 946 output_surface_id,
949 context_provider, 947 context_provider,
950 scoped_ptr<cc::SoftwareOutputDevice>(), 948 scoped_ptr<cc::SoftwareOutputDevice>(),
951 format)); 949 format));
952 } 950 }
953 bool use_swap_compositor_frame_message = false; 951 bool use_swap_compositor_frame_message = false;
954 return scoped_ptr<cc::OutputSurface>( 952 return scoped_ptr<cc::OutputSurface>(
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 if (!RenderThreadImpl::current()) 2836 if (!RenderThreadImpl::current())
2839 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 2837 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
2840 CauseForGpuLaunch cause = 2838 CauseForGpuLaunch cause =
2841 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; 2839 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
2842 scoped_refptr<GpuChannelHost> gpu_channel_host( 2840 scoped_refptr<GpuChannelHost> gpu_channel_host(
2843 RenderThreadImpl::current()->EstablishGpuChannelSync(cause)); 2841 RenderThreadImpl::current()->EstablishGpuChannelSync(cause));
2844 if (!gpu_channel_host) 2842 if (!gpu_channel_host)
2845 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 2843 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
2846 2844
2847 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; 2845 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
2848 #if defined(OS_ANDROID)
2849 // If we raster too fast we become upload bound, and pending 2846 // If we raster too fast we become upload bound, and pending
2850 // uploads consume memory. For maximum upload throughput, we would 2847 // uploads consume memory. For maximum upload throughput, we would
2851 // want to allow for upload_throughput * pipeline_time of pending 2848 // want to allow for upload_throughput * pipeline_time of pending
2852 // uploads, after which we are just wasting memory. Since we don't 2849 // uploads, after which we are just wasting memory. Since we don't
2853 // know our upload throughput yet, this just caps our memory usage. 2850 // know our upload throughput yet, this just caps our memory usage.
2854 size_t divider = 1; 2851
2855 if (base::android::SysUtils::IsLowEndDevice())
2856 divider = 6;
2857 // For reference Nexus10 can upload 1MB in about 2.5ms. 2852 // For reference Nexus10 can upload 1MB in about 2.5ms.
2858 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); 2853 const double max_mb_uploaded_per_ms = 2.0 / 5;
2859 // Deadline to draw a frame to achieve 60 frames per second. 2854 // Deadline to draw a frame to achieve 60 frames per second.
2860 const size_t kMillisecondsPerFrame = 16; 2855 const size_t kMillisecondsPerFrame = 16;
2861 // Assuming a two frame deep pipeline between the CPU and the GPU. 2856 // Assuming a two frame deep pipeline between the CPU and the GPU.
2862 size_t max_transfer_buffer_usage_mb = 2857 const size_t max_transfer_buffer_usage_mb =
2863 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); 2858 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms);
2864 static const size_t kBytesPerMegabyte = 1024 * 1024; 2859 static const size_t kBytesPerMegabyte = 1024 * 1024;
2865 // We keep the MappedMemoryReclaimLimit the same as the upload limit 2860 // We keep the MappedMemoryReclaimLimit the same as the upload limit
2866 // to avoid unnecessarily stalling the compositor thread. 2861 // to avoid unnecessarily stalling the compositor thread.
2867 limits.mapped_memory_reclaim_limit = 2862 if (base::SysUtils::IsLowEndDevice())
piman 2014/01/21 21:23:49 needs braces
2868 max_transfer_buffer_usage_mb * kBytesPerMegabyte; 2863 limits.mapped_memory_reclaim_limit =
2864 max_transfer_buffer_usage_mb / 6 * kBytesPerMegabyte;
2865 #if defined(OS_ANDROID)
2866 else
2867 limits.mapped_memory_reclaim_limit =
2868 max_transfer_buffer_usage_mb * kBytesPerMegabyte;
2869 #endif 2869 #endif
2870 2870
2871 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( 2871 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
2872 new WebGraphicsContext3DCommandBufferImpl( 2872 new WebGraphicsContext3DCommandBufferImpl(
2873 surface_id(), 2873 surface_id(),
2874 GetURLForGraphicsContext3D(), 2874 GetURLForGraphicsContext3D(),
2875 gpu_channel_host.get(), 2875 gpu_channel_host.get(),
2876 attributes, 2876 attributes,
2877 false /* bind generates resources */, 2877 false /* bind generates resources */,
2878 limits)); 2878 limits));
2879 return context.Pass(); 2879 return context.Pass();
2880 } 2880 }
2881 2881
2882 } // namespace content 2882 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698