| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 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_instrumentation.h" |
| 6 |
| 7 namespace cc { |
| 8 |
| 9 // static |
| 10 scoped_ptr<RenderingStatsInstrumentation> |
| 11 RenderingStatsInstrumentation::Create() { |
| 12 return make_scoped_ptr(new RenderingStatsInstrumentation()); |
| 13 } |
| 14 |
| 15 RenderingStatsInstrumentation::RenderingStatsInstrumentation() |
| 16 : record_rendering_stats_(false) { |
| 17 } |
| 18 |
| 19 RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {} |
| 20 |
| 21 RenderingStats RenderingStatsInstrumentation::GetRenderingStats() { |
| 22 base::AutoLock scoped_lock(lock_); |
| 23 return rendering_stats_; |
| 24 } |
| 25 |
| 26 base::TimeTicks RenderingStatsInstrumentation::StartRecording() const { |
| 27 if (record_rendering_stats_) |
| 28 return base::TimeTicks::HighResNow(); |
| 29 return base::TimeTicks(); |
| 30 } |
| 31 |
| 32 base::TimeDelta RenderingStatsInstrumentation::EndRecording( |
| 33 base::TimeTicks start_time) const { |
| 34 if (!start_time.is_null()) |
| 35 return base::TimeTicks::HighResNow() - start_time; |
| 36 return base::TimeDelta(); |
| 37 } |
| 38 |
| 39 void RenderingStatsInstrumentation::AddStats(const RenderingStats& other) { |
| 40 if (!record_rendering_stats_) |
| 41 return; |
| 42 |
| 43 base::AutoLock scoped_lock(lock_); |
| 44 rendering_stats_.Add(other); |
| 45 } |
| 46 |
| 47 void RenderingStatsInstrumentation::IncrementAnimationFrameCount() { |
| 48 if (!record_rendering_stats_) |
| 49 return; |
| 50 |
| 51 base::AutoLock scoped_lock(lock_); |
| 52 rendering_stats_.numAnimationFrames++; |
| 53 } |
| 54 |
| 55 void RenderingStatsInstrumentation::SetScreenFrameCount(int64 count) { |
| 56 if (!record_rendering_stats_) |
| 57 return; |
| 58 |
| 59 base::AutoLock scoped_lock(lock_); |
| 60 rendering_stats_.numFramesSentToScreen = count; |
| 61 } |
| 62 |
| 63 void RenderingStatsInstrumentation::SetDroppedFrameCount(int64 count) { |
| 64 if (!record_rendering_stats_) |
| 65 return; |
| 66 |
| 67 base::AutoLock scoped_lock(lock_); |
| 68 rendering_stats_.droppedFrameCount = count; |
| 69 } |
| 70 |
| 71 void RenderingStatsInstrumentation::AddCommit(base::TimeDelta duration) { |
| 72 if (!record_rendering_stats_) |
| 73 return; |
| 74 |
| 75 base::AutoLock scoped_lock(lock_); |
| 76 rendering_stats_.totalCommitTime += duration; |
| 77 rendering_stats_.totalCommitCount++; |
| 78 } |
| 79 |
| 80 void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration, |
| 81 int64 pixels) { |
| 82 if (!record_rendering_stats_) |
| 83 return; |
| 84 |
| 85 base::AutoLock scoped_lock(lock_); |
| 86 rendering_stats_.totalPaintTime += duration; |
| 87 rendering_stats_.totalPixelsPainted += pixels; |
| 88 } |
| 89 |
| 90 void RenderingStatsInstrumentation::AddRaster(base::TimeDelta duration, |
| 91 int64 pixels, |
| 92 bool is_in_pending_tree_now_bin) { |
| 93 if (!record_rendering_stats_) |
| 94 return; |
| 95 |
| 96 base::AutoLock scoped_lock(lock_); |
| 97 rendering_stats_.totalRasterizeTime += duration; |
| 98 rendering_stats_.totalPixelsRasterized += pixels; |
| 99 |
| 100 if (is_in_pending_tree_now_bin) |
| 101 rendering_stats_.totalRasterizeTimeForNowBinsOnPendingTree += duration; |
| 102 } |
| 103 |
| 104 void RenderingStatsInstrumentation::IncrementImplThreadScrolls() { |
| 105 if (!record_rendering_stats_) |
| 106 return; |
| 107 |
| 108 base::AutoLock scoped_lock(lock_); |
| 109 rendering_stats_.numImplThreadScrolls++; |
| 110 } |
| 111 |
| 112 void RenderingStatsInstrumentation::IncrementMainThreadScrolls() { |
| 113 if (!record_rendering_stats_) |
| 114 return; |
| 115 |
| 116 base::AutoLock scoped_lock(lock_); |
| 117 rendering_stats_.numMainThreadScrolls++; |
| 118 } |
| 119 |
| 120 void RenderingStatsInstrumentation::AddLayersDrawn(int64 amount) { |
| 121 if (!record_rendering_stats_) |
| 122 return; |
| 123 |
| 124 base::AutoLock scoped_lock(lock_); |
| 125 rendering_stats_.numLayersDrawn += amount; |
| 126 } |
| 127 |
| 128 void RenderingStatsInstrumentation::AddMissingTiles(int64 amount) { |
| 129 if (!record_rendering_stats_) |
| 130 return; |
| 131 |
| 132 base::AutoLock scoped_lock(lock_); |
| 133 rendering_stats_.numMissingTiles += amount; |
| 134 } |
| 135 |
| 136 void RenderingStatsInstrumentation::AddDeferredImageDecode( |
| 137 base::TimeDelta duration) { |
| 138 if (!record_rendering_stats_) |
| 139 return; |
| 140 |
| 141 base::AutoLock scoped_lock(lock_); |
| 142 rendering_stats_.totalDeferredImageDecodeTime += duration; |
| 143 rendering_stats_.totalDeferredImageDecodeCount++; |
| 144 } |
| 145 |
| 146 void RenderingStatsInstrumentation::AddImageGathering( |
| 147 base::TimeDelta duration) { |
| 148 if (!record_rendering_stats_) |
| 149 return; |
| 150 |
| 151 base::AutoLock scoped_lock(lock_); |
| 152 rendering_stats_.totalImageGatheringTime += duration; |
| 153 rendering_stats_.totalImageGatheringCount++; |
| 154 } |
| 155 |
| 156 void RenderingStatsInstrumentation::IncrementDeferredImageCacheHitCount() { |
| 157 if (!record_rendering_stats_) |
| 158 return; |
| 159 |
| 160 base::AutoLock scoped_lock(lock_); |
| 161 rendering_stats_.totalDeferredImageCacheHitCount++; |
| 162 } |
| 163 |
| 164 } // namespace cc |
| OLD | NEW |