Commit Graph

291 Commits

Author SHA1 Message Date
Justin Klaassen
543a7ed7af Fix NPE in ValueAnimator
- Reset mAnimationEndRequested to false in ValueAnimator#start(boolean)
  so that previously canceled animated (with a start delay) can be
  canceled again.
- In ObjectAnimator#animateValue(float) check if target == null
  regardless of mTarget == null since it's possible the target was
  explicitly set to null prior to the animator being cancelled.

Bug: 30190459
Change-Id: I6da55737df30a28f48355fc7a41ab91d05979deb
2016-07-25 12:40:09 -07:00
Doris Liu
c470466d7c Fix NPE for checking for whether animators should play together
BUG: 29586505
Change-Id: Ic2a67d51d2ac8d5bfb11ed7773c7c7e413cc28c7
2016-06-24 00:01:39 +00:00
Doris Liu
a28f0003eb Merge \"Fix setCurrentPlayTime for started but not yet pulsed animations\" into nyc-dev
am: 42d39300cf

Change-Id: I7c1f2adb31ece266b082ffb9ea85b17c083b518c
2016-06-13 20:31:32 +00:00
Doris Liu
caa2ebf814 Fix setCurrentPlayTime for started but not yet pulsed animations
Also fix the behavior for calling reverse() immediately after
start(). Such case now triggers end() right away, which is
consistent with what the animation would do in M.

Bug: 29271714
Change-Id: I045e36e039179a3c462f22bc6a3a765437de4074
2016-06-13 17:29:03 +00:00
Doris Liu
c9493879d7 Support Keyframe definition for AVD on RT
BUG: 27441613
Change-Id: Iece386f65f3704d1b7caa2b3690a8d3048ccf6e2
2016-06-09 14:40:32 -07:00
Doris Liu
a57e95a6a3 Throw Exception for wrong valueType with API guard
Previously, wrong valueType error is swallowed in jni. As a result,
some animations are quietly skipped without letting developers know.
This CL maintains that behavior for pre-N, and throws Exception
to notify developers of the error for N and above.

Bug: 29009391
Change-Id: I3e8f003cdb97d214da72af3f93a84f64797b1c2c
(cherry picked from commit 94db09917a)
2016-06-09 14:39:18 -07:00
Doris Liu
792926a58c Improve the property modification effiency of VectorDrawable animators
Previously, the VectorDrawable animators modify the VD properties by
doing reflection based on the property name. This CL avoids the overhead
of calling reflection by wrapping the setters of VD objects in
Float/IntProperty.

Bug: 28124049
Change-Id: I562c8d749fdfe508564c82a700a92e835cdd9ff4
(cherry picked from commit 9f3b31b953)
2016-06-08 20:43:34 +00:00
Doris Liu
3c85983996 Add more doc for Object animators defined with a single value
Bug: 28104516
Change-Id: I181b2817ceda5dfaf87e12c81b21e7d0d2f002fc
2016-05-27 15:08:46 -07:00
Doris Liu
61045c518b Clamp start delay to non-negative range
Bug: 28936388
Change-Id: I2a225e07cad53c6ffc3637219f8c741aca5c008c
2016-05-25 00:10:25 +00:00
Chet Haase
fa21bdfd5a Document behavior of object references in Animator classes
Animators that are created with Object values may have undefined
behavior when those objects are changed outside of the animator itself.
For example, an animator created with a start Rect and end Rect
will animate the bounds between those two objects. But if the caller
changes either the start or end rect before or during the animation,
that will affect the values used on every frame of the animation.

Issue #28304520 Strange interpolation of property values holder values

Change-Id: Id6ac19c8369ae34450e6b53d68f5e492b27c577e
2016-04-26 13:03:31 -07:00
Doris Liu
dd67b0d525 Merge "Fix pause/resume for AnimatorSet" into nyc-dev 2016-04-19 22:14:37 +00:00
Doris Liu
2987dffb72 Fix pause/resume for AnimatorSet
Bug: 28251945
Change-Id: Ie98c779791bf181e2e8fbf38bbd453228ce43310
2016-04-18 18:48:43 -07:00
Doris Liu
c5801fb933 Merge "Add api check to guard AnimatorSet behavior change" into nyc-dev 2016-04-13 23:15:33 +00:00
Doris Liu
56b0b57089 Skip to end for 0-duration animation
Repeating a 0-duration animation makes no sense. In the case of
battery saver mode, all animators are set to 0 duration, and
repeating the 0 duration animations not only waste battery power
but also potentially produce flickers on screen. In this CL,
0-duration animations are skipped to the end, regardless their
repeat count.

