Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b127713b authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Re-enable ViewPropAnimRT"

parents 15d0f974 2218472d
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -253,10 +253,9 @@ public class ViewPropertyAnimator {
    ViewPropertyAnimator(View view) {
        mView = view;
        view.ensureTransformationInfo();
        // TODO: Disabled because of b/15287046
        //if (view.getContext().getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.L) {
        //    mRTBackend = new ViewPropertyAnimatorRT(view);
        //}
        if (view.getContext().getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.L) {
            mRTBackend = new ViewPropertyAnimatorRT(view);
        }
    }

    /**
@@ -434,6 +433,9 @@ public class ViewPropertyAnimator {
        }
        mPendingAnimations.clear();
        mView.removeCallbacks(mAnimationStarter);
        if (mRTBackend != null) {
            mRTBackend.cancelAll();
        }
    }

    /**
+26 −0
Original line number Diff line number Diff line
@@ -50,6 +50,15 @@ class ViewPropertyAnimatorRT {
        return true;
    }

    public void cancelAll() {
        for (int i = 0; i < mAnimators.length; i++) {
            if (mAnimators[i] != null) {
                mAnimators[i].cancel();
                mAnimators[i] = null;
            }
        }
    }

    private void doStartAnimation(ViewPropertyAnimator parent) {
        int size = parent.mPendingAnimations.size();

@@ -99,10 +108,27 @@ class ViewPropertyAnimatorRT {
        if (parent.hasActions()) {
            return false;
        }
        if (hasAlphaAnimation(parent)) {
            // TODO: Alpha does too much weird stuff currently to safely RT-accelerate
            // see View:getFinalAlpha() and friends, which need to be fixed to
            // work with RT animators
            return false;
        }
        // Here goes nothing...
        return true;
    }

    private boolean hasAlphaAnimation(ViewPropertyAnimator parent) {
        int size = parent.mPendingAnimations.size();
        for (int i = 0; i < size; i++) {
            NameValuesHolder holder = parent.mPendingAnimations.get(i);
            if (holder.mNameConstant == ViewPropertyAnimator.ALPHA) {
                return true;
            }
        }
        return false;
    }

    private void cancelAnimators(ArrayList<NameValuesHolder> mPendingAnimations) {
        int size = mPendingAnimations.size();
        for (int i = 0; i < size; i++) {
+4 −0
Original line number Diff line number Diff line
@@ -160,6 +160,10 @@ void RenderPropertyAnimator::onAttached(RenderNode* target) {
    (target->mutateStagingProperties().*mPropertyAccess->setter)(finalValue());
}

uint32_t RenderPropertyAnimator::dirtyMask() {
    return mPropertyAccess->dirtyMask;
}

float RenderPropertyAnimator::getValue(RenderNode* target) const {
    return (target->properties().*mPropertyAccess->getter)();
}
+4 −0
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ public:
    bool isFinished() { return mPlayState == FINISHED; }
    float finalValue() { return mFinalValue; }

    ANDROID_API virtual uint32_t dirtyMask() { return 0; }

protected:
    BaseRenderNodeAnimator(float finalValue);
    virtual ~BaseRenderNodeAnimator();
@@ -112,6 +114,8 @@ public:

    ANDROID_API virtual void onAttached(RenderNode* target);

    ANDROID_API virtual uint32_t dirtyMask();

protected:
    virtual float getValue(RenderNode* target) const;
    virtual void setValue(RenderNode* target, float value);
+2 −0
Original line number Diff line number Diff line
@@ -189,6 +189,8 @@ public:
    // UI thread only!
    ANDROID_API void removeAnimator(const sp<BaseRenderNodeAnimator>& animator) {
        mStagingAnimators.erase(animator);
        // Force a sync of the staging property value
        mDirtyPropertyFields |= animator->dirtyMask();
        mNeedsAnimatorsSync = true;
    }