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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCFrameRateController.h" | 7 #include "CCFrameRateController.h" |
8 | 8 |
9 #include "CCDelayBasedTimeSource.h" | 9 #include "CCDelayBasedTimeSource.h" |
10 #include "CCTimeSource.h" | 10 #include "CCTimeSource.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 else { | 81 else { |
82 if (active) | 82 if (active) |
83 postManualTick(); | 83 postManualTick(); |
84 else | 84 else |
85 m_manualTicker->stop(); | 85 m_manualTicker->stop(); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 void CCFrameRateController::setMaxFramesPending(int maxFramesPending) | 89 void CCFrameRateController::setMaxFramesPending(int maxFramesPending) |
90 { | 90 { |
91 ASSERT(maxFramesPending > 0); | 91 DCHECK(maxFramesPending > 0); |
92 m_maxFramesPending = maxFramesPending; | 92 m_maxFramesPending = maxFramesPending; |
93 } | 93 } |
94 | 94 |
95 void CCFrameRateController::setTimebaseAndInterval(base::TimeTicks timebase, bas
e::TimeDelta interval) | 95 void CCFrameRateController::setTimebaseAndInterval(base::TimeTicks timebase, bas
e::TimeDelta interval) |
96 { | 96 { |
97 if (m_isTimeSourceThrottling) | 97 if (m_isTimeSourceThrottling) |
98 m_timeSource->setTimebaseAndInterval(timebase, interval); | 98 m_timeSource->setTimebaseAndInterval(timebase, interval); |
99 } | 99 } |
100 | 100 |
101 void CCFrameRateController::setSwapBuffersCompleteSupported(bool supported) | 101 void CCFrameRateController::setSwapBuffersCompleteSupported(bool supported) |
102 { | 102 { |
103 m_swapBuffersCompleteSupported = supported; | 103 m_swapBuffersCompleteSupported = supported; |
104 } | 104 } |
105 | 105 |
106 void CCFrameRateController::onTimerTick() | 106 void CCFrameRateController::onTimerTick() |
107 { | 107 { |
108 ASSERT(m_active); | 108 DCHECK(m_active); |
109 | 109 |
110 // Check if we have too many frames in flight. | 110 // Check if we have too many frames in flight. |
111 bool throttled = m_numFramesPending >= m_maxFramesPending; | 111 bool throttled = m_numFramesPending >= m_maxFramesPending; |
112 | 112 |
113 if (m_client) | 113 if (m_client) |
114 m_client->vsyncTick(throttled); | 114 m_client->vsyncTick(throttled); |
115 | 115 |
116 if (m_swapBuffersCompleteSupported && !m_isTimeSourceThrottling && m_numFram
esPending < m_maxFramesPending) | 116 if (m_swapBuffersCompleteSupported && !m_isTimeSourceThrottling && m_numFram
esPending < m_maxFramesPending) |
117 postManualTick(); | 117 postManualTick(); |
118 } | 118 } |
(...skipping 12 matching lines...) Expand all Loading... |
131 void CCFrameRateController::didBeginFrame() | 131 void CCFrameRateController::didBeginFrame() |
132 { | 132 { |
133 if (m_swapBuffersCompleteSupported) | 133 if (m_swapBuffersCompleteSupported) |
134 m_numFramesPending++; | 134 m_numFramesPending++; |
135 else if (!m_isTimeSourceThrottling) | 135 else if (!m_isTimeSourceThrottling) |
136 postManualTick(); | 136 postManualTick(); |
137 } | 137 } |
138 | 138 |
139 void CCFrameRateController::didFinishFrame() | 139 void CCFrameRateController::didFinishFrame() |
140 { | 140 { |
141 ASSERT(m_swapBuffersCompleteSupported); | 141 DCHECK(m_swapBuffersCompleteSupported); |
142 | 142 |
143 m_numFramesPending--; | 143 m_numFramesPending--; |
144 if (!m_isTimeSourceThrottling) | 144 if (!m_isTimeSourceThrottling) |
145 postManualTick(); | 145 postManualTick(); |
146 } | 146 } |
147 | 147 |
148 void CCFrameRateController::didAbortAllPendingFrames() | 148 void CCFrameRateController::didAbortAllPendingFrames() |
149 { | 149 { |
150 m_numFramesPending = 0; | 150 m_numFramesPending = 0; |
151 } | 151 } |
152 | 152 |
153 base::TimeTicks CCFrameRateController::nextTickTime() | 153 base::TimeTicks CCFrameRateController::nextTickTime() |
154 { | 154 { |
155 if (m_isTimeSourceThrottling) | 155 if (m_isTimeSourceThrottling) |
156 return m_timeSource->nextTickTime(); | 156 return m_timeSource->nextTickTime(); |
157 | 157 |
158 return base::TimeTicks(); | 158 return base::TimeTicks(); |
159 } | 159 } |
160 | 160 |
161 } | 161 } |
OLD | NEW |