diff options
author | Diego Perez <diegoperez@google.com> | 2015-02-27 15:31:36 +0000 |
---|---|---|
committer | Diego Perez <diegoperez@google.com> | 2015-05-08 02:01:53 +0100 |
commit | 635d8f4fe771a0bb2771b23991f7ca758861b884 (patch) | |
tree | 8926767fd54693dd29d9f6191736d71ed600efb1 | |
parent | 4b12583653561f69a5780126485380cac187c478 (diff) | |
download | frameworks_base-635d8f4fe771a0bb2771b23991f7ca758861b884.zip frameworks_base-635d8f4fe771a0bb2771b23991f7ca758861b884.tar.gz frameworks_base-635d8f4fe771a0bb2771b23991f7ca758861b884.tar.bz2 |
Fix crash when shadowSize is 0
Change-Id: I9f131afc95a2571fbc8a737df37f43653cfbb90d
(cherry picked from commit e81096458f689ab3c0c4dbab2452722c3e3623c4)
-rw-r--r-- | tools/layoutlib/bridge/src/android/view/ShadowPainter.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/layoutlib/bridge/src/android/view/ShadowPainter.java b/tools/layoutlib/bridge/src/android/view/ShadowPainter.java index 38846bd..2f93bc8 100644 --- a/tools/layoutlib/bridge/src/android/view/ShadowPainter.java +++ b/tools/layoutlib/bridge/src/android/view/ShadowPainter.java @@ -34,12 +34,15 @@ public class ShadowPainter { * new image. This method attempts to mimic the same visual characteristics as the rectangular * shadow painting methods in this class, {@link #createRectangularDropShadow(java.awt.image.BufferedImage)} * and {@link #createSmallRectangularDropShadow(java.awt.image.BufferedImage)}. + * <p/> + * If shadowSize is less or equals to 1, no shadow will be painted and the source image will be + * returned instead. * * @param source the source image * @param shadowSize the size of the shadow, normally {@link #SHADOW_SIZE or {@link * #SMALL_SHADOW_SIZE}} * - * @return a new image with the shadow painted in + * @return an image with the shadow painted in or the source image if shadowSize <= 1 */ @NonNull public static BufferedImage createDropShadow(BufferedImage source, int shadowSize) { @@ -60,11 +63,15 @@ public class ShadowPainter { * @param shadowOpacity the opacity of the shadow, with 0=transparent and 1=opaque * @param shadowRgb the RGB int to use for the shadow color * - * @return a new image with the source image on top of its shadow + * @return a new image with the source image on top of its shadow when shadowSize > 0 or the + * source image otherwise */ @SuppressWarnings({"SuspiciousNameCombination", "UnnecessaryLocalVariable"}) // Imported code public static BufferedImage createDropShadow(BufferedImage source, int shadowSize, float shadowOpacity, int shadowRgb) { + if (shadowSize <= 0) { + return source; + } // This code is based on // http://www.jroller.com/gfx/entry/non_rectangular_shadow |