Changeset 846 for trunk/src/corelib/animation
- Timestamp:
- May 5, 2011, 5:36:53 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
-
. (modified) (1 prop)
-
src/corelib/animation/qabstractanimation.cpp (modified) (13 diffs)
-
src/corelib/animation/qabstractanimation.h (modified) (1 diff)
-
src/corelib/animation/qabstractanimation_p.h (modified) (9 diffs)
-
src/corelib/animation/qanimationgroup.cpp (modified) (1 diff)
-
src/corelib/animation/qanimationgroup.h (modified) (1 diff)
-
src/corelib/animation/qanimationgroup_p.h (modified) (1 diff)
-
src/corelib/animation/qparallelanimationgroup.cpp (modified) (1 diff)
-
src/corelib/animation/qparallelanimationgroup.h (modified) (1 diff)
-
src/corelib/animation/qparallelanimationgroup_p.h (modified) (1 diff)
-
src/corelib/animation/qpauseanimation.cpp (modified) (1 diff)
-
src/corelib/animation/qpauseanimation.h (modified) (1 diff)
-
src/corelib/animation/qpropertyanimation.cpp (modified) (3 diffs)
-
src/corelib/animation/qpropertyanimation.h (modified) (1 diff)
-
src/corelib/animation/qpropertyanimation_p.h (modified) (1 diff)
-
src/corelib/animation/qsequentialanimationgroup.cpp (modified) (2 diffs)
-
src/corelib/animation/qsequentialanimationgroup.h (modified) (1 diff)
-
src/corelib/animation/qsequentialanimationgroup_p.h (modified) (1 diff)
-
src/corelib/animation/qvariantanimation.cpp (modified) (3 diffs)
-
src/corelib/animation/qvariantanimation.h (modified) (1 diff)
-
src/corelib/animation/qvariantanimation_p.h (modified) (1 diff)
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(); … … 262 290 void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation, bool isTopLevel) 263 291 { 264 registerRunningAnimation(animation); 292 QUnifiedTimer *inst = instance(true); //we create the instance if needed 293 inst->registerRunningAnimation(animation); 265 294 if (isTopLevel) { 266 295 Q_ASSERT(!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer); 267 296 QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = true; 268 animationsToStart << animation;269 if (! startStopAnimationTimer.isActive())270 startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this);297 animationsToStart << animation; 298 if (!startStopAnimationTimer.isActive()) 299 ); 271 300 } 272 301 } … … 274 303 void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation) 275 304 { 276 unregisterRunningAnimation(animation); 277 278 if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer) 279 return; 280 281 int idx = animations.indexOf(animation); 282 if (idx != -1) { 283 animations.removeAt(idx); 284 // this is needed if we unregister an animation while its running 285 if (idx <= currentAnimationIdx) 286 --currentAnimationIdx; 287 288 if (animations.isEmpty() && !startStopAnimationTimer.isActive()) 289 startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); 290 } else { 291 animationsToStart.removeOne(animation); 305 QUnifiedTimer *inst = QUnifiedTimer::instance(false); 306 if (inst) { 307 //at this point the unified timer should have been created 308 //but it might also have been already destroyed in case the application is shutting down 309 310 inst->unregisterRunningAnimation(animation); 311 312 if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer) 313 return; 314 315 int idx = inst->animations.indexOf(animation); 316 if (idx != -1) { 317 inst->animations.removeAt(idx); 318 // this is needed if we unregister an animation while its running 319 if (idx <= inst->currentAnimationIdx) 320 --inst->currentAnimationIdx; 321 322 if (inst->animations.isEmpty() && !inst->startStopAnimationTimer.isActive()) 323 inst->startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, inst); 324 } else { 325 inst->animationsToStart.removeOne(animation); 326 } 292 327 } 293 328 QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = false; … … 339 374 Q_Q(QAbstractAnimation); 340 375 if (state == newState) 376 377 378 341 379 return; 342 380 … … 364 402 if (oldState == QAbstractAnimation::Running) { 365 403 if (newState == QAbstractAnimation::Paused && hasRegisteredTimer) 366 QUnifiedTimer:: instance()->ensureTimerUpdate();404 QUnifiedTimer::ensureTimerUpdate(); 367 405 //the animation, is not running any more 368 QUnifiedTimer:: instance()->unregisterAnimation(q);406 QUnifiedTimer::unregisterAnimation(q); 369 407 } else if (newState == QAbstractAnimation::Running) { 370 QUnifiedTimer:: instance()->registerAnimation(q, isTopLevel);408 QUnifiedTimer::registerAnimation(q, isTopLevel); 371 409 } 372 410 … … 390 428 if (isTopLevel) { 391 429 // currentTime needs to be updated if pauseTimer is active 392 QUnifiedTimer:: instance()->ensureTimerUpdate();430 QUnifiedTimer::ensureTimerUpdate(); 393 431 q->setCurrentTime(totalCurrentTime); 394 432 } … … 449 487 emit stateChanged(oldState, d->state); 450 488 if (oldState == QAbstractAnimation::Running) 451 QUnifiedTimer:: instance()->unregisterAnimation(this);489 QUnifiedTimer::unregisterAnimation(this); 452 490 } 453 491 } … … 548 586 // then update the direction on this and all children and finally restart the pauseTimer if needed 549 587 if (d->hasRegisteredTimer) 550 QUnifiedTimer:: instance()->ensureTimerUpdate();588 QUnifiedTimer::ensureTimerUpdate(); 551 589 552 590 d->direction = direction; … … 555 593 if (d->hasRegisteredTimer) 556 594 // needed to update the timer interval in case of a pause animation 557 QUnifiedTimer:: instance()->restartAnimationTimer();595 QUnifiedTimer::AnimationTimer(); 558 596 559 597 emit directionChanged(direction); -
trunk/src/corelib/animation/qabstractanimation.h
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]) -
trunk/src/corelib/animation/qabstractanimation_p.h
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]) … … 57 57 #include <QtCore/qdatetime.h> 58 58 #include <QtCore/qtimer.h> 59 59 60 #include <private/qobject_p.h> 61 62 63 64 60 65 61 66 #ifndef QT_NO_ANIMATION … … 110 115 }; 111 116 117 112 118 113 119 class QUnifiedTimer : public QObject … … 119 125 //XXX this is needed by dui 120 126 static Q_CORE_EXPORT QUnifiedTimer *instance(); 121 122 void registerAnimation(QAbstractAnimation *animation, bool isTopLevel); 123 void unregisterAnimation(QAbstractAnimation *animation); 127 static QUnifiedTimer *instance(bool create); 128 129 static void registerAnimation(QAbstractAnimation *animation, bool isTopLevel); 130 static void unregisterAnimation(QAbstractAnimation *animation); 124 131 125 132 //defines the timing interval. Default is DEFAULT_TIMER_INTERVAL … … 139 146 void setConsistentTiming(bool consistent) { consistentTiming = consistent; } 140 147 141 //th is facilitatesfine-tuning of complex animations148 //th fine-tuning of complex animations 142 149 void setSlowModeEnabled(bool enabled) { slowMode = enabled; } 150 143 151 144 152 /* … … 146 154 timer is active or, otherwise, only of the animation passed as parameter. 147 155 */ 148 void ensureTimerUpdate();156 void ensureTimerUpdate(); 149 157 150 158 /* … … 152 160 some pause animations running. 153 161 */ 154 void restartAnimationTimer();162 AnimationTimer(); 155 163 156 164 protected: … … 163 171 QBasicTimer startStopAnimationTimer; 164 172 165 QTime time; 166 int lastTick; 173 ElapsedTimer time; 174 175 qint64 lastTick; 167 176 int timingInterval; 168 177 int currentAnimationIdx; 169 178 bool consistentTiming; 170 179 bool slowMode; 180 181 182 183 184 185 171 186 // bool to indicate that only pause animations are active 172 187 bool isPauseTimerActive; … … 181 196 void unregisterRunningAnimation(QAbstractAnimation *animation); 182 197 198 199 183 200 void updateAnimationsTime(); 184 201 int closestPauseAnimationTimeToFinish(); -
trunk/src/corelib/animation/qanimationgroup.cpp
r769 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]) -
trunk/src/corelib/animation/qanimationgroup.h
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]) -
trunk/src/corelib/animation/qanimationgroup_p.h
r769 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]) -
trunk/src/corelib/animation/qparallelanimationgroup.cpp
r769 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]) -
trunk/src/corelib/animation/qparallelanimationgroup.h
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]) -
trunk/src/corelib/animation/qparallelanimationgroup_p.h
r769 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]) -
trunk/src/corelib/animation/qpauseanimation.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]) -
trunk/src/corelib/animation/qpauseanimation.h
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]) -
trunk/src/corelib/animation/qpropertyanimation.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]) … … 119 119 if (!targetValue->dynamicPropertyNames().contains(propertyName)) 120 120 qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); 121 } 121 } else if (!targetValue->metaObject()->property(propertyIndex).isWritable()) { 122 qWarning("QPropertyAnimation: you're trying to animate the non-writable property %s of your QObject", propertyName.constData()); 123 } 122 124 } 123 125 … … 266 268 QPropertyAnimation *animToStop = 0; 267 269 { 270 268 271 QMutexLocker locker(QMutexPool::globalInstanceGet(&staticMetaObject)); 272 269 273 typedef QPair<QObject *, QByteArray> QPropertyAnimationPair; 270 274 typedef QHash<QPropertyAnimationPair, QPropertyAnimation*> QPropertyAnimationHash; -
trunk/src/corelib/animation/qpropertyanimation.h
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]) -
trunk/src/corelib/animation/qpropertyanimation_p.h
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]) -
trunk/src/corelib/animation/qsequentialanimationgroup.cpp
r769 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]) … … 465 465 void QSequentialAnimationGroupPrivate::activateCurrentAnimation(bool intermediate) 466 466 { 467 Q_Q(QSequentialAnimationGroup); 468 469 if (!currentAnimation) 470 return; 471 472 if (state == QSequentialAnimationGroup::Stopped) 467 if (!currentAnimation || state == QSequentialAnimationGroup::Stopped) 473 468 return; 474 469 -
trunk/src/corelib/animation/qsequentialanimationgroup.h
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]) -
trunk/src/corelib/animation/qsequentialanimationgroup_p.h
r769 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]) -
trunk/src/corelib/animation/qvariantanimation.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]) … … 436 436 if (!interpolators) 437 437 return; 438 438 439 QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators)); 440 439 441 if (int(interpolationType) >= interpolators->count()) 440 442 interpolators->resize(int(interpolationType) + 1); … … 451 453 { 452 454 QInterpolatorVector *interpolators = registeredInterpolators(); 455 453 456 QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators)); 457 454 458 QVariantAnimation::Interpolator ret = 0; 455 459 if (interpolationType < interpolators->count()) { -
trunk/src/corelib/animation/qvariantanimation.h
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]) -
trunk/src/corelib/animation/qvariantanimation_p.h
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])
Note:
See TracChangeset
for help on using the changeset viewer.
