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 12 matching lines...) Expand all Loading... |
111 DCHECK(active_); | 114 DCHECK(active_); |
112 | 115 |
113 // Check if we have too many frames in flight. | 116 // Check if we have too many frames in flight. |
114 bool throttled = | 117 bool throttled = |
115 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; | 118 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; |
116 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); | 119 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); |
117 | 120 |
118 if (client_) { | 121 if (client_) { |
119 // TODO(brianderson): Use an adaptive parent compositor deadline. | 122 // TODO(brianderson): Use an adaptive parent compositor deadline. |
120 base::TimeTicks frame_time = LastTickTime(); | 123 base::TimeTicks frame_time = LastTickTime(); |
121 base::TimeTicks deadline = NextTickTime() + deadline_adjustment_; | 124 base::TimeTicks deadline = NextTickTime(); |
122 client_->FrameRateControllerTick( | 125 BeginFrameArgs args = |
123 throttled, | 126 BeginFrameArgs::Create(frame_time, deadline, interval_); |
124 BeginFrameArgs::Create(frame_time, deadline, interval_)); | 127 args.AdjustDeadline(deadline_adjustment_); |
| 128 client_->FrameRateControllerTick(throttled, args); |
125 } | 129 } |
126 | 130 |
127 if (!is_time_source_throttling_ && !throttled) | 131 if (!is_time_source_throttling_ && !throttled) |
128 PostManualTick(); | 132 PostManualTick(); |
129 } | 133 } |
130 | 134 |
131 void FrameRateController::PostManualTick() { | 135 void FrameRateController::PostManualTick() { |
132 if (active_) { | 136 if (active_) { |
133 task_runner_->PostTask(FROM_HERE, | 137 task_runner_->PostTask(FROM_HERE, |
134 base::Bind(&FrameRateController::ManualTick, | 138 base::Bind(&FrameRateController::ManualTick, |
(...skipping 28 matching lines...) Expand all Loading... |
163 } | 167 } |
164 | 168 |
165 base::TimeTicks FrameRateController::LastTickTime() { | 169 base::TimeTicks FrameRateController::LastTickTime() { |
166 if (is_time_source_throttling_) | 170 if (is_time_source_throttling_) |
167 return time_source_->LastTickTime(); | 171 return time_source_->LastTickTime(); |
168 | 172 |
169 return base::TimeTicks::Now(); | 173 return base::TimeTicks::Now(); |
170 } | 174 } |
171 | 175 |
172 } // namespace cc | 176 } // namespace cc |
OLD | NEW |