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

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

Issue 10818038: Make GPU benchmarking numAnimationFrames and totalPaintTime work in software mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial commit. Created 8 years, 4 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 | Annotate | Revision Log
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/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "content/common/swapped_out_messages.h" 17 #include "content/common/swapped_out_messages.h"
18 #include "content/common/view_messages.h" 18 #include "content/common/view_messages.h"
19 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
20 #include "content/renderer/render_process.h" 20 #include "content/renderer/render_process.h"
21 #include "content/renderer/render_thread_impl.h" 21 #include "content/renderer/render_thread_impl.h"
22 #include "content/renderer/renderer_webkitplatformsupport_impl.h" 22 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
23 #include "ipc/ipc_sync_message.h" 23 #include "ipc/ipc_sync_message.h"
24 #include "skia/ext/platform_canvas.h" 24 #include "skia/ext/platform_canvas.h"
25 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h "
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHelperPlugin.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHelperPlugin.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPagePopup.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPagePopup.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 is_swapped_out_(swapped_out), 101 is_swapped_out_(swapped_out),
101 input_method_is_active_(false), 102 input_method_is_active_(false),
102 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 103 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
103 can_compose_inline_(true), 104 can_compose_inline_(true),
104 popup_type_(popup_type), 105 popup_type_(popup_type),
105 pending_window_rect_count_(0), 106 pending_window_rect_count_(0),
106 suppress_next_char_events_(false), 107 suppress_next_char_events_(false),
107 is_accelerated_compositing_active_(false), 108 is_accelerated_compositing_active_(false),
108 animation_update_pending_(false), 109 animation_update_pending_(false),
109 invalidation_task_posted_(false), 110 invalidation_task_posted_(false),
111 total_do_deferred_update_count_(0),
110 screen_info_(screen_info), 112 screen_info_(screen_info),
111 device_scale_factor_(1) { 113 device_scale_factor_(1) {
112 if (!swapped_out) 114 if (!swapped_out)
113 RenderProcess::current()->AddRefProcess(); 115 RenderProcess::current()->AddRefProcess();
114 DCHECK(RenderThread::Get()); 116 DCHECK(RenderThread::Get());
115 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( 117 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch(
116 switches::kDisableGpuVsync); 118 switches::kDisableGpuVsync);
117 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) 119 #if defined(OS_CHROMEOS) || defined(OS_MACOSX)
118 device_scale_factor_ = screen_info.verticalDPI / kStandardDPI; 120 device_scale_factor_ = screen_info.verticalDPI / kStandardDPI;
119 // Unless an explicit scale factor was provided for testing, ensure the scale 121 // Unless an explicit scale factor was provided for testing, ensure the scale
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 60); 884 60);
883 } 885 }
884 886
885 // Calculate filtered time per frame: 887 // Calculate filtered time per frame:
886 float frame_time_elapsed = static_cast<float>(delay.InSecondsF()); 888 float frame_time_elapsed = static_cast<float>(delay.InSecondsF());
887 filtered_time_per_frame_ = 889 filtered_time_per_frame_ =
888 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed; 890 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed;
889 } 891 }
890 last_do_deferred_update_time_ = frame_begin_ticks; 892 last_do_deferred_update_time_ = frame_begin_ticks;
891 893
894 total_do_deferred_update_count_++;
nduca 2012/07/25 17:14:04 name is a bit awkward. Look in the .h for things t
dtu 2012/07/27 01:40:48 Just changed to deferred_update_count_. Hopefully
895
892 // OK, save the pending update to a local since painting may cause more 896 // OK, save the pending update to a local since painting may cause more
893 // invalidation. Some WebCore rendering objects only layout when painted. 897 // invalidation. Some WebCore rendering objects only layout when painted.
894 PaintAggregator::PendingUpdate update; 898 PaintAggregator::PendingUpdate update;
895 paint_aggregator_.PopPendingUpdate(&update); 899 paint_aggregator_.PopPendingUpdate(&update);
896 900
897 gfx::Rect scroll_damage = update.GetScrollDamage(); 901 gfx::Rect scroll_damage = update.GetScrollDamage();
898 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); 902 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage);
899 903
900 // Notify derived classes that we're about to initiate a paint. 904 // Notify derived classes that we're about to initiate a paint.
901 WillInitiatePaint(); 905 WillInitiatePaint();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 pending_update_params_->bitmap = current_paint_buf_->id(); 965 pending_update_params_->bitmap = current_paint_buf_->id();
962 pending_update_params_->bitmap_rect = bounds; 966 pending_update_params_->bitmap_rect = bounds;
963 967
964 std::vector<gfx::Rect>& copy_rects = pending_update_params_->copy_rects; 968 std::vector<gfx::Rect>& copy_rects = pending_update_params_->copy_rects;
965 // The scroll damage is just another rectangle to paint and copy. 969 // The scroll damage is just another rectangle to paint and copy.
966 copy_rects.swap(update.paint_rects); 970 copy_rects.swap(update.paint_rects);
967 if (!scroll_damage.IsEmpty()) 971 if (!scroll_damage.IsEmpty())
968 copy_rects.push_back(scroll_damage); 972 copy_rects.push_back(scroll_damage);
969 973
970 for (size_t i = 0; i < copy_rects.size(); ++i) 974 for (size_t i = 0; i < copy_rects.size(); ++i)
971 PaintRect(copy_rects[i], pixel_bounds.origin(), canvas.get()); 975 PaintRect(copy_rects[i], pixel_bounds.origin(), canvas.get());
nduca 2012/07/25 17:14:04 there is code in here that forces a software paint
dtu 2012/07/27 01:40:48 Done this in WebViewImpl in http://wkbug.com/92325
972 976
973 // Software FPS tick for performance tests. The accelerated path traces the 977 // Software FPS tick for performance tests. The accelerated path traces the
974 // frame events in didCommitAndDrawCompositorFrame. See throughput_tests.cc. 978 // frame events in didCommitAndDrawCompositorFrame. See throughput_tests.cc.
975 // NOTE: Tests may break if this event is renamed or moved. 979 // NOTE: Tests may break if this event is renamed or moved.
976 UNSHIPPED_TRACE_EVENT_INSTANT0("test_fps", "TestFrameTickSW"); 980 UNSHIPPED_TRACE_EVENT_INSTANT0("test_fps", "TestFrameTickSW");
977 } else { // Accelerated compositing path 981 } else { // Accelerated compositing path
978 // Begin painting. 982 // Begin painting.
979 // If painting is done via the gpu process then we don't set any damage 983 // If painting is done via the gpu process then we don't set any damage
980 // rects to save the browser process from doing unecessary work. 984 // rects to save the browser process from doing unecessary work.
981 pending_update_params_->bitmap_rect = bounds; 985 pending_update_params_->bitmap_rect = bounds;
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { 1766 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) {
1763 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); 1767 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin();
1764 i != plugin_window_moves_.end(); ++i) { 1768 i != plugin_window_moves_.end(); ++i) {
1765 if (i->window == window) { 1769 if (i->window == window) {
1766 plugin_window_moves_.erase(i); 1770 plugin_window_moves_.erase(i);
1767 break; 1771 break;
1768 } 1772 }
1769 } 1773 }
1770 } 1774 }
1771 1775
1776 void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const {
1777 if (is_accelerated_compositing_active_) {
nduca 2012/07/25 17:14:04 if (is ...) { get return } ... unindented soft
dtu 2012/07/27 01:40:48 Done. With the way the stats are calculated now, t
1778 webwidget()->renderingStats(stats);
1779 } else {
1780 stats.numAnimationFrames = total_do_deferred_update_count_;
1781 stats.numFramesSentToScreen = total_do_deferred_update_count_;
1782 }
1783 }
1784
1772 void RenderWidget::BeginSmoothScroll(bool down, bool scroll_far) { 1785 void RenderWidget::BeginSmoothScroll(bool down, bool scroll_far) {
1773 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, down, scroll_far)); 1786 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, down, scroll_far));
1774 } 1787 }
1775 1788
1776 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { 1789 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) {
1777 return false; 1790 return false;
1778 } 1791 }
1779 1792
1780 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { 1793 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
1781 return false; 1794 return false;
1782 } 1795 }
OLDNEW
« content/renderer/render_widget.h ('K') | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698