Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/corelib/animation/qabstractanimation.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    162162QT_BEGIN_NAMESPACE
    163163
     164
    164165Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
     166
    165167
    166168QUnifiedTimer::QUnifiedTimer() :
    167169    QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
    168170    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
     177QUnifiedTimer *QUnifiedTimer::instance(bool create)
    174178{
    175179    QUnifiedTimer *inst;
    176     if (!unifiedTimer()->hasLocalData()) {
     180#ifndef QT_NO_THREAD
     181    if (create && !unifiedTimer()->hasLocalData()) {
    177182        inst = new QUnifiedTimer;
    178183        unifiedTimer()->setLocalData(inst);
     
    180185        inst = unifiedTimer()->localData();
    181186    }
     187
     188
     189
     190
    182191    return inst;
    183192}
    184193
     194
     195
     196
     197
     198
    185199void QUnifiedTimer::ensureTimerUpdate()
    186200{
    187     if (isPauseTimerActive)
    188         updateAnimationsTime();
     201    QUnifiedTimer *inst = QUnifiedTimer::instance(false);
     202    if (inst && inst->isPauseTimerActive)
     203        inst->updateAnimationsTime();
    189204}
    190205
    191206void QUnifiedTimer::updateAnimationsTime()
    192207{
     208
    193209    // ignore consistentTiming in case the pause timer is active
    194210    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;
    199220
    200221    //we make sure we only call update time if the time has actually changed
     
    212233}
    213234
     235
     236
     237
     238
     239
     240
     241
    214242void QUnifiedTimer::restartAnimationTimer()
    215243{
     
    243271            isPauseTimerActive = false;
    244272            // invalidate the start reference time
    245             time = QTime();
     273            timee();
    246274        } else {
    247275            restartAnimationTimer();