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/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 if (active) | 78 if (active) |
79 PostManualTick(); | 79 PostManualTick(); |
80 else | 80 else |
81 weak_factory_.InvalidateWeakPtrs(); | 81 weak_factory_.InvalidateWeakPtrs(); |
82 } | 82 } |
83 | 83 |
84 if (just_activated) { | 84 if (just_activated) { |
85 // TODO(brianderson): Use an adaptive parent compositor deadline. | 85 // TODO(brianderson): Use an adaptive parent compositor deadline. |
86 base::TimeTicks frame_time = NextTickTime() - interval_; | 86 base::TimeTicks frame_time = NextTickTime() - interval_; |
87 base::TimeTicks deadline = NextTickTime(); | 87 base::TimeTicks deadline = NextTickTime(); |
88 return BeginFrameArgs::Create(frame_time, deadline, interval_); | 88 BeginFrameArgs args = |
| 89 BeginFrameArgs::Create(frame_time, deadline, interval_); |
| 90 args.AdjustDeadline(deadline_adjustment_); |
| 91 return args; |
89 } | 92 } |
90 return BeginFrameArgs(); | 93 return BeginFrameArgs(); |
91 } | 94 } |
92 | 95 |
93 void FrameRateController::SetMaxSwapsPending(int max_swaps_pending) { | 96 void FrameRateController::SetMaxSwapsPending(int max_swaps_pending) { |
94 DCHECK_GE(max_swaps_pending, 0); | 97 DCHECK_GE(max_swaps_pending, 0); |
95 max_swaps_pending_ = max_swaps_pending; | 98 max_swaps_pending_ = max_swaps_pending; |
96 } | 99 } |
97 | 100 |
98 void FrameRateController::SetTimebaseAndInterval(base::TimeTicks timebase, | 101 void FrameRateController::SetTimebaseAndInterval(base::TimeTicks timebase, |
(...skipping 13 matching lines...) Expand all Loading... |
112 DCHECK(active_); | 115 DCHECK(active_); |
113 | 116 |
114 // Check if we have too many frames in flight. | 117 // Check if we have too many frames in flight. |
115 bool throttled = | 118 bool throttled = |
116 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; | 119 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; |
117 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); | 120 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); |
118 | 121 |
119 if (client_) { | 122 if (client_) { |
120 // TODO(brianderson): Use an adaptive parent compositor deadline. | 123 // TODO(brianderson): Use an adaptive parent compositor deadline. |
121 base::TimeTicks frame_time = LastTickTime(); | 124 base::TimeTicks frame_time = LastTickTime(); |
122 base::TimeTicks deadline = NextTickTime() + deadline_adjustment_; | 125 base::TimeTicks deadline = NextTickTime(); |
123 client_->FrameRateControllerTick( | 126 BeginFrameArgs args = |
124 throttled, | 127 BeginFrameArgs::Create(frame_time, deadline, interval_); |
125 BeginFrameArgs::Create(frame_time, deadline, interval_)); | 128 args.AdjustDeadline(deadline_adjustment_); |
| 129 client_->FrameRateControllerTick(throttled, args); |
126 } | 130 } |
127 | 131 |
128 if (!is_time_source_throttling_ && !throttled) | 132 if (!is_time_source_throttling_ && !throttled) |
129 PostManualTick(); | 133 PostManualTick(); |
130 } | 134 } |
131 | 135 |
132 void FrameRateController::PostManualTick() { | 136 void FrameRateController::PostManualTick() { |
133 if (active_) { | 137 if (active_) { |
134 task_runner_->PostTask(FROM_HERE, | 138 task_runner_->PostTask(FROM_HERE, |
135 base::Bind(&FrameRateController::ManualTick, | 139 base::Bind(&FrameRateController::ManualTick, |
(...skipping 28 matching lines...) Expand all Loading... |
164 } | 168 } |
165 | 169 |
166 base::TimeTicks FrameRateController::LastTickTime() { | 170 base::TimeTicks FrameRateController::LastTickTime() { |
167 if (is_time_source_throttling_) | 171 if (is_time_source_throttling_) |
168 return time_source_->LastTickTime(); | 172 return time_source_->LastTickTime(); |
169 | 173 |
170 return base::TimeTicks::Now(); | 174 return base::TimeTicks::Now(); |
171 } | 175 } |
172 | 176 |
173 } // namespace cc | 177 } // namespace cc |
OLD | NEW |