Changeset 846 for trunk/src/corelib/animation/qabstractanimation.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/corelib/animation/qabstractanimation.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 162 162 QT_BEGIN_NAMESPACE 163 163 164 164 165 Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer) 166 165 167 166 168 QUnifiedTimer::QUnifiedTimer() : 167 169 QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), 168 170 currentAnimationIdx(0), consistentTiming(false), slowMode(false), 169 isPauseTimerActive(false), runningLeafAnimations(0) 170 { 171 } 172 173 QUnifiedTimer *QUnifiedTimer::instance() 171 slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0) 172 { 173 time.invalidate(); 174 } 175 176 177 QUnifiedTimer *QUnifiedTimer::instance(bool create) 174 178 { 175 179 QUnifiedTimer *inst; 176 if (!unifiedTimer()->hasLocalData()) { 180 #ifndef QT_NO_THREAD 181 if (create && !unifiedTimer()->hasLocalData()) { 177 182 inst = new QUnifiedTimer; 178 183 unifiedTimer()->setLocalData(inst); … … 180 185 inst = unifiedTimer()->localData(); 181 186 } 187 188 189 190 182 191 return inst; 183 192 } 184 193 194 195 196 197 198 185 199 void QUnifiedTimer::ensureTimerUpdate() 186 200 { 187 if (isPauseTimerActive) 188 updateAnimationsTime(); 201 QUnifiedTimer *inst = QUnifiedTimer::instance(false); 202 if (inst && inst->isPauseTimerActive) 203 inst->updateAnimationsTime(); 189 204 } 190 205 191 206 void QUnifiedTimer::updateAnimationsTime() 192 207 { 208 193 209 // ignore consistentTiming in case the pause timer is active 194 210 int delta = (consistentTiming && !isPauseTimerActive) ? 195 timingInterval : time.elapsed() - lastTick; 196 if (slowMode) 197 delta /= 5; 198 lastTick = time.elapsed(); 211 timingInterval : totalElapsed - lastTick; 212 if (slowMode) { 213 if (slowdownFactor > 0) 214 delta = qRound(delta / slowdownFactor); 215 else 216 delta = 0; 217 } 218 219 lastTick = totalElapsed; 199 220 200 221 //we make sure we only call update time if the time has actually changed … … 212 233 } 213 234 235 236 237 238 239 240 241 214 242 void QUnifiedTimer::restartAnimationTimer() 215 243 { … … 243 271 isPauseTimerActive = false; 244 272 // invalidate the start reference time 245 time = QTime();273 timee(); 246 274 } else { 247 275 restartAnimationTimer(); …