aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@jollamobile.com>2014-03-28 11:43:47 -0500
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-08 01:39:37 +0200
commit02ad96fa8870630c6b77327098c712d6418b8fda (patch)
tree7f9557c1f00d80e3f16deb4e447cc34863b0a884 /src/quick/util
parent0a74379a57bcf68328ab167121c2dd16fc2d47c3 (diff)
Support dumping of animation jobs via QML_ANIMATION_TICK_DUMP.
Change-Id: I0b444321667691be3e1037164d02f29ed4dfc13e Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/quick/util')
-rw-r--r--src/quick/util/qquickanimation.cpp60
-rw-r--r--src/quick/util/qquickanimation_p_p.h14
-rw-r--r--src/quick/util/qquicksmoothedanimation.cpp7
-rw-r--r--src/quick/util/qquicksmoothedanimation_p_p.h1
-rw-r--r--src/quick/util/qquickspringanimation.cpp10
-rw-r--r--src/quick/util/qquicktimeline.cpp5
-rw-r--r--src/quick/util/qquicktimeline_p_p.h1
7 files changed, 95 insertions, 3 deletions
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index e46eb77ce2..10d2176d0a 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -873,6 +873,19 @@ void QActionAnimation::updateState(State newState, State oldState)
}
}
+void QActionAnimation::debugAnimation(QDebug d) const
+{
+ d << "ActionAnimation(" << hex << (void *) this << dec << ")";
+
+ if (animAction) {
+ int indentLevel = 1;
+ const QAbstractAnimationJob *job = this;
+ while ((job = job->group()))
+ ++indentLevel;
+ animAction->debugAction(d, indentLevel);
+ }
+}
+
/*!
\qmltype ScriptAction
\instantiates QQuickScriptAction
@@ -957,6 +970,22 @@ QAbstractAnimationAction* QQuickScriptActionPrivate::createAction()
return new Proxy(this);
}
+void QQuickScriptActionPrivate::debugAction(QDebug d, int indentLevel) const
+{
+ QQmlScriptString scriptStr = hasRunScriptScript ? runScriptScript : script;
+
+ if (!scriptStr.isEmpty()) {
+ QQmlExpression expr(scriptStr);
+
+ QByteArray ind(indentLevel, ' ');
+ QString exprStr = expr.expression();
+ int endOfFirstLine = exprStr.indexOf('\n');
+ d << "\n" << ind.constData() << exprStr.left(endOfFirstLine);
+ if (endOfFirstLine != -1 && endOfFirstLine < exprStr.length())
+ d << "...";
+ }
+}
+
void QQuickScriptActionPrivate::execute()
{
Q_Q(QQuickScriptAction);
@@ -1170,6 +1199,14 @@ QAbstractAnimationJob* QQuickPropertyAction::transition(QQuickStateActions &acti
QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding);
}
}
+ virtual void debugAction(QDebug d, int indentLevel) const {
+ QByteArray ind(indentLevel, ' ');
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ const QQuickStateAction &action = actions.at(ii);
+ d << "\n" << ind.constData() << "target:" << action.property.object() << "property:" << action.property.name()
+ << "value:" << action.toValue;
+ }
+ }
};
QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
@@ -1929,6 +1966,19 @@ void QQuickBulkValueAnimator::topLevelAnimationLoopChanged()
QAbstractAnimationJob::topLevelAnimationLoopChanged();
}
+void QQuickBulkValueAnimator::debugAnimation(QDebug d) const
+{
+ d << "BulkValueAnimation(" << hex << (void *) this << dec << ")" << "duration:" << duration();
+
+ if (animValue) {
+ int indentLevel = 1;
+ const QAbstractAnimationJob *job = this;
+ while ((job = job->group()))
+ ++indentLevel;
+ animValue->debugUpdater(d, indentLevel);
+ }
+}
+
/*!
\qmltype PropertyAnimation
\instantiates QQuickPropertyAnimation
@@ -2502,6 +2552,16 @@ void QQuickAnimationPropertyUpdater::setValue(qreal v)
fromSourced = true;
}
+void QQuickAnimationPropertyUpdater::debugUpdater(QDebug d, int indentLevel) const
+{
+ QByteArray ind(indentLevel, ' ');
+ for (int i = 0; i < actions.count(); ++i) {
+ const QQuickStateAction &action = actions.at(i);
+ d << "\n" << ind.constData() << "target:" << action.property.object() << "property:" << action.property.name()
+ << "from:" << action.fromValue << "to:" << action.toValue;
+ }
+}
+
QQuickStateActions QQuickPropertyAnimation::createTransitionActions(QQuickStateActions &actions,
QQmlProperties &modified,
QObject *defaultTarget)
diff --git a/src/quick/util/qquickanimation_p_p.h b/src/quick/util/qquickanimation_p_p.h
index 127f447e5d..f2b5f6388f 100644
--- a/src/quick/util/qquickanimation_p_p.h
+++ b/src/quick/util/qquickanimation_p_p.h
@@ -79,18 +79,19 @@ class QAbstractAnimationAction
public:
virtual ~QAbstractAnimationAction() {}
virtual void doAction() = 0;
+ virtual void debugAction(QDebug, int) const {}
};
//templated animation action
//allows us to specify an action that calls a function of a class.
//(so that class doesn't have to inherit QQuickAbstractAnimationAction)
-template<class T, void (T::*method)()>
+template<class T, void (T::*method)(), void (T::*debugMethod)(QDebug, int) const>
class QAnimationActionProxy : public QAbstractAnimationAction
{
public:
QAnimationActionProxy(T *instance) : m_instance(instance) {}
virtual void doAction() { (m_instance->*method)(); }
-
+ virtual void debugAction(QDebug d, int indentLevel) const { (m_instance->*debugMethod)(d, indentLevel); }
private:
T *m_instance;
};
@@ -111,6 +112,7 @@ public:
protected:
virtual void updateCurrentTime(int);
virtual void updateState(State newState, State oldState);
+ void debugAnimation(QDebug d) const;
private:
QAbstractAnimationAction *animAction;
@@ -121,6 +123,7 @@ class QQuickBulkValueUpdater
public:
virtual ~QQuickBulkValueUpdater() {}
virtual void setValue(qreal value) = 0;
+ virtual void debugUpdater(QDebug, int) const {}
};
//animates QQuickBulkValueUpdater (assumes start and end values will be reals or compatible)
@@ -145,6 +148,7 @@ public:
protected:
void updateCurrentTime(int currentTime);
void topLevelAnimationLoopChanged();
+ void debugAnimation(QDebug d) const;
private:
QQuickBulkValueUpdater *animValue;
@@ -224,8 +228,10 @@ public:
void execute();
QAbstractAnimationAction* createAction();
+ void debugAction(QDebug d, int indentLevel) const;
typedef QAnimationActionProxy<QQuickScriptActionPrivate,
- &QQuickScriptActionPrivate::execute> Proxy;
+ &QQuickScriptActionPrivate::execute,
+ &QQuickScriptActionPrivate::debugAction> Proxy;
};
class QQuickPropertyActionPrivate : public QQuickAbstractAnimationPrivate
@@ -307,6 +313,8 @@ public:
void setValue(qreal v);
+ void debugUpdater(QDebug d, int indentLevel) const;
+
QQuickStateActions actions;
int interpolatorType; //for Number/ColorAnimation
QVariantAnimation::Interpolator interpolator;
diff --git a/src/quick/util/qquicksmoothedanimation.cpp b/src/quick/util/qquicksmoothedanimation.cpp
index a0e6c36830..a23f7a5df6 100644
--- a/src/quick/util/qquicksmoothedanimation.cpp
+++ b/src/quick/util/qquicksmoothedanimation.cpp
@@ -313,6 +313,13 @@ void QSmoothedAnimation::init()
}
}
+void QSmoothedAnimation::debugAnimation(QDebug d) const
+{
+ d << "SmoothedAnimationJob(" << hex << (void *) this << dec << ")" << "duration:" << userDuration
+ << "velocity:" << velocity << "target:" << target.object() << "property:" << target.name()
+ << "to:" << to << "current velocity:" << trackVelocity;
+}
+
/*!
\qmltype SmoothedAnimation
\instantiates QQuickSmoothedAnimation
diff --git a/src/quick/util/qquicksmoothedanimation_p_p.h b/src/quick/util/qquicksmoothedanimation_p_p.h
index 7835d0328b..3c85f09b04 100644
--- a/src/quick/util/qquicksmoothedanimation_p_p.h
+++ b/src/quick/util/qquicksmoothedanimation_p_p.h
@@ -105,6 +105,7 @@ public:
protected:
virtual void updateCurrentTime(int);
virtual void updateState(QAbstractAnimationJob::State, QAbstractAnimationJob::State);
+ void debugAnimation(QDebug d) const;
private:
qreal easeFollow(qreal);
diff --git a/src/quick/util/qquickspringanimation.cpp b/src/quick/util/qquickspringanimation.cpp
index f237c09bf9..4b1abcef8c 100644
--- a/src/quick/util/qquickspringanimation.cpp
+++ b/src/quick/util/qquickspringanimation.cpp
@@ -101,6 +101,7 @@ public:
protected:
virtual void updateCurrentTime(int time);
virtual void updateState(QAbstractAnimationJob::State, QAbstractAnimationJob::State);
+ void debugAnimation(QDebug d) const;
private:
QQuickSpringAnimationPrivate *animationTemplate;
@@ -320,6 +321,15 @@ void QSpringAnimation::updateState(QAbstractAnimationJob::State newState, QAbstr
init();
}
+void QSpringAnimation::debugAnimation(QDebug d) const
+{
+ d << "SpringAnimationJob(" << hex << (void *) this << dec << ")" << "velocity:" << maxVelocity
+ << "spring:" << spring << "damping:" << damping << "epsilon:" << epsilon << "modulus:" << modulus
+ << "mass:" << mass << "target:" << target.object() << "property:" << target.name()
+ << "to:" << to << "current velocity:" << velocity;
+}
+
+
void QQuickSpringAnimationPrivate::updateMode()
{
if (spring == 0. && maxVelocity == 0.)
diff --git a/src/quick/util/qquicktimeline.cpp b/src/quick/util/qquicktimeline.cpp
index 94e1f30215..f9928c4d00 100644
--- a/src/quick/util/qquicktimeline.cpp
+++ b/src/quick/util/qquicktimeline.cpp
@@ -723,6 +723,11 @@ void QQuickTimeLine::updateCurrentTime(int v)
}
}
+void QQuickTimeLine::debugAnimation(QDebug d) const
+{
+ d << "QuickTimeLine(" << hex << (void *) this << dec << ")";
+}
+
bool operator<(const QPair<int, Update> &lhs,
const QPair<int, Update> &rhs)
{
diff --git a/src/quick/util/qquicktimeline_p_p.h b/src/quick/util/qquicktimeline_p_p.h
index a99a515f0a..0172ecbfcf 100644
--- a/src/quick/util/qquicktimeline_p_p.h
+++ b/src/quick/util/qquicktimeline_p_p.h
@@ -109,6 +109,7 @@ Q_SIGNALS:
protected:
virtual void updateCurrentTime(int);
+ void debugAnimation(QDebug d) const;
private:
void remove(QQuickTimeLineObject *);