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