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