summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/android/AndroidAnimation.cpp
diff options
context:
space:
mode:
authorRussell Brenner <russellbrenner@google.com>2011-03-08 14:20:31 -0800
committerRussell Brenner <russellbrenner@google.com>2011-03-08 16:43:43 -0800
commit8d060c05a073fedcf8cd4142926ff5a5e1991de9 (patch)
tree75568185c4a640e20b8b2b41d56f0cd3a4870ce5 /WebCore/platform/graphics/android/AndroidAnimation.cpp
parent4ffd02f8c673bc6ce1a6b96f9fd3b21e8337ec7c (diff)
downloadexternal_webkit-8d060c05a073fedcf8cd4142926ff5a5e1991de9.zip
external_webkit-8d060c05a073fedcf8cd4142926ff5a5e1991de9.tar.gz
external_webkit-8d060c05a073fedcf8cd4142926ff5a5e1991de9.tar.bz2
Fix 2453890: animation via css -webkit-transform
Followed model used for transform animations. Tested with http://www.webkit.org/blog-files/leaves/. Fixes http://b/2453890. Change-Id: Ie71217743b6e1ee9ab0e023fdff44e8c65c8d477
Diffstat (limited to 'WebCore/platform/graphics/android/AndroidAnimation.cpp')
-rw-r--r--WebCore/platform/graphics/android/AndroidAnimation.cpp62
1 files changed, 51 insertions, 11 deletions
diff --git a/WebCore/platform/graphics/android/AndroidAnimation.cpp b/WebCore/platform/graphics/android/AndroidAnimation.cpp
index e01bf55..47fc82c 100644
--- a/WebCore/platform/graphics/android/AndroidAnimation.cpp
+++ b/WebCore/platform/graphics/android/AndroidAnimation.cpp
@@ -136,28 +136,25 @@ bool AndroidAnimation::checkIterationsAndProgress(double time, float* finalProgr
}
PassRefPtr<AndroidOpacityAnimation> AndroidOpacityAnimation::create(
- float fromValue,
- float toValue,
const Animation* animation,
+ KeyframeValueList* operations,
double beginTime)
{
- return adoptRef(new AndroidOpacityAnimation(fromValue, toValue,
- animation, beginTime));
+ return adoptRef(new AndroidOpacityAnimation(animation, operations,
+ beginTime));
}
-AndroidOpacityAnimation::AndroidOpacityAnimation(float fromValue, float toValue,
- const Animation* animation,
+AndroidOpacityAnimation::AndroidOpacityAnimation(const Animation* animation,
+ KeyframeValueList* operations,
double beginTime)
: AndroidAnimation(animation, beginTime)
- , m_fromValue(fromValue)
- , m_toValue(toValue)
+ , m_operations(operations)
{
}
AndroidOpacityAnimation::AndroidOpacityAnimation(AndroidOpacityAnimation* anim)
: AndroidAnimation(anim)
- , m_fromValue(anim->m_fromValue)
- , m_toValue(anim->m_toValue)
+ , m_operations(anim->m_operations)
{
}
@@ -175,8 +172,51 @@ bool AndroidOpacityAnimation::evaluate(LayerAndroid* layer, double time)
if (progress < 0) // we still want to be evaluated until we get progress > 0
return true;
- float value = m_fromValue + ((m_toValue - m_fromValue) * progress);
+ // First, we need to get the from and to values
+
+ FloatAnimationValue* fromValue = 0;
+ FloatAnimationValue* toValue = 0;
+
+ float distance = 0;
+ unsigned int foundAt = 0;
+ for (unsigned int i = 0; i < m_operations->size(); i++) {
+ FloatAnimationValue* value = (FloatAnimationValue*) m_operations->at(i);
+ float opacity = (float) value->value();
+ float key = value->keyTime();
+ float d = progress - key;
+ XLOG("[%d] Key %.2f, opacity %.4f", i, key, opacity);
+ if (!fromValue || (d > 0 && d < distance && i + 1 < m_operations->size())) {
+ fromValue = value;
+ distance = d;
+ foundAt = i;
+ }
+ }
+
+ if (foundAt + 1 < m_operations->size())
+ toValue = (FloatAnimationValue*) m_operations->at(foundAt + 1);
+ else
+ toValue = fromValue;
+
+ XLOG("[layer %d] fromValue %x, key %.2f, toValue %x, key %.2f for progress %.2f",
+ layer->uniqueId(),
+ fromValue, fromValue->keyTime(),
+ toValue, toValue->keyTime(), progress);
+
+ // We now have the correct two values to work with, let's compute the
+ // progress value
+
+ float delta = toValue->keyTime() - fromValue->keyTime();
+ float rprogress = (progress - fromValue->keyTime()) / delta;
+ XLOG("We picked keys %.2f to %.2f for progress %.2f, real progress %.2f",
+ fromValue->keyTime(), toValue->keyTime(), progress, rprogress);
+ progress = rprogress;
+
+ float from = (float) fromValue->value();
+ float to = (float) toValue->value();
+ float value = from + ((to - from) * progress);
+
layer->setOpacity(value);
+ XLOG("AndroidOpacityAnimation::evaluate(%p, %p, %L) value=%.6f", this, layer, time, value);
return true;
}