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/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 Loading... |
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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 true)); | 887 true)); |
888 } | 888 } |
889 | 889 |
890 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { | 890 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { |
891 // Composite-to-mailbox is currently used for layout tests in order to cause | 891 // Composite-to-mailbox is currently used for layout tests in order to cause |
892 // them to draw inside in the renderer to do the readback there. This should | 892 // them to draw inside in the renderer to do the readback there. This should |
893 // no longer be the case when crbug.com/311404 is fixed. | 893 // no longer be the case when crbug.com/311404 is fixed. |
894 DCHECK(is_threaded_compositing_enabled_ || | 894 DCHECK(is_threaded_compositing_enabled_ || |
895 RenderThreadImpl::current()->layout_test_mode()); | 895 RenderThreadImpl::current()->layout_test_mode()); |
896 cc::ResourceFormat format = cc::RGBA_8888; | 896 cc::ResourceFormat format = cc::RGBA_8888; |
897 #if defined(OS_ANDROID) | 897 if (base::SysUtils::IsLowEndDevice()) |
898 if (base::android::SysUtils::IsLowEndDevice()) | |
899 format = cc::RGB_565; | 898 format = cc::RGB_565; |
900 #endif | |
901 return scoped_ptr<cc::OutputSurface>( | 899 return scoped_ptr<cc::OutputSurface>( |
902 new MailboxOutputSurface( | 900 new MailboxOutputSurface( |
903 routing_id(), | 901 routing_id(), |
904 output_surface_id, | 902 output_surface_id, |
905 context_provider, | 903 context_provider, |
906 scoped_ptr<cc::SoftwareOutputDevice>(), | 904 scoped_ptr<cc::SoftwareOutputDevice>(), |
907 format)); | 905 format)); |
908 } | 906 } |
909 bool use_swap_compositor_frame_message = false; | 907 bool use_swap_compositor_frame_message = false; |
910 return scoped_ptr<cc::OutputSurface>( | 908 return scoped_ptr<cc::OutputSurface>( |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2303 attributes.stencil = false; | 2301 attributes.stencil = false; |
2304 bool lose_context_when_out_of_memory = true; | 2302 bool lose_context_when_out_of_memory = true; |
2305 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | 2303 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
2306 #if defined(OS_ANDROID) | 2304 #if defined(OS_ANDROID) |
2307 // If we raster too fast we become upload bound, and pending | 2305 // If we raster too fast we become upload bound, and pending |
2308 // uploads consume memory. For maximum upload throughput, we would | 2306 // uploads consume memory. For maximum upload throughput, we would |
2309 // want to allow for upload_throughput * pipeline_time of pending | 2307 // want to allow for upload_throughput * pipeline_time of pending |
2310 // uploads, after which we are just wasting memory. Since we don't | 2308 // uploads, after which we are just wasting memory. Since we don't |
2311 // know our upload throughput yet, this just caps our memory usage. | 2309 // know our upload throughput yet, this just caps our memory usage. |
2312 size_t divider = 1; | 2310 size_t divider = 1; |
2313 if (base::android::SysUtils::IsLowEndDevice()) | 2311 if (base::SysUtils::IsLowEndDevice()) |
2314 divider = 6; | 2312 divider = 6; |
2315 // For reference Nexus10 can upload 1MB in about 2.5ms. | 2313 // For reference Nexus10 can upload 1MB in about 2.5ms. |
2316 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); | 2314 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); |
2317 // Deadline to draw a frame to achieve 60 frames per second. | 2315 // Deadline to draw a frame to achieve 60 frames per second. |
2318 const size_t kMillisecondsPerFrame = 16; | 2316 const size_t kMillisecondsPerFrame = 16; |
2319 // Assuming a two frame deep pipeline between the CPU and the GPU. | 2317 // Assuming a two frame deep pipeline between the CPU and the GPU. |
2320 size_t max_transfer_buffer_usage_mb = | 2318 size_t max_transfer_buffer_usage_mb = |
2321 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); | 2319 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); |
2322 static const size_t kBytesPerMegabyte = 1024 * 1024; | 2320 static const size_t kBytesPerMegabyte = 1024 * 1024; |
2323 // We keep the MappedMemoryReclaimLimit the same as the upload limit | 2321 // We keep the MappedMemoryReclaimLimit the same as the upload limit |
(...skipping 15 matching lines...) Expand all Loading... |
2339 | 2337 |
2340 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2338 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2341 swapped_out_frames_.AddObserver(frame); | 2339 swapped_out_frames_.AddObserver(frame); |
2342 } | 2340 } |
2343 | 2341 |
2344 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2342 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2345 swapped_out_frames_.RemoveObserver(frame); | 2343 swapped_out_frames_.RemoveObserver(frame); |
2346 } | 2344 } |
2347 | 2345 |
2348 } // namespace content | 2346 } // namespace content |
OLD | NEW |