| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/scheduler/frame_rate_controller.h" | 5 #include "cc/scheduler/frame_rate_controller.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "cc/base/thread.h" | 9 #include "cc/base/thread.h" |
| 10 #include "cc/scheduler/delay_based_time_source.h" | 10 #include "cc/scheduler/delay_based_time_source.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 void FrameRateController::SetSwapBuffersCompleteSupported(bool supported) { | 91 void FrameRateController::SetSwapBuffersCompleteSupported(bool supported) { |
| 92 swap_buffers_complete_supported_ = supported; | 92 swap_buffers_complete_supported_ = supported; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void FrameRateController::OnTimerTick() { | 95 void FrameRateController::OnTimerTick() { |
| 96 DCHECK(active_); | 96 DCHECK(active_); |
| 97 | 97 |
| 98 // Check if we have too many frames in flight. | 98 // Check if we have too many frames in flight. |
| 99 bool throttled = | 99 bool throttled = |
| 100 max_frames_pending_ && num_frames_pending_ >= max_frames_pending_; | 100 max_frames_pending_ && num_frames_pending_ >= max_frames_pending_; |
| 101 TRACE_COUNTER_ID1("cc", "ThrottledVSyncInterval", thread_, throttled); | 101 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", thread_, throttled); |
| 102 | 102 |
| 103 if (client_) | 103 if (client_) |
| 104 client_->VSyncTick(throttled); | 104 client_->BeginFrame(throttled); |
| 105 | 105 |
| 106 if (swap_buffers_complete_supported_ && !is_time_source_throttling_ && | 106 if (swap_buffers_complete_supported_ && !is_time_source_throttling_ && |
| 107 !throttled) | 107 !throttled) |
| 108 PostManualTick(); | 108 PostManualTick(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void FrameRateController::PostManualTick() { | 111 void FrameRateController::PostManualTick() { |
| 112 if (active_) { | 112 if (active_) { |
| 113 thread_->PostTask(base::Bind(&FrameRateController::ManualTick, | 113 thread_->PostTask(base::Bind(&FrameRateController::ManualTick, |
| 114 weak_factory_.GetWeakPtr())); | 114 weak_factory_.GetWeakPtr())); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 145 } | 145 } |
| 146 | 146 |
| 147 base::TimeTicks FrameRateController::LastTickTime() { | 147 base::TimeTicks FrameRateController::LastTickTime() { |
| 148 if (is_time_source_throttling_) | 148 if (is_time_source_throttling_) |
| 149 return time_source_->LastTickTime(); | 149 return time_source_->LastTickTime(); |
| 150 | 150 |
| 151 return base::TimeTicks::Now(); | 151 return base::TimeTicks::Now(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 } // namespace cc | 154 } // namespace cc |
| OLD | NEW |