Chromium Code Reviews| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 CASE_TYPE(TouchCancel); | 132 CASE_TYPE(TouchCancel); |
| 133 default: | 133 default: |
| 134 // Must include default to let WebKit::WebInputEvent add new event types | 134 // Must include default to let WebKit::WebInputEvent add new event types |
| 135 // before they're added here. | 135 // before they're added here. |
| 136 DLOG(WARNING) << "Unhandled WebInputEvent type in GetEventName.\n"; | 136 DLOG(WARNING) << "Unhandled WebInputEvent type in GetEventName.\n"; |
| 137 break; | 137 break; |
| 138 } | 138 } |
| 139 #undef CASE_TYPE | 139 #undef CASE_TYPE |
| 140 return ""; | 140 return ""; |
| 141 } | 141 } |
| 142 | |
| 143 void SendToImplThreadLatencyUma(int routing_id, | |
| 144 const ui::LatencyInfo& latency_info, | |
| 145 WebInputEvent::Type event_type) { | |
| 146 ui::LatencyInfo::LatencyComponent dispatch_component; | |
| 147 ui::LatencyInfo::LatencyComponent receive_component; | |
| 148 if (latency_info.FindLatency( | |
| 149 ui::INPUT_EVENT_LATENCY_SENT_FROM_IMPL_THREAD_COMPONENT, | |
| 150 routing_id, &dispatch_component) && | |
| 151 latency_info.FindLatency( | |
| 152 ui::INPUT_EVENT_LATENCY_RECEIVED_ON_MAIN_THREAD_COMPONENT, | |
| 153 routing_id, &receive_component)) { | |
| 154 base::TimeDelta delta = receive_component.event_time - | |
| 155 dispatch_component.event_time; | |
| 156 switch (event_type) { | |
| 157 case WebInputEvent::GestureScrollBegin: | |
| 158 case WebInputEvent::GestureScrollUpdate: | |
| 159 case WebInputEvent::GestureScrollUpdateWithoutPropagation: | |
| 160 UMA_HISTOGRAM_TIMES( | |
| 161 "Event.Latency.ImplThreadToRendererThread.GestureScroll", delta); | |
| 162 break; | |
| 163 case WebInputEvent::TouchStart: | |
| 164 case WebInputEvent::TouchMove: | |
| 165 UMA_HISTOGRAM_TIMES( | |
| 166 "Event.Latency.ImplThreadToRendererThread.Touch", delta); | |
| 167 break; | |
| 168 default: | |
| 169 break; | |
| 170 } | |
| 171 } | |
| 172 } | |
| 173 | |
| 174 void UpdateRenderingStatsForAverageImplThreadLatency( | |
| 175 int routing_id, | |
| 176 const ui::LatencyInfo& latency_info, | |
| 177 cc::RenderingStats& stats) { | |
| 178 ui::LatencyInfo::LatencyComponent dispatch_component; | |
| 179 ui::LatencyInfo::LatencyComponent receive_component; | |
| 180 if (latency_info.FindLatency( | |
| 181 ui::INPUT_EVENT_LATENCY_SENT_FROM_IMPL_THREAD_COMPONENT, | |
| 182 routing_id, &dispatch_component) && | |
| 183 latency_info.FindLatency( | |
| 184 ui::INPUT_EVENT_LATENCY_RECEIVED_ON_MAIN_THREAD_COMPONENT, | |
| 185 routing_id, &receive_component)) { | |
| 186 stats.average_impl_thread_to_main_thread_time = | |
| 187 receive_component.event_time - dispatch_component.event_time; | |
|
jbauman
2013/07/03 20:00:15
This won't calculate an average. You'd need to sum
varunjain
2013/07/04 16:49:46
Done.
| |
| 188 } | |
| 189 } | |
| 190 | |
| 142 } | 191 } |
| 143 namespace content { | 192 namespace content { |
| 144 | 193 |
| 145 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, | 194 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, |
| 146 const WebKit::WebScreenInfo& screen_info, | 195 const WebKit::WebScreenInfo& screen_info, |
| 147 bool swapped_out) | 196 bool swapped_out) |
| 148 : routing_id_(MSG_ROUTING_NONE), | 197 : routing_id_(MSG_ROUTING_NONE), |
| 149 surface_id_(0), | 198 surface_id_(0), |
| 150 webwidget_(NULL), | 199 webwidget_(NULL), |
| 151 opener_id_(MSG_ROUTING_NONE), | 200 opener_id_(MSG_ROUTING_NONE), |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 731 } | 780 } |
| 732 | 781 |
| 733 const char* const event_name = GetEventName(input_event->type); | 782 const char* const event_name = GetEventName(input_event->type); |
| 734 TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent", | 783 TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent", |
| 735 "event", event_name); | 784 "event", event_name); |
| 736 | 785 |
| 737 if (compositor_) | 786 if (compositor_) |
| 738 compositor_->SetLatencyInfo(latency_info); | 787 compositor_->SetLatencyInfo(latency_info); |
| 739 else | 788 else |
| 740 latency_info_.MergeWith(latency_info); | 789 latency_info_.MergeWith(latency_info); |
| 790 SendToImplThreadLatencyUma(routing_id(), latency_info, input_event->type); | |
| 791 UpdateRenderingStatsForAverageImplThreadLatency(routing_id(), latency_info_, | |
|
jbauman
2013/07/03 20:00:15
You probably don't want to use latency_info_ here.
varunjain
2013/07/04 16:49:46
Done.
| |
| 792 software_stats_); | |
| 741 | 793 |
| 742 base::TimeDelta now = base::TimeDelta::FromInternalValue( | 794 base::TimeDelta now = base::TimeDelta::FromInternalValue( |
| 743 base::TimeTicks::Now().ToInternalValue()); | 795 base::TimeTicks::Now().ToInternalValue()); |
| 744 | 796 |
| 745 int64 delta = static_cast<int64>( | 797 int64 delta = static_cast<int64>( |
| 746 (now.InSecondsF() - input_event->timeStampSeconds) * | 798 (now.InSecondsF() - input_event->timeStampSeconds) * |
| 747 base::Time::kMicrosecondsPerSecond); | 799 base::Time::kMicrosecondsPerSecond); |
| 748 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Renderer", delta, 0, 1000000, 100); | 800 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Renderer", delta, 0, 1000000, 100); |
| 749 base::HistogramBase* counter_for_type = | 801 base::HistogramBase* counter_for_type = |
| 750 base::Histogram::FactoryGet( | 802 base::Histogram::FactoryGet( |
| (...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2326 compositor_->GetRenderingStats(&stats.rendering_stats); | 2378 compositor_->GetRenderingStats(&stats.rendering_stats); |
| 2327 | 2379 |
| 2328 stats.rendering_stats.animation_frame_count += | 2380 stats.rendering_stats.animation_frame_count += |
| 2329 software_stats_.animation_frame_count; | 2381 software_stats_.animation_frame_count; |
| 2330 stats.rendering_stats.screen_frame_count += | 2382 stats.rendering_stats.screen_frame_count += |
| 2331 software_stats_.screen_frame_count; | 2383 software_stats_.screen_frame_count; |
| 2332 stats.rendering_stats.total_paint_time += | 2384 stats.rendering_stats.total_paint_time += |
| 2333 software_stats_.total_paint_time; | 2385 software_stats_.total_paint_time; |
| 2334 stats.rendering_stats.total_pixels_painted += | 2386 stats.rendering_stats.total_pixels_painted += |
| 2335 software_stats_.total_pixels_painted; | 2387 software_stats_.total_pixels_painted; |
| 2388 stats.rendering_stats.average_impl_thread_to_main_thread_time = | |
| 2389 software_stats_.average_impl_thread_to_main_thread_time; | |
| 2336 } | 2390 } |
| 2337 | 2391 |
| 2338 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { | 2392 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { |
| 2339 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); | 2393 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); |
| 2340 if (!gpu_channel) | 2394 if (!gpu_channel) |
| 2341 return false; | 2395 return false; |
| 2342 | 2396 |
| 2343 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); | 2397 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); |
| 2344 } | 2398 } |
| 2345 | 2399 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2408 | 2462 |
| 2409 if (!context->InitializeWithDefaultBufferSizes( | 2463 if (!context->InitializeWithDefaultBufferSizes( |
| 2410 attributes, | 2464 attributes, |
| 2411 false /* bind generates resources */, | 2465 false /* bind generates resources */, |
| 2412 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) | 2466 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) |
| 2413 return NULL; | 2467 return NULL; |
| 2414 return context.release(); | 2468 return context.release(); |
| 2415 } | 2469 } |
| 2416 | 2470 |
| 2417 } // namespace content | 2471 } // namespace content |
| OLD | NEW |