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_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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 #include "ui/gfx/frame_time.h" | 67 #include "ui/gfx/frame_time.h" |
67 #include "ui/gfx/point_conversions.h" | 68 #include "ui/gfx/point_conversions.h" |
68 #include "ui/gfx/rect_conversions.h" | 69 #include "ui/gfx/rect_conversions.h" |
69 #include "ui/gfx/size_conversions.h" | 70 #include "ui/gfx/size_conversions.h" |
70 #include "ui/gfx/skia_util.h" | 71 #include "ui/gfx/skia_util.h" |
71 #include "ui/gl/gl_switches.h" | 72 #include "ui/gl/gl_switches.h" |
72 #include "ui/surface/transport_dib.h" | 73 #include "ui/surface/transport_dib.h" |
73 | 74 |
74 #if defined(OS_ANDROID) | 75 #if defined(OS_ANDROID) |
75 #include <android/keycodes.h> | 76 #include <android/keycodes.h> |
76 #include "base/android/sys_utils.h" | |
77 #include "content/renderer/android/synchronous_compositor_factory.h" | 77 #include "content/renderer/android/synchronous_compositor_factory.h" |
78 #endif | 78 #endif |
79 | 79 |
80 #if defined(OS_POSIX) | 80 #if defined(OS_POSIX) |
81 #include "ipc/ipc_channel_posix.h" | 81 #include "ipc/ipc_channel_posix.h" |
82 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 82 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
83 #include "third_party/skia/include/core/SkPixelRef.h" | 83 #include "third_party/skia/include/core/SkPixelRef.h" |
84 #endif // defined(OS_POSIX) | 84 #endif // defined(OS_POSIX) |
85 | 85 |
86 #include "third_party/WebKit/public/web/WebWidget.h" | 86 #include "third_party/WebKit/public/web/WebWidget.h" |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 true)); | 851 true)); |
852 } | 852 } |
853 | 853 |
854 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { | 854 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { |
855 // Composite-to-mailbox is currently used for layout tests in order to cause | 855 // Composite-to-mailbox is currently used for layout tests in order to cause |
856 // them to draw inside in the renderer to do the readback there. This should | 856 // them to draw inside in the renderer to do the readback there. This should |
857 // no longer be the case when crbug.com/311404 is fixed. | 857 // no longer be the case when crbug.com/311404 is fixed. |
858 DCHECK(is_threaded_compositing_enabled_ || | 858 DCHECK(is_threaded_compositing_enabled_ || |
859 RenderThreadImpl::current()->layout_test_mode()); | 859 RenderThreadImpl::current()->layout_test_mode()); |
860 cc::ResourceFormat format = cc::RGBA_8888; | 860 cc::ResourceFormat format = cc::RGBA_8888; |
861 #if defined(OS_ANDROID) | 861 if (base::SysInfo::IsLowEndDevice()) |
862 if (base::android::SysUtils::IsLowEndDevice()) | |
863 format = cc::RGB_565; | 862 format = cc::RGB_565; |
864 #endif | |
865 return scoped_ptr<cc::OutputSurface>( | 863 return scoped_ptr<cc::OutputSurface>( |
866 new MailboxOutputSurface( | 864 new MailboxOutputSurface( |
867 routing_id(), | 865 routing_id(), |
868 output_surface_id, | 866 output_surface_id, |
869 context_provider, | 867 context_provider, |
870 scoped_ptr<cc::SoftwareOutputDevice>(), | 868 scoped_ptr<cc::SoftwareOutputDevice>(), |
871 format)); | 869 format)); |
872 } | 870 } |
873 bool use_swap_compositor_frame_message = false; | 871 bool use_swap_compositor_frame_message = false; |
874 return scoped_ptr<cc::OutputSurface>( | 872 return scoped_ptr<cc::OutputSurface>( |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2006 attributes.stencil = false; | 2004 attributes.stencil = false; |
2007 bool lose_context_when_out_of_memory = true; | 2005 bool lose_context_when_out_of_memory = true; |
2008 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | 2006 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
2009 #if defined(OS_ANDROID) | 2007 #if defined(OS_ANDROID) |
2010 // If we raster too fast we become upload bound, and pending | 2008 // If we raster too fast we become upload bound, and pending |
2011 // uploads consume memory. For maximum upload throughput, we would | 2009 // uploads consume memory. For maximum upload throughput, we would |
2012 // want to allow for upload_throughput * pipeline_time of pending | 2010 // want to allow for upload_throughput * pipeline_time of pending |
2013 // uploads, after which we are just wasting memory. Since we don't | 2011 // uploads, after which we are just wasting memory. Since we don't |
2014 // know our upload throughput yet, this just caps our memory usage. | 2012 // know our upload throughput yet, this just caps our memory usage. |
2015 size_t divider = 1; | 2013 size_t divider = 1; |
2016 if (base::android::SysUtils::IsLowEndDevice()) | 2014 if (base::SysInfo::IsLowEndDevice()) |
2017 divider = 6; | 2015 divider = 6; |
2018 // For reference Nexus10 can upload 1MB in about 2.5ms. | 2016 // For reference Nexus10 can upload 1MB in about 2.5ms. |
2019 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); | 2017 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); |
2020 // Deadline to draw a frame to achieve 60 frames per second. | 2018 // Deadline to draw a frame to achieve 60 frames per second. |
2021 const size_t kMillisecondsPerFrame = 16; | 2019 const size_t kMillisecondsPerFrame = 16; |
2022 // Assuming a two frame deep pipeline between the CPU and the GPU. | 2020 // Assuming a two frame deep pipeline between the CPU and the GPU. |
2023 size_t max_transfer_buffer_usage_mb = | 2021 size_t max_transfer_buffer_usage_mb = |
2024 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); | 2022 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); |
2025 static const size_t kBytesPerMegabyte = 1024 * 1024; | 2023 static const size_t kBytesPerMegabyte = 1024 * 1024; |
2026 // We keep the MappedMemoryReclaimLimit the same as the upload limit | 2024 // We keep the MappedMemoryReclaimLimit the same as the upload limit |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2060 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2058 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2061 video_hole_frames_.AddObserver(frame); | 2059 video_hole_frames_.AddObserver(frame); |
2062 } | 2060 } |
2063 | 2061 |
2064 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2062 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2065 video_hole_frames_.RemoveObserver(frame); | 2063 video_hole_frames_.RemoveObserver(frame); |
2066 } | 2064 } |
2067 #endif // defined(VIDEO_HOLE) | 2065 #endif // defined(VIDEO_HOLE) |
2068 | 2066 |
2069 } // namespace content | 2067 } // namespace content |
OLD | NEW |