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/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_utils.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 Loading... |
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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 true)); | 860 true)); |
861 } | 861 } |
862 | 862 |
863 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { | 863 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { |
864 // Composite-to-mailbox is currently used for layout tests in order to cause | 864 // Composite-to-mailbox is currently used for layout tests in order to cause |
865 // them to draw inside in the renderer to do the readback there. This should | 865 // them to draw inside in the renderer to do the readback there. This should |
866 // no longer be the case when crbug.com/311404 is fixed. | 866 // no longer be the case when crbug.com/311404 is fixed. |
867 DCHECK(is_threaded_compositing_enabled_ || | 867 DCHECK(is_threaded_compositing_enabled_ || |
868 RenderThreadImpl::current()->layout_test_mode()); | 868 RenderThreadImpl::current()->layout_test_mode()); |
869 cc::ResourceFormat format = cc::RGBA_8888; | 869 cc::ResourceFormat format = cc::RGBA_8888; |
870 #if defined(OS_ANDROID) | 870 if (base::SysUtils::IsLowEndDevice()) |
871 if (base::android::SysUtils::IsLowEndDevice()) | |
872 format = cc::RGB_565; | 871 format = cc::RGB_565; |
873 #endif | |
874 return scoped_ptr<cc::OutputSurface>( | 872 return scoped_ptr<cc::OutputSurface>( |
875 new MailboxOutputSurface( | 873 new MailboxOutputSurface( |
876 routing_id(), | 874 routing_id(), |
877 output_surface_id, | 875 output_surface_id, |
878 context_provider, | 876 context_provider, |
879 scoped_ptr<cc::SoftwareOutputDevice>(), | 877 scoped_ptr<cc::SoftwareOutputDevice>(), |
880 format)); | 878 format)); |
881 } | 879 } |
882 bool use_swap_compositor_frame_message = false; | 880 bool use_swap_compositor_frame_message = false; |
883 return scoped_ptr<cc::OutputSurface>( | 881 return scoped_ptr<cc::OutputSurface>( |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 attributes.stencil = false; | 2083 attributes.stencil = false; |
2086 bool lose_context_when_out_of_memory = true; | 2084 bool lose_context_when_out_of_memory = true; |
2087 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | 2085 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
2088 #if defined(OS_ANDROID) | 2086 #if defined(OS_ANDROID) |
2089 // If we raster too fast we become upload bound, and pending | 2087 // If we raster too fast we become upload bound, and pending |
2090 // uploads consume memory. For maximum upload throughput, we would | 2088 // uploads consume memory. For maximum upload throughput, we would |
2091 // want to allow for upload_throughput * pipeline_time of pending | 2089 // want to allow for upload_throughput * pipeline_time of pending |
2092 // uploads, after which we are just wasting memory. Since we don't | 2090 // uploads, after which we are just wasting memory. Since we don't |
2093 // know our upload throughput yet, this just caps our memory usage. | 2091 // know our upload throughput yet, this just caps our memory usage. |
2094 size_t divider = 1; | 2092 size_t divider = 1; |
2095 if (base::android::SysUtils::IsLowEndDevice()) | 2093 if (base::SysUtils::IsLowEndDevice()) |
2096 divider = 6; | 2094 divider = 6; |
2097 // For reference Nexus10 can upload 1MB in about 2.5ms. | 2095 // For reference Nexus10 can upload 1MB in about 2.5ms. |
2098 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); | 2096 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); |
2099 // Deadline to draw a frame to achieve 60 frames per second. | 2097 // Deadline to draw a frame to achieve 60 frames per second. |
2100 const size_t kMillisecondsPerFrame = 16; | 2098 const size_t kMillisecondsPerFrame = 16; |
2101 // Assuming a two frame deep pipeline between the CPU and the GPU. | 2099 // Assuming a two frame deep pipeline between the CPU and the GPU. |
2102 size_t max_transfer_buffer_usage_mb = | 2100 size_t max_transfer_buffer_usage_mb = |
2103 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); | 2101 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); |
2104 static const size_t kBytesPerMegabyte = 1024 * 1024; | 2102 static const size_t kBytesPerMegabyte = 1024 * 1024; |
2105 // We keep the MappedMemoryReclaimLimit the same as the upload limit | 2103 // We keep the MappedMemoryReclaimLimit the same as the upload limit |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2139 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2137 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2140 video_hole_frames_.AddObserver(frame); | 2138 video_hole_frames_.AddObserver(frame); |
2141 } | 2139 } |
2142 | 2140 |
2143 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2141 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2144 video_hole_frames_.RemoveObserver(frame); | 2142 video_hole_frames_.RemoveObserver(frame); |
2145 } | 2143 } |
2146 #endif // defined(VIDEO_HOLE) | 2144 #endif // defined(VIDEO_HOLE) |
2147 | 2145 |
2148 } // namespace content | 2146 } // namespace content |
OLD | NEW |