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