mac: Don't limit GL_MAX_TEXTURE_SIZE on 10.9.0+.
[chromium-blink-merge.git] / cc / debug / rendering_stats_instrumentation.cc
blobc707e233c608b4e603595c7660409b14b453b9b0
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.
5 #include "cc/debug/rendering_stats_instrumentation.h"
7 namespace cc {
9 // static
10 scoped_ptr<RenderingStatsInstrumentation>
11 RenderingStatsInstrumentation::Create() {
12 return make_scoped_ptr(new RenderingStatsInstrumentation());
15 RenderingStatsInstrumentation::RenderingStatsInstrumentation()
16 : record_rendering_stats_(false) {
19 RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {}
21 RenderingStats RenderingStatsInstrumentation::impl_thread_rendering_stats() {
22 base::AutoLock scoped_lock(lock_);
23 return impl_thread_rendering_stats_;
26 RenderingStats RenderingStatsInstrumentation::GetRenderingStats() {
27 base::AutoLock scoped_lock(lock_);
28 RenderingStats rendering_stats;
29 rendering_stats = impl_thread_rendering_stats_accu_;
30 rendering_stats.Add(impl_thread_rendering_stats_);
31 return rendering_stats;
34 void RenderingStatsInstrumentation::AccumulateAndClearImplThreadStats() {
35 base::AutoLock scoped_lock(lock_);
36 impl_thread_rendering_stats_accu_.Add(impl_thread_rendering_stats_);
37 impl_thread_rendering_stats_ = RenderingStats();
40 base::TimeTicks RenderingStatsInstrumentation::StartRecording() const {
41 if (record_rendering_stats_) {
42 if (base::TimeTicks::IsThreadNowSupported())
43 return base::TimeTicks::ThreadNow();
44 return base::TimeTicks::HighResNow();
46 return base::TimeTicks();
49 base::TimeDelta RenderingStatsInstrumentation::EndRecording(
50 base::TimeTicks start_time) const {
51 if (!start_time.is_null()) {
52 if (base::TimeTicks::IsThreadNowSupported())
53 return base::TimeTicks::ThreadNow() - start_time;
54 return base::TimeTicks::HighResNow() - start_time;
56 return base::TimeDelta();
59 void RenderingStatsInstrumentation::IncrementFrameCount(int64 count) {
60 if (!record_rendering_stats_)
61 return;
63 base::AutoLock scoped_lock(lock_);
64 impl_thread_rendering_stats_.frame_count += count;
67 void RenderingStatsInstrumentation::AddVisibleContentArea(int64 area) {
68 if (!record_rendering_stats_)
69 return;
71 base::AutoLock scoped_lock(lock_);
72 impl_thread_rendering_stats_.visible_content_area += area;
75 void RenderingStatsInstrumentation::AddApproximatedVisibleContentArea(
76 int64 area) {
77 if (!record_rendering_stats_)
78 return;
80 base::AutoLock scoped_lock(lock_);
81 impl_thread_rendering_stats_.approximated_visible_content_area += area;
84 void RenderingStatsInstrumentation::AddDrawDuration(
85 base::TimeDelta draw_duration,
86 base::TimeDelta draw_duration_estimate) {
87 if (!record_rendering_stats_)
88 return;
90 base::AutoLock scoped_lock(lock_);
91 impl_thread_rendering_stats_.draw_duration.Append(draw_duration);
92 impl_thread_rendering_stats_.draw_duration_estimate.Append(
93 draw_duration_estimate);
96 void RenderingStatsInstrumentation::AddBeginMainFrameToCommitDuration(
97 base::TimeDelta begin_main_frame_to_commit_duration,
98 base::TimeDelta begin_main_frame_to_commit_duration_estimate) {
99 if (!record_rendering_stats_)
100 return;
102 base::AutoLock scoped_lock(lock_);
103 impl_thread_rendering_stats_.begin_main_frame_to_commit_duration.Append(
104 begin_main_frame_to_commit_duration);
105 impl_thread_rendering_stats_.begin_main_frame_to_commit_duration_estimate
106 .Append(begin_main_frame_to_commit_duration_estimate);
109 void RenderingStatsInstrumentation::AddCommitToActivateDuration(
110 base::TimeDelta commit_to_activate_duration,
111 base::TimeDelta commit_to_activate_duration_estimate) {
112 if (!record_rendering_stats_)
113 return;
115 base::AutoLock scoped_lock(lock_);
116 impl_thread_rendering_stats_.commit_to_activate_duration.Append(
117 commit_to_activate_duration);
118 impl_thread_rendering_stats_.commit_to_activate_duration_estimate.Append(
119 commit_to_activate_duration_estimate);
122 } // namespace cc