summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Teng-Hui Zhu <ztenghui@google.com> 2016-06-30 23:25:56 +0000
committer android-build-merger <android-build-merger@google.com> 2016-06-30 23:25:56 +0000
commit526dba474a88791ed5efe7bb4884a69d6cbb778e (patch)
treeb2a1a09a169fd9450723230f5b3c4d3a47761b88
parent1b7dbd9253b2465666ab40bfc0680e68124d4bc1 (diff)
parent486c76b5efa8824c1a9460bad13000bf7d1697a7 (diff)
Merge \"Mutate the drawable if a valid state change happen\" into nyc-dev
am: 486c76b5ef Change-Id: I9f09c87cd4f738066c55d28fa7849fafdc33b7f9
-rw-r--r--graphics/java/android/graphics/drawable/VectorDrawable.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java
index 7b8dc52bc3b4..c855c4c6d17b 100644
--- a/graphics/java/android/graphics/drawable/VectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/VectorDrawable.java
@@ -240,9 +240,7 @@ public class VectorDrawable extends Drawable {
* constructors to set the state and initialize local properties.
*/
private VectorDrawable(@NonNull VectorDrawableState state, @Nullable Resources res) {
- // Constant state sharing is disabled until we fix onStateChanged()
- // affecting the shared bitmap.
- mVectorState = new VectorDrawableState(state);
+ mVectorState = state;
updateLocalState(res);
}
@@ -388,6 +386,11 @@ public class VectorDrawable extends Drawable {
protected boolean onStateChange(int[] stateSet) {
boolean changed = false;
+ // When the VD is stateful, we need to mutate the drawable such that we don't share the
+ // cache bitmap with others. Such that the state change only affect this new cached bitmap.
+ if (isStateful()) {
+ mutate();
+ }
final VectorDrawableState state = mVectorState;
if (state.onStateChange(stateSet)) {
changed = true;