summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDiego Perez <diegoperez@google.com>2015-06-12 15:10:14 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-06-12 15:10:14 +0000
commitc051c556669f88e284f2922f8d28fad2138598ae (patch)
treeac71f231ec0bf71c1dc19544e5fc0c62e2e3a7f5 /tools
parent327b481f1f2499eaa5ab938e63a2c12c21fe7482 (diff)
parente10e8005903572158cbb9c7f869508a247ff51ad (diff)
downloadframeworks_base-c051c556669f88e284f2922f8d28fad2138598ae.zip
frameworks_base-c051c556669f88e284f2922f8d28fad2138598ae.tar.gz
frameworks_base-c051c556669f88e284f2922f8d28fad2138598ae.tar.bz2
am e10e8005: am 68155986: am f5a99437: Merge "Fix crash when shadowSize is 0" into lmp-mr1-dev
* commit 'e10e8005903572158cbb9c7f869508a247ff51ad': Fix crash when shadowSize is 0
Diffstat (limited to 'tools')
-rw-r--r--tools/layoutlib/bridge/src/android/view/ShadowPainter.java11
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