| 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::impl_thread_rendering_stats() { |  | 
|   22   base::AutoLock scoped_lock(lock_); |  | 
|   23   return impl_thread_rendering_stats_; |  | 
|   24 } |  | 
|   25  |  | 
|   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; |  | 
|   32 } |  | 
|   33  |  | 
|   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(); |  | 
|   38 } |  | 
|   39  |  | 
|   40 base::TimeDelta RenderingStatsInstrumentation::StartRecording() const { |  | 
|   41   if (record_rendering_stats_) { |  | 
|   42     if (base::ThreadTicks::IsSupported()) |  | 
|   43       return base::ThreadTicks::Now() - base::ThreadTicks(); |  | 
|   44     return base::TimeTicks::Now() - base::TimeTicks(); |  | 
|   45   } |  | 
|   46   return base::TimeDelta(); |  | 
|   47 } |  | 
|   48  |  | 
|   49 base::TimeDelta RenderingStatsInstrumentation::EndRecording( |  | 
|   50     base::TimeDelta start_time) const { |  | 
|   51   if (start_time != base::TimeDelta()) { |  | 
|   52     if (base::ThreadTicks::IsSupported()) |  | 
|   53       return (base::ThreadTicks::Now() - base::ThreadTicks()) - start_time; |  | 
|   54     return (base::TimeTicks::Now() - base::TimeTicks()) - start_time; |  | 
|   55   } |  | 
|   56   return base::TimeDelta(); |  | 
|   57 } |  | 
|   58  |  | 
|   59 void RenderingStatsInstrumentation::IncrementFrameCount(int64 count) { |  | 
|   60   if (!record_rendering_stats_) |  | 
|   61     return; |  | 
|   62  |  | 
|   63   base::AutoLock scoped_lock(lock_); |  | 
|   64   impl_thread_rendering_stats_.frame_count += count; |  | 
|   65 } |  | 
|   66  |  | 
|   67 void RenderingStatsInstrumentation::AddVisibleContentArea(int64 area) { |  | 
|   68   if (!record_rendering_stats_) |  | 
|   69     return; |  | 
|   70  |  | 
|   71   base::AutoLock scoped_lock(lock_); |  | 
|   72   impl_thread_rendering_stats_.visible_content_area += area; |  | 
|   73 } |  | 
|   74  |  | 
|   75 void RenderingStatsInstrumentation::AddApproximatedVisibleContentArea( |  | 
|   76     int64 area) { |  | 
|   77   if (!record_rendering_stats_) |  | 
|   78     return; |  | 
|   79  |  | 
|   80   base::AutoLock scoped_lock(lock_); |  | 
|   81   impl_thread_rendering_stats_.approximated_visible_content_area += area; |  | 
|   82 } |  | 
|   83  |  | 
|   84 void RenderingStatsInstrumentation::AddDrawDuration( |  | 
|   85     base::TimeDelta draw_duration, |  | 
|   86     base::TimeDelta draw_duration_estimate) { |  | 
|   87   if (!record_rendering_stats_) |  | 
|   88     return; |  | 
|   89  |  | 
|   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); |  | 
|   94 } |  | 
|   95  |  | 
|   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; |  | 
|  101  |  | 
|  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); |  | 
|  107 } |  | 
|  108  |  | 
|  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; |  | 
|  114  |  | 
|  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); |  | 
|  120 } |  | 
|  121  |  | 
|  122 }  // namespace cc |  | 
| OLD | NEW |