diff options
author | Nicolas Roard <nicolas@android.com> | 2010-02-11 18:40:34 +0000 |
---|---|---|
committer | Nicolas Roard <nicolas@android.com> | 2010-02-12 11:29:24 +0000 |
commit | fe41360961a5f02a9f54dbe4922d301ef4bc4a20 (patch) | |
tree | 3fb6dcaafc452ac68c36ac518eb4f3c957270a20 /WebCore/platform | |
parent | c557fc762122cd1bbc9a15778b86728c884a2dfb (diff) | |
download | external_webkit-fe41360961a5f02a9f54dbe4922d301ef4bc4a20.zip external_webkit-fe41360961a5f02a9f54dbe4922d301ef4bc4a20.tar.gz external_webkit-fe41360961a5f02a9f54dbe4922d301ef4bc4a20.tar.bz2 |
Put back the animations in the UI thread
Diffstat (limited to 'WebCore/platform')
4 files changed, 16 insertions, 112 deletions
diff --git a/WebCore/platform/graphics/android/AndroidAnimation.cpp b/WebCore/platform/graphics/android/AndroidAnimation.cpp index ca1acbe..2b1b252 100644 --- a/WebCore/platform/graphics/android/AndroidAnimation.cpp +++ b/WebCore/platform/graphics/android/AndroidAnimation.cpp @@ -30,18 +30,6 @@ namespace WebCore { -void AndroidTransformAnimationValue::apply() -{ - if (m_doTranslation) - m_layer->setTranslation(m_translation.x(), m_translation.y()); - - if (m_doScaling) - m_layer->setScale(m_scale.x(), m_scale.y()); - - if (m_doRotation) - m_layer->setRotation(m_rotation); -} - static long gDebugAndroidAnimationInstances; long AndroidAnimation::instancesCount() @@ -125,13 +113,6 @@ bool AndroidAnimation::checkIterationsAndProgress(double time, float* finalProgr return true; } -PassRefPtr<AndroidAnimationValue> AndroidAnimation::result() -{ - if (!m_result) - return 0; - return m_result.release(); -} - PassRefPtr<AndroidOpacityAnimation> AndroidOpacityAnimation::create( float fromValue, float toValue, @@ -179,7 +160,7 @@ bool AndroidOpacityAnimation::evaluate(LayerAndroid* layer, double time) return true; float value = m_fromValue + ((m_toValue - m_fromValue) * progress); - m_result = AndroidOpacityAnimationValue::create(layer, value); + layer->setOpacity(value); return true; } @@ -294,14 +275,15 @@ bool AndroidTransformAnimation::evaluate(LayerAndroid* layer, double time) float sz = m_fromScaleZ + (m_toScaleZ - m_fromScaleZ) * progress; float a = m_fromAngle + (m_toAngle - m_fromAngle) * progress; - FloatPoint translation(x, y); - FloatPoint3D scale(sx, sy, sz); - RefPtr<AndroidTransformAnimationValue> result = - AndroidTransformAnimationValue::create(layer, translation, scale, a); - result->setDoTranslation(m_doTranslation); - result->setDoScaling(m_doScaling); - result->setDoRotation(m_doRotation); - m_result = result.release(); + if (m_doTranslation) + layer->setTranslation(x, y); + + if (m_doScaling) + layer->setScale(sx, sy); + + if (m_doRotation) + layer->setRotation(a); + return true; } diff --git a/WebCore/platform/graphics/android/AndroidAnimation.h b/WebCore/platform/graphics/android/AndroidAnimation.h index 75e2f35..1eb13d4 100644 --- a/WebCore/platform/graphics/android/AndroidAnimation.h +++ b/WebCore/platform/graphics/android/AndroidAnimation.h @@ -30,63 +30,8 @@ namespace WebCore { -class AndroidAnimation; class TimingFunction; -class AndroidAnimationValue : public RefCounted<AndroidAnimationValue> { - public: - AndroidAnimationValue(LayerAndroid* layer) : m_layer(layer) { } - virtual ~AndroidAnimationValue() { } - virtual void apply() = 0; - protected: - RefPtr<LayerAndroid> m_layer; -}; - -class AndroidOpacityAnimationValue : public AndroidAnimationValue { - public: - static PassRefPtr<AndroidOpacityAnimationValue> create( - LayerAndroid* layer, float value) { - return adoptRef(new AndroidOpacityAnimationValue(layer, value)); - } - AndroidOpacityAnimationValue(LayerAndroid* layer, float value) : - AndroidAnimationValue(layer), m_value(value) { } - virtual void apply() { m_layer->setOpacity(m_value); } - private: - float m_value; -}; - -class AndroidTransformAnimationValue : public AndroidAnimationValue { - public: - static PassRefPtr<AndroidTransformAnimationValue> create( - LayerAndroid* layer, - FloatPoint translation, - FloatPoint3D scale, - float rotation) { - return adoptRef(new AndroidTransformAnimationValue(layer, translation, scale, rotation)); - } - - AndroidTransformAnimationValue(LayerAndroid* layer, - FloatPoint translation, - FloatPoint3D scale, - float rotation) : - AndroidAnimationValue(layer), - m_doTranslation(false), m_doScaling(false), m_doRotation(false), - m_translation(translation), m_scale(scale), m_rotation(rotation) { } - void setDoTranslation(bool doTranslation) { m_doTranslation = doTranslation; } - void setDoScaling(bool doScaling) { m_doScaling = doScaling; } - void setDoRotation(bool doRotation) { m_doRotation = doRotation; } - - virtual void apply(); - - private: - bool m_doTranslation; - bool m_doScaling; - bool m_doRotation; - FloatPoint m_translation; - FloatPoint3D m_scale; - float m_rotation; -}; - class AndroidAnimation : public RefCounted<AndroidAnimation> { public: AndroidAnimation(const Animation* animation, @@ -102,10 +47,8 @@ class AndroidAnimation : public RefCounted<AndroidAnimation> { static long instancesCount(); void setName(const String& name) { m_name = name; } String name() { return m_name; } - virtual PassRefPtr<AndroidAnimationValue> result(); protected: - RefPtr<AndroidAnimationValue> m_result; double m_beginTime; double m_elapsedTime; double m_duration; diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index f741370..d5c5442 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -17,12 +17,6 @@ #define LAYER_DEBUG // Add diagonals for debugging #undef LAYER_DEBUG -#include <cutils/log.h> -#include <wtf/CurrentTime.h> - -#undef LOG -#define LOG(...) android_printLog(ANDROID_LOG_DEBUG, "LayerAndroid", __VA_ARGS__) - namespace WebCore { static int gDebugLayerAndroidInstances; @@ -95,15 +89,11 @@ LayerAndroid::~LayerAndroid() static int gDebugNbAnims = 0; -Vector<RefPtr<AndroidAnimationValue> >* LayerAndroid::evaluateAnimations() const +bool LayerAndroid::evaluateAnimations() const { double time = WTF::currentTime(); - Vector<RefPtr<AndroidAnimationValue> >* results = new Vector<RefPtr<AndroidAnimationValue> >(); gDebugNbAnims = 0; - if (evaluateAnimations(time, results)) - return results; - delete results; - return 0; + return evaluateAnimations(time); } bool LayerAndroid::hasAnimations() const @@ -115,12 +105,11 @@ bool LayerAndroid::hasAnimations() const return !!m_animations.size(); } -bool LayerAndroid::evaluateAnimations(double time, - Vector<RefPtr<AndroidAnimationValue> >* results) const +bool LayerAndroid::evaluateAnimations(double time) const { bool hasRunningAnimations = false; for (unsigned int i = 0; i < m_children.size(); i++) { - if (m_children[i]->evaluateAnimations(time, results)) + if (m_children[i]->evaluateAnimations(time)) hasRunningAnimations = true; } KeyframesMap::const_iterator end = m_animations.end(); @@ -128,9 +117,6 @@ bool LayerAndroid::evaluateAnimations(double time, gDebugNbAnims++; LayerAndroid* currentLayer = const_cast<LayerAndroid*>(this); if ((it->second)->evaluate(currentLayer, time)) { - RefPtr<AndroidAnimationValue> result = (it->second)->result(); - if (result) - results->append(result); hasRunningAnimations = true; } } @@ -196,7 +182,6 @@ void LayerAndroid::paintOn(SkPoint offset, SkSize size, SkScalar scale, SkCanvas int scrollY = offset.fY; int width = size.width(); int height = size.height(); - LOG("(%x) PaintOn (scroll(%d,%d) width(%d) height(%d)", this, scrollX, scrollY, width, height); paintChildren(scrollX, scrollY, width, height, scale, canvas, 1); } @@ -245,8 +230,6 @@ void LayerAndroid::paintMe(int scrollX, SkCanvas* canvas, float opacity) { - LOG("(%x) A - paint me (width: %.2f height: %.2f), anchor(%.2f, %.2f), translate(%.2f, %.2f), position(%.2f, %.2f) angle(%.2f) fixed(%d) rotation(%d)", - this, m_size.width(), m_size.height(), m_anchorPoint.fX, m_anchorPoint.fY, m_translation.fX, m_translation.fY, m_position.fX, m_position.fY, m_angleTransform, m_isFixed, m_doRotation); if (!prepareContext()) return; @@ -311,9 +294,6 @@ void LayerAndroid::paintMe(int scrollX, canvas->scale(sx, sy); } - LOG("(%x) B - paint me (width: %.2f height: %.2f) with x(%.2f) y(%.2f), scale (%.2f, %.2f), anchor(%.2f, %.2f), translate(%.2f, %.2f), position(%.2f, %.2f) angle(%.2f) fixed(%d) rotation(%d)", - this, m_size.width(), m_size.height(), x, y, sx, sy, m_anchorPoint.fX, m_anchorPoint.fY, m_translation.fX, m_translation.fY, m_position.fX, m_position.fY, m_angleTransform, m_isFixed, m_doRotation); - m_recordingPicture->draw(canvas); #ifdef LAYER_DEBUG diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index 480521b..06f1a74 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -69,9 +69,8 @@ public: void addAnimation(PassRefPtr<AndroidAnimation> anim); void removeAnimation(const String& name); - Vector<RefPtr<AndroidAnimationValue> >* evaluateAnimations() const; - bool evaluateAnimations(double time, - Vector<RefPtr<AndroidAnimationValue> >* results) const; + bool evaluateAnimations() const; + bool evaluateAnimations(double time) const; bool hasAnimations() const; private: |