diff options
| author | Deepanshu Gupta <deepanshu@google.com> | 2015-05-07 00:07:54 +0000 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2015-05-07 00:07:54 +0000 |
| commit | 047a28ec506bb40081eef6eaf8434884157709ce (patch) | |
| tree | 2bf8415b3b379270e591e0e20ac05d0b645c25a0 /tools/layoutlib/bridge/src | |
| parent | d8039f048db26847a3da5367a0b69e2bd3f340e0 (diff) | |
| parent | 96437fb4b05be2602bb0fa215988be646aec28fc (diff) | |
| download | frameworks_base-047a28ec506bb40081eef6eaf8434884157709ce.zip frameworks_base-047a28ec506bb40081eef6eaf8434884157709ce.tar.gz frameworks_base-047a28ec506bb40081eef6eaf8434884157709ce.tar.bz2 | |
am 96437fb4: am 9aa600e7: Merge "LayoutLib: fix crash when shadow size <=0." into lmp-mr1-dev
* commit '96437fb4b05be2602bb0fa215988be646aec28fc':
LayoutLib: fix crash when shadow size <=0.
Diffstat (limited to 'tools/layoutlib/bridge/src')
| -rw-r--r-- | tools/layoutlib/bridge/src/android/view/RectShadowPainter.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/layoutlib/bridge/src/android/view/RectShadowPainter.java b/tools/layoutlib/bridge/src/android/view/RectShadowPainter.java index ec3a8d6..30512aa 100644 --- a/tools/layoutlib/bridge/src/android/view/RectShadowPainter.java +++ b/tools/layoutlib/bridge/src/android/view/RectShadowPainter.java @@ -19,6 +19,7 @@ package android.view; import com.android.layoutlib.bridge.impl.ResourceHelper; import android.graphics.Canvas; +import android.graphics.Canvas_Delegate; import android.graphics.LinearGradient; import android.graphics.Outline; import android.graphics.Paint; @@ -125,6 +126,9 @@ public class RectShadowPainter { private static void sideShadow(Canvas canvas, Paint edgePaint, RectF edgeShadowRect, float dx, float dy, int rotations) { + if (isRectEmpty(edgeShadowRect)) { + return; + } int saved = canvas.save(); canvas.translate(dx, dy); canvas.rotate(rotations * PERPENDICULAR_ANGLE); @@ -153,4 +157,15 @@ public class RectShadowPainter { canvas.drawPath(path, paint); canvas.restoreToCount(saved); } + + /** + * Differs from {@link RectF#isEmpty()} as this first converts the rect to int and then checks. + * <p/> + * This is required because {@link Canvas_Delegate#native_drawRect(long, float, float, float, + * float, long)} casts the co-ordinates to int and we want to ensure that it doesn't end up + * drawing empty rectangles, which results in IllegalArgumentException. + */ + private static boolean isRectEmpty(RectF rect) { + return (int) rect.left >= (int) rect.right || (int) rect.top >= (int) rect.bottom; + } } |