Bug: 25451472
Change-Id: I20f9dc2f0ff9c027782a8363ff4cf4a4d390736c
2016-04-13 14:13:49 -07:00
Doris Liu
58606db8be Add api check to guard AnimatorSet behavior change
For pre-N, we have inconsistent behavior between ValueAnimator and
AnimatorSet in the case of calling end() when already ended:
ValueAnimator would start() and immediately end, whereas AnimatorSet
would be no-op. We made a decision to be consistent within Animation
Framework from N forward, which means that AnimatorSet will have the
new behavior of starting and immediately ending just like
ValueAnimator. This new behavior will be guarded by an API check.

Bug: 25601129
Change-Id: I2d952a93d8521c547ec8cde173c80d1d8ead0639
2016-04-13 13:37:45 -07:00
Jorim Jaggi
c69bd2246f Implement transition for docking task in recents #6
- Use a future to provide the app thumbnail so the app can restart
in parallel when recents draws the bitmap (extremely expensive).
- Don't call startRecents from AM when recents is already running - this
messes up the transition information.
- Make sure to put the task into resizing mode if it needs to be restored
from the disk.
- Some minor fixes for the transition animation spec.
- Add NO_MOVE_ANIMATION to recents flags to prevent wallpaper
flickering.

Bug: 27607141
Change-Id: I7d0c75b88775ab467927b8cf94303ddb60222e7f
2016-03-25 15:13:36 -07:00
Jorim Jaggi
787e9dd6c8 Implement transition for docking task in recents #5
- Move task along a curved path.

Bug: 27607141
Change-Id: I945071de55efed0d327b68045e48fea6989adf63
2016-03-25 14:53:19 -07:00
George Mount
907c177b04 Start seeked animators without waiting for start delay.
Bug 24872727

Change-Id: I954efd7113565f9b8f9a569f57960b8d91620758
2016-03-24 16:29:03 -07:00
Chet Haase
e60a693d84 Clarify docs around weak references to animator targets
Issue #26069047 Weak reference to the target in animators
can cause interrupted animations

Change-Id: I719f619006e93a94af907c4de7840c691a5aed37
2016-03-22 16:20:46 -07:00
George Mount
7f1bdd9f91 Merge "Add @SafeVarargs for methods using typevar varargs." into nyc-dev 2016-03-18 22:11:39 +00:00
George Mount
d98f4ba86c Add @SafeVarargs for methods using typevar varargs.
Bug 27142336
Using a type variable in a varargs leads to a javac warning
because type variables are treated as Object after compilation.
Because these uses do not require a specific typed array, we
can use @SafeVarargs to suppress the warning.

Change-Id: I860bcc79667a9c85c381c7994fd1d798209d7c66
2016-03-14 14:32:14 -07:00
Alan Viverette
781fbf28c7 Merge "Ensure all Java-side usages of config flags are using Java flags" into nyc-dev 2016-03-14 15:01:51 +00:00
Doris Liu
5a705d0bbb Merge "Set end value immediately when start a 0-duration animation" into nyc-dev 2016-03-11 20:25:21 +00:00
Alan Viverette
ac85f90466 Ensure all Java-side usages of config flags are using Java flags
Previously we were using native config flags in some places that expected
Java flags, and vice-versa. All usages of config flags are now annotated
to ensure we're using the right type.

Cleans up annotations on most methods that were touched.

Bug: 21161798
Change-Id: Ifd87dfb12199fc8258915d8a510e03ddb681ca89
2016-03-11 15:15:51 -05:00
Adam Lesinski
c4dd2e7d52 Merge "Move the guts of Resources to ResourcesImpl" into nyc-dev 2016-03-04 00:16:47 +00:00
George Mount
a06b3f19d4 Remove animation listener while paused.
Bug 27418573

While an animator was paused, it continued to receive
Choreographer callbacks. This has been changed now so
that after the first callback, it is removed.

Change-Id: If73483404b38f1f354a63fc98d07696f442987e6
2016-03-03 08:12:58 -08:00
Adam Lesinski
fb302ccd8e Move the guts of Resources to ResourcesImpl
In order to satisfy the requirement that clients can
cache a Resources object when a configuration change happens,
we move the caches and all other method bodies to ResourcesImpl.
These can then be swapped out for the correct version when needed,
while allowing clients to keep holding the existing Resources references.

