diff options
author | John Reck <jreck@google.com> | 2014-05-15 20:10:52 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-15 20:10:52 +0000 |
commit | a3d5d3ca1140304e26c41cc29b029dc9c5330b1b (patch) | |
tree | b3946549e2dc9bcd4b3c360e1f74a99a60531e31 /core/jni | |
parent | 4c1227e448c938eb2deb431336abb9e67d6e1099 (diff) | |
parent | ff941dcd815021bb20d6504eb486acb1e50592c3 (diff) | |
download | frameworks_base-a3d5d3ca1140304e26c41cc29b029dc9c5330b1b.zip frameworks_base-a3d5d3ca1140304e26c41cc29b029dc9c5330b1b.tar.gz frameworks_base-a3d5d3ca1140304e26c41cc29b029dc9c5330b1b.tar.bz2 |
Merge "Animator start value..."
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android_view_RenderNode.cpp | 32 | ||||
-rw-r--r-- | core/jni/android_view_RenderNodeAnimator.cpp | 38 | ||||
-rw-r--r-- | core/jni/android_view_ThreadedRenderer.cpp | 6 |
3 files changed, 49 insertions, 27 deletions
diff --git a/core/jni/android_view_RenderNode.cpp b/core/jni/android_view_RenderNode.cpp index e45a901..b0defdb 100644 --- a/core/jni/android_view_RenderNode.cpp +++ b/core/jni/android_view_RenderNode.cpp @@ -80,6 +80,7 @@ static void android_view_RenderNode_setCaching(JNIEnv* env, jobject clazz, jlong renderNodePtr, jboolean caching) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setCaching(caching); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setStaticMatrix(JNIEnv* env, @@ -87,6 +88,7 @@ static void android_view_RenderNode_setStaticMatrix(JNIEnv* env, RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixPtr); renderNode->mutateStagingProperties().setStaticMatrix(matrix); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setAnimationMatrix(JNIEnv* env, @@ -94,24 +96,28 @@ static void android_view_RenderNode_setAnimationMatrix(JNIEnv* env, RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixPtr); renderNode->mutateStagingProperties().setAnimationMatrix(matrix); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setClipToBounds(JNIEnv* env, jobject clazz, jlong renderNodePtr, jboolean clipToBounds) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setClipToBounds(clipToBounds); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setProjectBackwards(JNIEnv* env, jobject clazz, jlong renderNodePtr, jboolean shouldProject) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setProjectBackwards(shouldProject); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setProjectionReceiver(JNIEnv* env, jobject clazz, jlong renderNodePtr, jboolean shouldRecieve) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setProjectionReceiver(shouldRecieve); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setOutlineRoundRect(JNIEnv* env, @@ -119,6 +125,7 @@ static void android_view_RenderNode_setOutlineRoundRect(JNIEnv* env, jint right, jint bottom, jfloat radius) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().mutableOutline().setRoundRect(left, top, right, bottom, radius); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setOutlineConvexPath(JNIEnv* env, @@ -126,18 +133,21 @@ static void android_view_RenderNode_setOutlineConvexPath(JNIEnv* env, RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); SkPath* outlinePath = reinterpret_cast<SkPath*>(outlinePathPtr); renderNode->mutateStagingProperties().mutableOutline().setConvexPath(outlinePath); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setOutlineEmpty(JNIEnv* env, jobject clazz, jlong renderNodePtr) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().mutableOutline().setEmpty(); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setClipToOutline(JNIEnv* env, jobject clazz, jlong renderNodePtr, jboolean clipToOutline) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().mutableOutline().setShouldClip(clipToOutline); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setRevealClip(JNIEnv* env, @@ -146,114 +156,133 @@ static void android_view_RenderNode_setRevealClip(JNIEnv* env, RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().mutableRevealClip().set( shouldClip, inverseClip, x, y, radius); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setAlpha(JNIEnv* env, jobject clazz, jlong renderNodePtr, float alpha) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setAlpha(alpha); + renderNode->setPropertyFieldsDirty(RenderNode::ALPHA); } static void android_view_RenderNode_setHasOverlappingRendering(JNIEnv* env, jobject clazz, jlong renderNodePtr, bool hasOverlappingRendering) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setHasOverlappingRendering(hasOverlappingRendering); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setElevation(JNIEnv* env, jobject clazz, jlong renderNodePtr, float elevation) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setElevation(elevation); + renderNode->setPropertyFieldsDirty(RenderNode::Z); } static void android_view_RenderNode_setTranslationX(JNIEnv* env, jobject clazz, jlong renderNodePtr, float tx) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setTranslationX(tx); + renderNode->setPropertyFieldsDirty(RenderNode::TRANSLATION_X | RenderNode::X); } static void android_view_RenderNode_setTranslationY(JNIEnv* env, jobject clazz, jlong renderNodePtr, float ty) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setTranslationY(ty); + renderNode->setPropertyFieldsDirty(RenderNode::TRANSLATION_Y | RenderNode::Y); } static void android_view_RenderNode_setTranslationZ(JNIEnv* env, jobject clazz, jlong renderNodePtr, float tz) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setTranslationZ(tz); + renderNode->setPropertyFieldsDirty(RenderNode::TRANSLATION_Z | RenderNode::Z); } static void android_view_RenderNode_setRotation(JNIEnv* env, jobject clazz, jlong renderNodePtr, float rotation) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setRotation(rotation); + renderNode->setPropertyFieldsDirty(RenderNode::ROTATION); } static void android_view_RenderNode_setRotationX(JNIEnv* env, jobject clazz, jlong renderNodePtr, float rx) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setRotationX(rx); + renderNode->setPropertyFieldsDirty(RenderNode::ROTATION_X); } static void android_view_RenderNode_setRotationY(JNIEnv* env, jobject clazz, jlong renderNodePtr, float ry) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setRotationY(ry); + renderNode->setPropertyFieldsDirty(RenderNode::ROTATION_Y); } static void android_view_RenderNode_setScaleX(JNIEnv* env, jobject clazz, jlong renderNodePtr, float sx) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setScaleX(sx); + renderNode->setPropertyFieldsDirty(RenderNode::SCALE_X); } static void android_view_RenderNode_setScaleY(JNIEnv* env, jobject clazz, jlong renderNodePtr, float sy) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setScaleY(sy); + renderNode->setPropertyFieldsDirty(RenderNode::SCALE_Y); } static void android_view_RenderNode_setPivotX(JNIEnv* env, jobject clazz, jlong renderNodePtr, float px) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setPivotX(px); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setPivotY(JNIEnv* env, jobject clazz, jlong renderNodePtr, float py) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setPivotY(py); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setCameraDistance(JNIEnv* env, jobject clazz, jlong renderNodePtr, float distance) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setCameraDistance(distance); + renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); } static void android_view_RenderNode_setLeft(JNIEnv* env, jobject clazz, jlong renderNodePtr, int left) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setLeft(left); + renderNode->setPropertyFieldsDirty(RenderNode::X); } static void android_view_RenderNode_setTop(JNIEnv* env, jobject clazz, jlong renderNodePtr, int top) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setTop(top); + renderNode->setPropertyFieldsDirty(RenderNode::Y); } static void android_view_RenderNode_setRight(JNIEnv* env, jobject clazz, jlong renderNodePtr, int right) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setRight(right); + renderNode->setPropertyFieldsDirty(RenderNode::X); } static void android_view_RenderNode_setBottom(JNIEnv* env, jobject clazz, jlong renderNodePtr, int bottom) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setBottom(bottom); + renderNode->setPropertyFieldsDirty(RenderNode::Y); } static void android_view_RenderNode_setLeftTopRightBottom(JNIEnv* env, @@ -261,18 +290,21 @@ static void android_view_RenderNode_setLeftTopRightBottom(JNIEnv* env, int right, int bottom) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().setLeftTopRightBottom(left, top, right, bottom); + renderNode->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y); } static void android_view_RenderNode_offsetLeftAndRight(JNIEnv* env, jobject clazz, jlong renderNodePtr, float offset) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().offsetLeftRight(offset); + renderNode->setPropertyFieldsDirty(RenderNode::X); } static void android_view_RenderNode_offsetTopAndBottom(JNIEnv* env, jobject clazz, jlong renderNodePtr, float offset) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); renderNode->mutateStagingProperties().offsetTopBottom(offset); + renderNode->setPropertyFieldsDirty(RenderNode::Y); } // ---------------------------------------------------------------------------- diff --git a/core/jni/android_view_RenderNodeAnimator.cpp b/core/jni/android_view_RenderNodeAnimator.cpp index 5733f60..ea2f96e 100644 --- a/core/jni/android_view_RenderNodeAnimator.cpp +++ b/core/jni/android_view_RenderNodeAnimator.cpp @@ -62,7 +62,7 @@ public: mWeakThis = NULL; } - virtual void onAnimationFinished(BaseAnimator*) { + virtual void onAnimationFinished(BaseRenderNodeAnimator*) { JNIEnv* env = getEnv(mJvm); env->CallStaticVoidMethod( gRenderNodeAnimatorClassInfo.clazz, @@ -81,13 +81,6 @@ static inline RenderPropertyAnimator::RenderProperty toRenderProperty(jint prope return static_cast<RenderPropertyAnimator::RenderProperty>(property); } -static inline RenderPropertyAnimator::DeltaValueType toDeltaType(jint deltaType) { - LOG_ALWAYS_FATAL_IF(deltaType != RenderPropertyAnimator::DELTA - && deltaType != RenderPropertyAnimator::ABSOLUTE, - "Invalid delta type %d", deltaType); - return static_cast<RenderPropertyAnimator::DeltaValueType>(deltaType); -} - static inline CanvasPropertyPaintAnimator::PaintField toPaintField(jint field) { LOG_ALWAYS_FATAL_IF(field < 0 || field > CanvasPropertyPaintAnimator::ALPHA, @@ -96,49 +89,46 @@ static inline CanvasPropertyPaintAnimator::PaintField toPaintField(jint field) { } static jlong createAnimator(JNIEnv* env, jobject clazz, jobject weakThis, - jint propertyRaw, jint deltaTypeRaw, jfloat deltaValue) { + jint propertyRaw, jfloat finalValue) { RenderPropertyAnimator::RenderProperty property = toRenderProperty(propertyRaw); - RenderPropertyAnimator::DeltaValueType deltaType = toDeltaType(deltaTypeRaw); - BaseAnimator* animator = new RenderPropertyAnimator(property, deltaType, deltaValue); + BaseRenderNodeAnimator* animator = new RenderPropertyAnimator(property, finalValue); animator->setListener(new AnimationListenerBridge(env, weakThis)); return reinterpret_cast<jlong>( animator ); } static jlong createCanvasPropertyFloatAnimator(JNIEnv* env, jobject clazz, - jobject weakThis, jlong canvasPropertyPtr, jint deltaTypeRaw, jfloat deltaValue) { - RenderPropertyAnimator::DeltaValueType deltaType = toDeltaType(deltaTypeRaw); + jobject weakThis, jlong canvasPropertyPtr, jfloat finalValue) { CanvasPropertyPrimitive* canvasProperty = reinterpret_cast<CanvasPropertyPrimitive*>(canvasPropertyPtr); - BaseAnimator* animator = new CanvasPropertyPrimitiveAnimator(canvasProperty, deltaType, deltaValue); + BaseRenderNodeAnimator* animator = new CanvasPropertyPrimitiveAnimator(canvasProperty, finalValue); animator->setListener(new AnimationListenerBridge(env, weakThis)); return reinterpret_cast<jlong>( animator ); } static jlong createCanvasPropertyPaintAnimator(JNIEnv* env, jobject clazz, jobject weakThis, jlong canvasPropertyPtr, jint paintFieldRaw, - jint deltaTypeRaw, jfloat deltaValue) { - RenderPropertyAnimator::DeltaValueType deltaType = toDeltaType(deltaTypeRaw); + jfloat finalValue) { CanvasPropertyPaint* canvasProperty = reinterpret_cast<CanvasPropertyPaint*>(canvasPropertyPtr); CanvasPropertyPaintAnimator::PaintField paintField = toPaintField(paintFieldRaw); - BaseAnimator* animator = new CanvasPropertyPaintAnimator( - canvasProperty, paintField, deltaType, deltaValue); + BaseRenderNodeAnimator* animator = new CanvasPropertyPaintAnimator( + canvasProperty, paintField, finalValue); animator->setListener(new AnimationListenerBridge(env, weakThis)); return reinterpret_cast<jlong>( animator ); } static void setDuration(JNIEnv* env, jobject clazz, jlong animatorPtr, jint duration) { LOG_ALWAYS_FATAL_IF(duration < 0, "Duration cannot be negative"); - BaseAnimator* animator = reinterpret_cast<BaseAnimator*>(animatorPtr); + BaseRenderNodeAnimator* animator = reinterpret_cast<BaseRenderNodeAnimator*>(animatorPtr); animator->setDuration(duration); } static jint getDuration(JNIEnv* env, jobject clazz, jlong animatorPtr) { - BaseAnimator* animator = reinterpret_cast<BaseAnimator*>(animatorPtr); + BaseRenderNodeAnimator* animator = reinterpret_cast<BaseRenderNodeAnimator*>(animatorPtr); return static_cast<jint>(animator->duration()); } static void setInterpolator(JNIEnv* env, jobject clazz, jlong animatorPtr, jlong interpolatorPtr) { - BaseAnimator* animator = reinterpret_cast<BaseAnimator*>(animatorPtr); + BaseRenderNodeAnimator* animator = reinterpret_cast<BaseRenderNodeAnimator*>(animatorPtr); Interpolator* interpolator = reinterpret_cast<Interpolator*>(interpolatorPtr); animator->setInterpolator(interpolator); } @@ -153,9 +143,9 @@ const char* const kClassPathName = "android/view/RenderNodeAnimator"; static JNINativeMethod gMethods[] = { #ifdef USE_OPENGL_RENDERER - { "nCreateAnimator", "(Ljava/lang/ref/WeakReference;IIF)J", (void*) createAnimator }, - { "nCreateCanvasPropertyFloatAnimator", "(Ljava/lang/ref/WeakReference;JIF)J", (void*) createCanvasPropertyFloatAnimator }, - { "nCreateCanvasPropertyPaintAnimator", "(Ljava/lang/ref/WeakReference;JIIF)J", (void*) createCanvasPropertyPaintAnimator }, + { "nCreateAnimator", "(Ljava/lang/ref/WeakReference;IF)J", (void*) createAnimator }, + { "nCreateCanvasPropertyFloatAnimator", "(Ljava/lang/ref/WeakReference;JF)J", (void*) createCanvasPropertyFloatAnimator }, + { "nCreateCanvasPropertyPaintAnimator", "(Ljava/lang/ref/WeakReference;JIF)J", (void*) createCanvasPropertyPaintAnimator }, { "nSetDuration", "(JI)V", (void*) setDuration }, { "nGetDuration", "(J)I", (void*) getDuration }, { "nSetInterpolator", "(JJ)V", (void*) setInterpolator }, diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp index d130a6d..2c10212 100644 --- a/core/jni/android_view_ThreadedRenderer.cpp +++ b/core/jni/android_view_ThreadedRenderer.cpp @@ -92,9 +92,9 @@ private: class OnFinishedEvent { public: - OnFinishedEvent(BaseAnimator* animator, AnimationListener* listener) + OnFinishedEvent(BaseRenderNodeAnimator* animator, AnimationListener* listener) : animator(animator), listener(listener) {} - sp<BaseAnimator> animator; + sp<BaseRenderNodeAnimator> animator; sp<AnimationListener> listener; }; @@ -127,7 +127,7 @@ public: virtual ~RootRenderNode() {} - virtual void callOnFinished(BaseAnimator* animator, AnimationListener* listener) { + virtual void callOnFinished(BaseRenderNodeAnimator* animator, AnimationListener* listener) { OnFinishedEvent event(animator, listener); mOnFinishedEvents.push_back(event); } |