| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 time_source_->SetActive(false); | 67 time_source_->SetActive(false); |
| 68 } | 68 } |
| 69 | 69 |
| 70 BeginFrameArgs FrameRateController::SetActive(bool active) { | 70 BeginFrameArgs FrameRateController::SetActive(bool active) { |
| 71 if (active_ == active) | 71 if (active_ == active) |
| 72 return BeginFrameArgs(); | 72 return BeginFrameArgs(); |
| 73 TRACE_EVENT1("cc", "FrameRateController::SetActive", "active", active); | 73 TRACE_EVENT1("cc", "FrameRateController::SetActive", "active", active); |
| 74 active_ = active; | 74 active_ = active; |
| 75 | 75 |
| 76 if (is_time_source_throttling_) { | 76 if (is_time_source_throttling_) { |
| 77 base::TimeTicks missed_tick_time = time_source_->SetActive(active); | 77 gfx::FrameTime missed_tick_time = |
| 78 gfx::FrameTime::Unsafe_FromTimeTicks( |
| 79 time_source_->SetActive(active)); |
| 78 if (!missed_tick_time.is_null()) { | 80 if (!missed_tick_time.is_null()) { |
| 79 base::TimeTicks deadline = NextTickTime(); | 81 gfx::FrameTime deadline = NextTickTime(); |
| 80 return BeginFrameArgs::Create( | 82 return BeginFrameArgs::Create( |
| 81 missed_tick_time, deadline + deadline_adjustment_, interval_); | 83 missed_tick_time, deadline + deadline_adjustment_, interval_); |
| 82 } | 84 } |
| 83 } else { | 85 } else { |
| 84 if (active) | 86 if (active) |
| 85 PostManualTick(); | 87 PostManualTick(); |
| 86 else | 88 else |
| 87 weak_factory_.InvalidateWeakPtrs(); | 89 weak_factory_.InvalidateWeakPtrs(); |
| 88 } | 90 } |
| 89 | 91 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 110 TRACE_EVENT0("cc", "FrameRateController::OnTimerTick"); | 112 TRACE_EVENT0("cc", "FrameRateController::OnTimerTick"); |
| 111 DCHECK(active_); | 113 DCHECK(active_); |
| 112 | 114 |
| 113 // Check if we have too many frames in flight. | 115 // Check if we have too many frames in flight. |
| 114 bool throttled = | 116 bool throttled = |
| 115 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; | 117 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; |
| 116 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); | 118 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); |
| 117 | 119 |
| 118 if (client_) { | 120 if (client_) { |
| 119 // TODO(brianderson): Use an adaptive parent compositor deadline. | 121 // TODO(brianderson): Use an adaptive parent compositor deadline. |
| 120 base::TimeTicks frame_time = LastTickTime(); | 122 gfx::FrameTime frame_time = LastTickTime(); |
| 121 base::TimeTicks deadline = NextTickTime(); | 123 gfx::FrameTime deadline = NextTickTime(); |
| 122 BeginFrameArgs args = BeginFrameArgs::Create( | 124 BeginFrameArgs args = BeginFrameArgs::Create( |
| 123 frame_time, deadline + deadline_adjustment_, interval_); | 125 frame_time, deadline + deadline_adjustment_, interval_); |
| 124 client_->FrameRateControllerTick(throttled, args); | 126 client_->FrameRateControllerTick(throttled, args); |
| 125 } | 127 } |
| 126 | 128 |
| 127 if (!is_time_source_throttling_ && !throttled) | 129 if (!is_time_source_throttling_ && !throttled) |
| 128 PostManualTick(); | 130 PostManualTick(); |
| 129 } | 131 } |
| 130 | 132 |
| 131 void FrameRateController::PostManualTick() { | 133 void FrameRateController::PostManualTick() { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 148 DCHECK_GT(num_frames_pending_, 0); | 150 DCHECK_GT(num_frames_pending_, 0); |
| 149 num_frames_pending_--; | 151 num_frames_pending_--; |
| 150 if (!is_time_source_throttling_) | 152 if (!is_time_source_throttling_) |
| 151 PostManualTick(); | 153 PostManualTick(); |
| 152 } | 154 } |
| 153 | 155 |
| 154 void FrameRateController::DidAbortAllPendingFrames() { | 156 void FrameRateController::DidAbortAllPendingFrames() { |
| 155 num_frames_pending_ = 0; | 157 num_frames_pending_ = 0; |
| 156 } | 158 } |
| 157 | 159 |
| 158 base::TimeTicks FrameRateController::NextTickTime() { | 160 gfx::FrameTime FrameRateController::NextTickTime() { |
| 159 if (is_time_source_throttling_) | 161 if (is_time_source_throttling_) { |
| 160 return time_source_->NextTickTime(); | 162 return gfx::FrameTime::Unsafe_FromTimeTicks( |
| 163 time_source_->NextTickTime()); |
| 164 } |
| 161 | 165 |
| 162 return base::TimeTicks(); | 166 return gfx::FrameTime(); |
| 163 } | 167 } |
| 164 | 168 |
| 165 base::TimeTicks FrameRateController::LastTickTime() { | 169 gfx::FrameTime FrameRateController::LastTickTime() { |
| 166 if (is_time_source_throttling_) | 170 if (is_time_source_throttling_) |
| 167 return time_source_->LastTickTime(); | 171 return gfx::FrameTime::Unsafe_FromTimeTicks( |
| 172 time_source_->LastTickTime()); |
| 168 | 173 |
| 169 return gfx::FrameTime::Now(); | 174 return gfx::FrameTime::Now(); |
| 170 } | 175 } |
| 171 | 176 |
| 172 } // namespace cc | 177 } // namespace cc |
| OLD | NEW |