1 // Copyright 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "cc/debug/rendering_stats.h" 6 7 namespace cc { 8 9 RenderingStats::TimeDeltaList::TimeDeltaList() { 10 } 11 12 RenderingStats::TimeDeltaList::~TimeDeltaList() { 13 } 14 15 void RenderingStats::TimeDeltaList::Append(base::TimeDelta value) { 16 values.push_back(value); 17 } 18 19 void RenderingStats::TimeDeltaList::AddToTracedValue( 20 base::debug::TracedValue* list_value) const { 21 std::list<base::TimeDelta>::const_iterator iter; 22 for (iter = values.begin(); iter != values.end(); ++iter) { 23 list_value->AppendDouble(iter->InMillisecondsF()); 24 } 25 } 26 27 void RenderingStats::TimeDeltaList::Add(const TimeDeltaList& other) { 28 values.insert(values.end(), other.values.begin(), other.values.end()); 29 } 30 31 RenderingStats::MainThreadRenderingStats::MainThreadRenderingStats() 32 : frame_count(0), painted_pixel_count(0), recorded_pixel_count(0) { 33 } 34 35 RenderingStats::MainThreadRenderingStats::~MainThreadRenderingStats() { 36 } 37 38 scoped_refptr<base::debug::ConvertableToTraceFormat> 39 RenderingStats::MainThreadRenderingStats::AsTraceableData() const { 40 scoped_refptr<base::debug::TracedValue> record_data = 41 new base::debug::TracedValue(); 42 record_data->SetInteger("frame_count", frame_count); 43 record_data->SetDouble("paint_time", paint_time.InSecondsF()); 44 record_data->SetInteger("painted_pixel_count", painted_pixel_count); 45 record_data->SetDouble("record_time", record_time.InSecondsF()); 46 record_data->SetInteger("recorded_pixel_count", recorded_pixel_count); 47 return record_data; 48 } 49 50 void RenderingStats::MainThreadRenderingStats::Add( 51 const MainThreadRenderingStats& other) { 52 frame_count += other.frame_count; 53 paint_time += other.paint_time; 54 painted_pixel_count += other.painted_pixel_count; 55 record_time += other.record_time; 56 recorded_pixel_count += other.recorded_pixel_count; 57 } 58 59 RenderingStats::ImplThreadRenderingStats::ImplThreadRenderingStats() 60 : frame_count(0), 61 rasterized_pixel_count(0), 62 visible_content_area(0), 63 approximated_visible_content_area(0) { 64 } 65 66 RenderingStats::ImplThreadRenderingStats::~ImplThreadRenderingStats() { 67 } 68 69 scoped_refptr<base::debug::ConvertableToTraceFormat> 70 RenderingStats::ImplThreadRenderingStats::AsTraceableData() const { 71 scoped_refptr<base::debug::TracedValue> record_data = 72 new base::debug::TracedValue(); 73 record_data->SetInteger("frame_count", frame_count); 74 record_data->SetDouble("rasterize_time", rasterize_time.InSecondsF()); 75 record_data->SetInteger("rasterized_pixel_count", rasterized_pixel_count); 76 record_data->SetInteger("visible_content_area", visible_content_area); 77 record_data->SetInteger("approximated_visible_content_area", 78 approximated_visible_content_area); 79 record_data->BeginArray("draw_duration_ms"); 80 draw_duration.AddToTracedValue(record_data.get()); 81 record_data->EndArray(); 82 83 record_data->BeginArray("draw_duration_estimate_ms"); 84 draw_duration_estimate.AddToTracedValue(record_data.get()); 85 record_data->EndArray(); 86 87 record_data->BeginArray("begin_main_frame_to_commit_duration_ms"); 88 begin_main_frame_to_commit_duration.AddToTracedValue(record_data.get()); 89 record_data->EndArray(); 90 91 record_data->BeginArray("begin_main_frame_to_commit_duration_estimate_ms"); 92 begin_main_frame_to_commit_duration_estimate.AddToTracedValue( 93 record_data.get()); 94 record_data->EndArray(); 95 96 record_data->BeginArray("commit_to_activate_duration_ms"); 97 commit_to_activate_duration.AddToTracedValue(record_data.get()); 98 record_data->EndArray(); 99 100 record_data->BeginArray("commit_to_activate_duration_estimate_ms"); 101 commit_to_activate_duration_estimate.AddToTracedValue(record_data.get()); 102 record_data->EndArray(); 103 return record_data; 104 } 105 106 void RenderingStats::ImplThreadRenderingStats::Add( 107 const ImplThreadRenderingStats& other) { 108 frame_count += other.frame_count; 109 rasterize_time += other.rasterize_time; 110 analysis_time += other.analysis_time; 111 rasterized_pixel_count += other.rasterized_pixel_count; 112 visible_content_area += other.visible_content_area; 113 approximated_visible_content_area += other.approximated_visible_content_area; 114 115 draw_duration.Add(other.draw_duration); 116 draw_duration_estimate.Add(other.draw_duration_estimate); 117 begin_main_frame_to_commit_duration.Add( 118 other.begin_main_frame_to_commit_duration); 119 begin_main_frame_to_commit_duration_estimate.Add( 120 other.begin_main_frame_to_commit_duration_estimate); 121 commit_to_activate_duration.Add(other.commit_to_activate_duration); 122 commit_to_activate_duration_estimate.Add( 123 other.commit_to_activate_duration_estimate); 124 } 125 126 void RenderingStats::Add(const RenderingStats& other) { 127 main_stats.Add(other.main_stats); 128 impl_stats.Add(other.impl_stats); 129 } 130 131 } // namespace cc 132