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

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: Created 6 years, 8 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "ui/gfx/frame_time.h" 65 #include "ui/gfx/frame_time.h"
65 #include "ui/gfx/point_conversions.h" 66 #include "ui/gfx/point_conversions.h"
66 #include "ui/gfx/rect_conversions.h" 67 #include "ui/gfx/rect_conversions.h"
67 #include "ui/gfx/size_conversions.h" 68 #include "ui/gfx/size_conversions.h"
68 #include "ui/gfx/skia_util.h" 69 #include "ui/gfx/skia_util.h"
69 #include "ui/gl/gl_switches.h" 70 #include "ui/gl/gl_switches.h"
70 #include "ui/surface/transport_dib.h" 71 #include "ui/surface/transport_dib.h"
71 72
72 #if defined(OS_ANDROID) 73 #if defined(OS_ANDROID)
73 #include <android/keycodes.h> 74 #include <android/keycodes.h>
74 #include "base/android/sys_utils.h"
75 #include "content/renderer/android/synchronous_compositor_factory.h" 75 #include "content/renderer/android/synchronous_compositor_factory.h"
76 #endif 76 #endif
77 77
78 #if defined(OS_POSIX) 78 #if defined(OS_POSIX)
79 #include "ipc/ipc_channel_posix.h" 79 #include "ipc/ipc_channel_posix.h"
80 #include "third_party/skia/include/core/SkMallocPixelRef.h" 80 #include "third_party/skia/include/core/SkMallocPixelRef.h"
81 #include "third_party/skia/include/core/SkPixelRef.h" 81 #include "third_party/skia/include/core/SkPixelRef.h"
82 #endif // defined(OS_POSIX) 82 #endif // defined(OS_POSIX)
83 83
84 #include "third_party/WebKit/public/web/WebWidget.h" 84 #include "third_party/WebKit/public/web/WebWidget.h"
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 true)); 877 true));
878 } 878 }
879 879
880 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { 880 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) {
881 // Composite-to-mailbox is currently used for layout tests in order to cause 881 // Composite-to-mailbox is currently used for layout tests in order to cause
882 // them to draw inside in the renderer to do the readback there. This should 882 // them to draw inside in the renderer to do the readback there. This should
883 // no longer be the case when crbug.com/311404 is fixed. 883 // no longer be the case when crbug.com/311404 is fixed.
884 DCHECK(is_threaded_compositing_enabled_ || 884 DCHECK(is_threaded_compositing_enabled_ ||
885 RenderThreadImpl::current()->layout_test_mode()); 885 RenderThreadImpl::current()->layout_test_mode());
886 cc::ResourceFormat format = cc::RGBA_8888; 886 cc::ResourceFormat format = cc::RGBA_8888;
887 #if defined(OS_ANDROID) 887 if (base::SysUtils::IsLowEndDevice())
888 if (base::android::SysUtils::IsLowEndDevice())
889 format = cc::RGB_565; 888 format = cc::RGB_565;
890 #endif
891 return scoped_ptr<cc::OutputSurface>( 889 return scoped_ptr<cc::OutputSurface>(
892 new MailboxOutputSurface( 890 new MailboxOutputSurface(
893 routing_id(), 891 routing_id(),
894 output_surface_id, 892 output_surface_id,
895 context_provider, 893 context_provider,
896 scoped_ptr<cc::SoftwareOutputDevice>(), 894 scoped_ptr<cc::SoftwareOutputDevice>(),
897 format)); 895 format));
898 } 896 }
899 bool use_swap_compositor_frame_message = false; 897 bool use_swap_compositor_frame_message = false;
900 return scoped_ptr<cc::OutputSurface>( 898 return scoped_ptr<cc::OutputSurface>(
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 attributes.stencil = false; 2330 attributes.stencil = false;
2333 bool lose_context_when_out_of_memory = true; 2331 bool lose_context_when_out_of_memory = true;
2334 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; 2332 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
2335 #if defined(OS_ANDROID) 2333 #if defined(OS_ANDROID)
2336 // If we raster too fast we become upload bound, and pending 2334 // If we raster too fast we become upload bound, and pending
2337 // uploads consume memory. For maximum upload throughput, we would 2335 // uploads consume memory. For maximum upload throughput, we would
2338 // want to allow for upload_throughput * pipeline_time of pending 2336 // want to allow for upload_throughput * pipeline_time of pending
2339 // uploads, after which we are just wasting memory. Since we don't 2337 // uploads, after which we are just wasting memory. Since we don't
2340 // know our upload throughput yet, this just caps our memory usage. 2338 // know our upload throughput yet, this just caps our memory usage.
2341 size_t divider = 1; 2339 size_t divider = 1;
2342 if (base::android::SysUtils::IsLowEndDevice()) 2340 if (base::SysUtils::IsLowEndDevice())
2343 divider = 6; 2341 divider = 6;
2344 // For reference Nexus10 can upload 1MB in about 2.5ms. 2342 // For reference Nexus10 can upload 1MB in about 2.5ms.
2345 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); 2343 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider);
2346 // Deadline to draw a frame to achieve 60 frames per second. 2344 // Deadline to draw a frame to achieve 60 frames per second.
2347 const size_t kMillisecondsPerFrame = 16; 2345 const size_t kMillisecondsPerFrame = 16;
2348 // 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.
2349 size_t max_transfer_buffer_usage_mb = 2347 size_t max_transfer_buffer_usage_mb =
2350 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); 2348 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms);
2351 static const size_t kBytesPerMegabyte = 1024 * 1024; 2349 static const size_t kBytesPerMegabyte = 1024 * 1024;
2352 // We keep the MappedMemoryReclaimLimit the same as the upload limit 2350 // We keep the MappedMemoryReclaimLimit the same as the upload limit
(...skipping 15 matching lines...) Expand all
2368 2366
2369 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { 2367 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) {
2370 swapped_out_frames_.AddObserver(frame); 2368 swapped_out_frames_.AddObserver(frame);
2371 } 2369 }
2372 2370
2373 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { 2371 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) {
2374 swapped_out_frames_.RemoveObserver(frame); 2372 swapped_out_frames_.RemoveObserver(frame);
2375 } 2373 }
2376 2374
2377 } // namespace content 2375 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698