OSDN Git Service

Avoid ripple buffer creation for empty bounds
authorAlan Viverette <alanv@google.com>
Wed, 21 Jan 2015 20:30:49 +0000 (12:30 -0800)
committerThe Android Automerger <android-build@google.com>
Wed, 21 Jan 2015 23:03:55 +0000 (15:03 -0800)
Bug: 19068439
Change-Id: I031d4303bbf101a25612dce6f02d81ce4cf58e2b

graphics/java/android/graphics/drawable/RippleDrawable.java

index 9809606..1263447 100644 (file)
@@ -661,7 +661,8 @@ public class RippleDrawable extends LayerDrawable {
 
         mHasValidMask = true;
 
-        if (maskType == MASK_NONE) {
+        final Rect bounds = getBounds();
+        if (maskType == MASK_NONE || bounds.isEmpty()) {
             if (mMaskBuffer != null) {
                 mMaskBuffer.recycle();
                 mMaskBuffer = null;
@@ -674,7 +675,6 @@ public class RippleDrawable extends LayerDrawable {
         }
 
         // Ensure we have a correctly-sized buffer.
-        final Rect bounds = getBounds();
         if (mMaskBuffer == null
                 || mMaskBuffer.getWidth() != bounds.width()
                 || mMaskBuffer.getHeight() != bounds.height()) {