| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 BeginFrameArgs FrameRateController::SetActive(bool active) { | 69 BeginFrameArgs FrameRateController::SetActive(bool active) { |
| 70 if (active_ == active) | 70 if (active_ == active) |
| 71 return BeginFrameArgs(); | 71 return BeginFrameArgs(); |
| 72 TRACE_EVENT1("cc", "FrameRateController::SetActive", "active", active); | 72 TRACE_EVENT1("cc", "FrameRateController::SetActive", "active", active); |
| 73 active_ = active; | 73 active_ = active; |
| 74 | 74 |
| 75 if (is_time_source_throttling_) { | 75 if (is_time_source_throttling_) { |
| 76 base::TimeTicks missed_tick_time = time_source_->SetActive(active); | 76 base::TimeTicks missed_tick_time = time_source_->SetActive(active); |
| 77 if (!missed_tick_time.is_null()) { | 77 if (!missed_tick_time.is_null()) { |
| 78 base::TimeTicks deadline = NextTickTime(); | 78 base::TimeTicks deadline = NextTickTime(); |
| 79 return BeginFrameArgs::Create(missed_tick_time, | 79 return BeginFrameArgs::Create( |
| 80 deadline, | 80 missed_tick_time, deadline + deadline_adjustment_, interval_); |
| 81 interval_); | |
| 82 } | 81 } |
| 83 } else { | 82 } else { |
| 84 if (active) | 83 if (active) |
| 85 PostManualTick(); | 84 PostManualTick(); |
| 86 else | 85 else |
| 87 weak_factory_.InvalidateWeakPtrs(); | 86 weak_factory_.InvalidateWeakPtrs(); |
| 88 } | 87 } |
| 89 | 88 |
| 90 return BeginFrameArgs(); | 89 return BeginFrameArgs(); |
| 91 } | 90 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 111 DCHECK(active_); | 110 DCHECK(active_); |
| 112 | 111 |
| 113 // Check if we have too many frames in flight. | 112 // Check if we have too many frames in flight. |
| 114 bool throttled = | 113 bool throttled = |
| 115 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; | 114 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; |
| 116 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); | 115 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); |
| 117 | 116 |
| 118 if (client_) { | 117 if (client_) { |
| 119 // TODO(brianderson): Use an adaptive parent compositor deadline. | 118 // TODO(brianderson): Use an adaptive parent compositor deadline. |
| 120 base::TimeTicks frame_time = LastTickTime(); | 119 base::TimeTicks frame_time = LastTickTime(); |
| 121 base::TimeTicks deadline = NextTickTime() + deadline_adjustment_; | 120 base::TimeTicks deadline = NextTickTime(); |
| 122 client_->FrameRateControllerTick( | 121 BeginFrameArgs args = BeginFrameArgs::Create( |
| 123 throttled, | 122 frame_time, deadline + deadline_adjustment_, interval_); |
| 124 BeginFrameArgs::Create(frame_time, deadline, interval_)); | 123 client_->FrameRateControllerTick(throttled, args); |
| 125 } | 124 } |
| 126 | 125 |
| 127 if (!is_time_source_throttling_ && !throttled) | 126 if (!is_time_source_throttling_ && !throttled) |
| 128 PostManualTick(); | 127 PostManualTick(); |
| 129 } | 128 } |
| 130 | 129 |
| 131 void FrameRateController::PostManualTick() { | 130 void FrameRateController::PostManualTick() { |
| 132 if (active_) { | 131 if (active_) { |
| 133 task_runner_->PostTask(FROM_HERE, | 132 task_runner_->PostTask(FROM_HERE, |
| 134 base::Bind(&FrameRateController::ManualTick, | 133 base::Bind(&FrameRateController::ManualTick, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 163 } | 162 } |
| 164 | 163 |
| 165 base::TimeTicks FrameRateController::LastTickTime() { | 164 base::TimeTicks FrameRateController::LastTickTime() { |
| 166 if (is_time_source_throttling_) | 165 if (is_time_source_throttling_) |
| 167 return time_source_->LastTickTime(); | 166 return time_source_->LastTickTime(); |
| 168 | 167 |
| 169 return base::TimeTicks::Now(); | 168 return base::TimeTicks::Now(); |
| 170 } | 169 } |
| 171 | 170 |
| 172 } // namespace cc | 171 } // namespace cc |
| OLD | NEW |