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