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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 if (active) | 79 if (active) |
80 PostManualTick(); | 80 PostManualTick(); |
81 else | 81 else |
82 weak_factory_.InvalidateWeakPtrs(); | 82 weak_factory_.InvalidateWeakPtrs(); |
83 } | 83 } |
84 | 84 |
85 if (just_activated) { | 85 if (just_activated) { |
86 // TODO(brianderson): Use an adaptive parent compositor deadline. | 86 // TODO(brianderson): Use an adaptive parent compositor deadline. |
87 base::TimeTicks frame_time = NextTickTime() - interval_; | 87 base::TimeTicks frame_time = NextTickTime() - interval_; |
88 base::TimeTicks deadline = NextTickTime(); | 88 base::TimeTicks deadline = NextTickTime(); |
89 return BeginFrameArgs::Create(frame_time, deadline, interval_); | 89 BeginFrameArgs args = |
90 BeginFrameArgs::Create(frame_time, deadline, interval_); | |
91 args.AdjustDeadline(deadline_adjustment_); | |
92 return args; | |
90 } | 93 } |
91 return BeginFrameArgs(); | 94 return BeginFrameArgs(); |
92 } | 95 } |
93 | 96 |
94 void FrameRateController::SetMaxSwapsPending(int max_swaps_pending) { | 97 void FrameRateController::SetMaxSwapsPending(int max_swaps_pending) { |
95 DCHECK_GE(max_swaps_pending, 0); | 98 DCHECK_GE(max_swaps_pending, 0); |
96 max_swaps_pending_ = max_swaps_pending; | 99 max_swaps_pending_ = max_swaps_pending; |
97 } | 100 } |
98 | 101 |
99 void FrameRateController::SetTimebaseAndInterval(base::TimeTicks timebase, | 102 void FrameRateController::SetTimebaseAndInterval(base::TimeTicks timebase, |
100 base::TimeDelta interval) { | 103 base::TimeDelta interval) { |
104 timebase = base::TimeTicks(); | |
brianderson
2013/07/18 02:02:49
This is a hack to keep the phase from changing eve
| |
101 interval_ = interval; | 105 interval_ = interval; |
102 if (is_time_source_throttling_) | 106 if (is_time_source_throttling_) |
103 time_source_->SetTimebaseAndInterval(timebase, interval); | 107 time_source_->SetTimebaseAndInterval(timebase, interval); |
104 } | 108 } |
105 | 109 |
106 void FrameRateController::SetDeadlineAdjustment(base::TimeDelta delta) { | 110 void FrameRateController::SetDeadlineAdjustment(base::TimeDelta delta) { |
107 deadline_adjustment_ = delta; | 111 deadline_adjustment_ = delta; |
108 } | 112 } |
109 | 113 |
110 void FrameRateController::OnTimerTick() { | 114 void FrameRateController::OnTimerTick() { |
111 TRACE_EVENT0("cc", "FrameRateController::OnTimerTick"); | 115 TRACE_EVENT0("cc", "FrameRateController::OnTimerTick"); |
112 DCHECK(active_); | 116 DCHECK(active_); |
113 | 117 |
114 // Check if we have too many frames in flight. | 118 // Check if we have too many frames in flight. |
115 bool throttled = | 119 bool throttled = |
116 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; | 120 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; |
117 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); | 121 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); |
118 | 122 |
119 if (client_) { | 123 if (client_) { |
120 // TODO(brianderson): Use an adaptive parent compositor deadline. | 124 // TODO(brianderson): Use an adaptive parent compositor deadline. |
121 base::TimeTicks frame_time = LastTickTime(); | 125 base::TimeTicks frame_time = LastTickTime(); |
122 base::TimeTicks deadline = NextTickTime() + deadline_adjustment_; | 126 base::TimeTicks deadline = NextTickTime(); |
123 client_->FrameRateControllerTick( | 127 BeginFrameArgs args = |
124 throttled, | 128 BeginFrameArgs::Create(frame_time, deadline, interval_); |
125 BeginFrameArgs::Create(frame_time, deadline, interval_)); | 129 args.AdjustDeadline(deadline_adjustment_); |
130 client_->FrameRateControllerTick(throttled, args); | |
126 } | 131 } |
127 | 132 |
128 if (!is_time_source_throttling_ && !throttled) | 133 if (!is_time_source_throttling_ && !throttled) |
129 PostManualTick(); | 134 PostManualTick(); |
130 } | 135 } |
131 | 136 |
132 void FrameRateController::PostManualTick() { | 137 void FrameRateController::PostManualTick() { |
133 if (active_) { | 138 if (active_) { |
134 task_runner_->PostTask(FROM_HERE, | 139 task_runner_->PostTask(FROM_HERE, |
135 base::Bind(&FrameRateController::ManualTick, | 140 base::Bind(&FrameRateController::ManualTick, |
(...skipping 28 matching lines...) Expand all Loading... | |
164 } | 169 } |
165 | 170 |
166 base::TimeTicks FrameRateController::LastTickTime() { | 171 base::TimeTicks FrameRateController::LastTickTime() { |
167 if (is_time_source_throttling_) | 172 if (is_time_source_throttling_) |
168 return time_source_->LastTickTime(); | 173 return time_source_->LastTickTime(); |
169 | 174 |
170 return base::TimeTicks::Now(); | 175 return base::TimeTicks::Now(); |
171 } | 176 } |
172 | 177 |
173 } // namespace cc | 178 } // namespace cc |
OLD | NEW |