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

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

Issue 258663002: Expose a low-end device mode override flags for non-android OSs as well (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix builds. Created 6 years, 6 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/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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/debug/trace_event_synthetic_delay.h" 11 #include "base/debug/trace_event_synthetic_delay.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/sys_info.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
20 #include "cc/base/switches.h" 21 #include "cc/base/switches.h"
21 #include "cc/debug/benchmark_instrumentation.h" 22 #include "cc/debug/benchmark_instrumentation.h"
22 #include "cc/output/output_surface.h" 23 #include "cc/output/output_surface.h"
23 #include "cc/trees/layer_tree_host.h" 24 #include "cc/trees/layer_tree_host.h"
24 #include "content/child/npapi/webplugin.h" 25 #include "content/child/npapi/webplugin.h"
25 #include "content/common/gpu/client/context_provider_command_buffer.h" 26 #include "content/common/gpu/client/context_provider_command_buffer.h"
26 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 27 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
27 #include "content/common/gpu/gpu_process_launch_causes.h" 28 #include "content/common/gpu/gpu_process_launch_causes.h"
28 #include "content/common/input/synthetic_gesture_packet.h" 29 #include "content/common/input/synthetic_gesture_packet.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "ui/gfx/frame_time.h" 66 #include "ui/gfx/frame_time.h"
66 #include "ui/gfx/point_conversions.h" 67 #include "ui/gfx/point_conversions.h"
67 #include "ui/gfx/rect_conversions.h" 68 #include "ui/gfx/rect_conversions.h"
68 #include "ui/gfx/size_conversions.h" 69 #include "ui/gfx/size_conversions.h"
69 #include "ui/gfx/skia_util.h" 70 #include "ui/gfx/skia_util.h"
70 #include "ui/gl/gl_switches.h" 71 #include "ui/gl/gl_switches.h"
71 #include "ui/surface/transport_dib.h" 72 #include "ui/surface/transport_dib.h"
72 73
73 #if defined(OS_ANDROID) 74 #if defined(OS_ANDROID)
74 #include <android/keycodes.h> 75 #include <android/keycodes.h>
75 #include "base/android/sys_utils.h"
76 #include "content/renderer/android/synchronous_compositor_factory.h" 76 #include "content/renderer/android/synchronous_compositor_factory.h"
77 #endif 77 #endif
78 78
79 #if defined(OS_POSIX) 79 #if defined(OS_POSIX)
80 #include "ipc/ipc_channel_posix.h" 80 #include "ipc/ipc_channel_posix.h"
81 #include "third_party/skia/include/core/SkMallocPixelRef.h" 81 #include "third_party/skia/include/core/SkMallocPixelRef.h"
82 #include "third_party/skia/include/core/SkPixelRef.h" 82 #include "third_party/skia/include/core/SkPixelRef.h"
83 #endif // defined(OS_POSIX) 83 #endif // defined(OS_POSIX)
84 84
85 #include "third_party/WebKit/public/web/WebWidget.h" 85 #include "third_party/WebKit/public/web/WebWidget.h"
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 true)); 852 true));
853 } 853 }
854 854
855 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { 855 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) {
856 // Composite-to-mailbox is currently used for layout tests in order to cause 856 // Composite-to-mailbox is currently used for layout tests in order to cause
857 // them to draw inside in the renderer to do the readback there. This should 857 // them to draw inside in the renderer to do the readback there. This should
858 // no longer be the case when crbug.com/311404 is fixed. 858 // no longer be the case when crbug.com/311404 is fixed.
859 DCHECK(is_threaded_compositing_enabled_ || 859 DCHECK(is_threaded_compositing_enabled_ ||
860 RenderThreadImpl::current()->layout_test_mode()); 860 RenderThreadImpl::current()->layout_test_mode());
861 cc::ResourceFormat format = cc::RGBA_8888; 861 cc::ResourceFormat format = cc::RGBA_8888;
862 #if defined(OS_ANDROID) 862 if (base::SysInfo::IsLowEndDevice())
863 if (base::android::SysUtils::IsLowEndDevice())
864 format = cc::RGB_565; 863 format = cc::RGB_565;
865 #endif
866 return scoped_ptr<cc::OutputSurface>( 864 return scoped_ptr<cc::OutputSurface>(
867 new MailboxOutputSurface( 865 new MailboxOutputSurface(
868 routing_id(), 866 routing_id(),
869 output_surface_id, 867 output_surface_id,
870 context_provider, 868 context_provider,
871 scoped_ptr<cc::SoftwareOutputDevice>(), 869 scoped_ptr<cc::SoftwareOutputDevice>(),
872 format)); 870 format));
873 } 871 }
874 bool use_swap_compositor_frame_message = false; 872 bool use_swap_compositor_frame_message = false;
875 return scoped_ptr<cc::OutputSurface>( 873 return scoped_ptr<cc::OutputSurface>(
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 attributes.stencil = false; 2014 attributes.stencil = false;
2017 bool lose_context_when_out_of_memory = true; 2015 bool lose_context_when_out_of_memory = true;
2018 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; 2016 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
2019 #if defined(OS_ANDROID) 2017 #if defined(OS_ANDROID)
2020 // If we raster too fast we become upload bound, and pending 2018 // If we raster too fast we become upload bound, and pending
2021 // uploads consume memory. For maximum upload throughput, we would 2019 // uploads consume memory. For maximum upload throughput, we would
2022 // want to allow for upload_throughput * pipeline_time of pending 2020 // want to allow for upload_throughput * pipeline_time of pending
2023 // uploads, after which we are just wasting memory. Since we don't 2021 // uploads, after which we are just wasting memory. Since we don't
2024 // know our upload throughput yet, this just caps our memory usage. 2022 // know our upload throughput yet, this just caps our memory usage.
2025 size_t divider = 1; 2023 size_t divider = 1;
2026 if (base::android::SysUtils::IsLowEndDevice()) 2024 if (base::SysInfo::IsLowEndDevice())
2027 divider = 6; 2025 divider = 6;
2028 // For reference Nexus10 can upload 1MB in about 2.5ms. 2026 // For reference Nexus10 can upload 1MB in about 2.5ms.
2029 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); 2027 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider);
2030 // Deadline to draw a frame to achieve 60 frames per second. 2028 // Deadline to draw a frame to achieve 60 frames per second.
2031 const size_t kMillisecondsPerFrame = 16; 2029 const size_t kMillisecondsPerFrame = 16;
2032 // Assuming a two frame deep pipeline between the CPU and the GPU. 2030 // Assuming a two frame deep pipeline between the CPU and the GPU.
2033 size_t max_transfer_buffer_usage_mb = 2031 size_t max_transfer_buffer_usage_mb =
2034 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); 2032 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms);
2035 static const size_t kBytesPerMegabyte = 1024 * 1024; 2033 static const size_t kBytesPerMegabyte = 1024 * 1024;
2036 // We keep the MappedMemoryReclaimLimit the same as the upload limit 2034 // We keep the MappedMemoryReclaimLimit the same as the upload limit
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2068 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2071 video_hole_frames_.AddObserver(frame); 2069 video_hole_frames_.AddObserver(frame);
2072 } 2070 }
2073 2071
2074 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2072 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2075 video_hole_frames_.RemoveObserver(frame); 2073 video_hole_frames_.RemoveObserver(frame);
2076 } 2074 }
2077 #endif // defined(VIDEO_HOLE) 2075 #endif // defined(VIDEO_HOLE)
2078 2076
2079 } // namespace content 2077 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698