This is part 1 of 2 CLs. The next one will do the actual switching of implementations
based on configuration changes for multiwindow.

Bug:26854894
Change-Id: I41156194a3541e59053b4048c3a15981c7d8a506
2016-03-01 16:58:19 -08:00
Doris Liu
b199da785b Set end value immediately when start a 0-duration animation
This is to be consistent with pre-N behavior.

Bug: 27066791
Change-Id: I24cb7bc7645339a6e52be35a8cb15902b7d7bd5e
2016-02-25 14:25:15 -08:00
Doris Liu
c4bb185d41 VectorDrawable native rendering - Step 5 of MANY
This is reverting the revert of what reverts the revert of the original
implementation. Fourth revert is a charm!

This reverts commit df7fdb1e0b.

Change-Id: I6fc3a5accfd8b79c3da31bbc101ad9e9b4d6e7dd
2016-02-19 13:51:31 -08:00
Doris Liu
df7fdb1e0b Revert "Revert "Revert "VectorDrawable native rendering - Step 5 of MANY"""
This reverts commit 0d20a275a5.

Change-Id: I97c782f1164a5d39ab74dc098cca71d9e1b30cd8
2016-02-18 18:37:02 +00:00
Doris Liu
0d20a275a5 Revert "Revert "VectorDrawable native rendering - Step 5 of MANY""
This reverts commit e03ef25a3e.

Change-Id: I9c2e1c891667451a3ee668e414bf337ad67279ab
2016-02-12 19:49:29 -08:00
John Reck
e03ef25a3e Revert "VectorDrawable native rendering - Step 5 of MANY"
Bug: 27136799

This reverts commit 18bdf443e3.

Change-Id: I825b061eec2a591f2d18119ba64494624b9ad4f2
2016-02-11 17:02:33 +00:00
Doris Liu
18bdf443e3 VectorDrawable native rendering - Step 5 of MANY
Implemented reset() (public API for AVD)
and reverse() (internal API that needs to be supported)

Change-Id: Ife1650049f271cad1347943151a5800c40c20aa2
2016-02-11 01:08:47 +00:00
Doris Liu
766431aa57 Revert "Revert "VectorDrawable native rendering - Step 4 of MANY""
This reverts commit 5a11e8d0ba.

Change-Id: I7a48b59c4f930dad65ddc8590c25a12636244ea2
2016-02-04 16:29:51 -08:00
Doris Liu
5a11e8d0ba Revert "VectorDrawable native rendering - Step 4 of MANY"
b/26949340 and b/26975469, b/26975079 as well 

This reverts commit f276acd984.

Change-Id: I4b55177daf0d289bc03604c71fd4bf579f65073a
2016-02-04 20:59:00 +00:00
Doris Liu
f276acd984 VectorDrawable native rendering - Step 4 of MANY
This CL runs VectorDrawable animation on RenderThread. The changes in this CL
include:
- Convert all the animators in AnimatorSet for AVD into a set of RenderNodeAnimators.
- Hook up the new animators with RenderThread
- Add drawOp in RecordingCanvas for drawing VD so that during the animation
  on RenderThread, all the property changes on VD can be reflected on the screen.

TODO:
- Implement reverse and reset for AVD.

Change-Id: I2df1d754f2db0ad098d9c15dde4bb2bdfafc2315
2016-02-02 15:04:01 -08:00
George Mount
0f5fd2d870 Merge "Add IntDefs for Animator and Transition classes." 2016-01-14 16:21:27 +00:00
George Mount
7764b920f2 Add IntDefs for Animator and Transition classes.
Bug 23593341

Change-Id: Ifcb30322cb90efb32262c80f5d11c2d39efc5080
2016-01-13 15:21:51 -08:00
Chet Haase
406a02b59d Don't double-set keyframe values when Property exists
There is logic in PVH.setupValue() that sets the value of
the appropriate keyframe from a Property, if that Property object
exists for the animator. But after that is done, it goes ahead and sets
the same keyframe value based on the getter for the target object.
This is not only redundant; it is wrong (in the odd situation in which
a getter would return something different than Property.get()).

The solution is to return early once we've set the value with the
Property object.

Issue #26471646  PropertyValuesHolder uses reflection in setupValue when a Property is being used

Change-Id: I12634a25661400f13f44872ba17625b32e93ca19
2016-01-11 16:27:20 -08:00
Doris Liu
804618d086 VectorDrawable native rendering - Step 2 of MANY
Introduced PathData in Java, which is effectively a thin layer around the
native instance. PathData holds the verbs and points which is being used
in path morphing/interpolation. The verbs and points can be interpreted
into skia path commands, which is now done in native and therefore saves
a handful of JNI calls during path creation.

Removed the old PathDataNode mechanism and changed the PathEvaluator
to use PathData instead.

Also added tests and a microbench. Also ran CTS tests for VectorDrawable
and AnimatedVectorDrawable, and passed all of the existing tests.

Change-Id: Ia166f5172ff031fe18b154327967f911a62caec1
2015-11-18 13:38:23 -08:00
Doris Liu
66d4856653 Fix animator sometimes not being ended when end() is called without start()'ing
Bug: 23713124
Change-Id: I2e00cedb9c74e14d2361579bba89d3d1dbfe4d22
2015-11-09 14:44:35 -08:00
George Mount
f2aeca34ba Change wrong doc about using linear interpolator.
Bug 24986885

Change-Id: I79f2cd0c6439749bf1fc412d28471e865501aa5a
2015-10-16 10:47:57 -07:00
Doris Liu
8b7c99cca2 New public API for calculating the total duration of an animation
Total duration is the total amount of time an animation takes from
start to finish. It include start delay (if any), child animation
sequence, accounting for repeat.

Change-Id: Id5b36a63c02e25586aefd38612aa5867492e1adb
2015-10-12 18:24:40 -07:00
Doris Liu
fbe94ece70 More refactor on ValueAnimator
mPlayingBackwards is confusing when placed next to mReversing.
One means the overall direction of animation playing, the other
indicates the direction of playing in the current iteration.

mCurrentIteration and mPlayingBackward are redundant together,
as the latter can be derived from the former, given the overall
direction of animation playing. Redundant variables pose risk of
getting out of sync and therefore are refactored out in this CL.
Instead, an overall fraction that ranges from 0 to mRepeatCount + 1
was introduced. It can capture both the current iteration and the
fraction in the current iteration. It gives a much better idea of
the overall progress of the animation.

Change-Id: Ic0ea02c86b04cfc01c462687d1ebbd46184cbab7
2015-10-08 18:40:05 -07:00
Chet Haase
4365e5a137 Fix ValueAnimator.getCurrentPlayTime()
Return a valid value for the current play time if the animator has
been seeked to a play time or fraction, but not yet started.

Issue #24717972 animator.getCurrentPlayTime() is all messed up

Change-Id: I15f1329b65410b4b0366a23a3419b5987305a865
2015-10-08 12:47:10 -07:00
Doris Liu
7b67734fe3 Merge "Fix behavior change for animators without a start delay" 2015-10-02 17:16:34 +00:00
Doris Liu
f57bfe2fef Fix behavior change for animators without a start delay
This CL maintains the behavior that animators without any
start delay will get started right away, instead of being delayed
to the first frame as it was in the previous refactor.

Bug: 23825781
Change-Id: I7873bc6c7a761c1b4d48ee5e17af631b359fd676
2015-10-01 18:48:15 -07:00
Doris Liu
2b2e2c8d25 Update doc to reflect requirement of a Looper for changing animation's frame delay
Bug: 24569533
Change-Id: Ie886394a5e3cd7ceebbedbf09e2d9645b464a9c6
2015-10-01 11:11:04 -07:00
Doris Liu
ee684556ce Correct isRunning() behavior for AnimatorSet
isRunning() for an Animator indicates whether an animator has gone
past its start delay and not yet finished. As a subclass of Animator,
AnimatorSet should follow the same principle. The implemention prior
to this CL returns whether any child animation is running, which is
inconsistent with the javadoc for isRunning() and general behavior
for Animator.

Change-Id: Iece814dfcd609ee292dbc00bd55dc64c7bda8e57
2015-08-28 13:21:03 -07:00
Doris Liu
3dbaae1ef4 Prevents recursive call into end() or cancel()
end() and cancel() in ValueAnimator will trigger onAnimationCancel
or onAnimationEnd callback on its listeners. If additional end()
or cancel() request comes from the callback, a loop will be formed.
Therefore, we need to mark when the end is reuqested so we do not
process end() or cancel() request multiple times during one animation
run, and also effectively terminate the loop.

Bug: 23596652
Change-Id: Iefb69eb8969071b43124c09d7cccbe9ff5ba5dcc
2015-08-27 16:13:48 -07:00