diff options
| author | 2013-03-01 01:16:43 +0000 | |
|---|---|---|
| committer | 2013-03-01 01:16:44 +0000 | |
| commit | cccd6c67db8c610bcaa469e0e1b808eb98807453 (patch) | |
| tree | 8f2e9d5c8458a2d745db0495e97c0730edfce8de | |
| parent | 7f61d0146e48275bf372e6b1ea82d2f48163c73d (diff) | |
| parent | f0e06784609bd3a62cbf86499b4348f4521b6de6 (diff) | |
Merge "Avoid trying to draw invisible ShapeDrawables" into jb-mr2-dev
| -rw-r--r-- | graphics/java/android/graphics/drawable/ShapeDrawable.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java index 2ec12939feed..1dbcddbf63ae 100644 --- a/graphics/java/android/graphics/drawable/ShapeDrawable.java +++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java @@ -217,16 +217,19 @@ public class ShapeDrawable extends Drawable { int prevAlpha = paint.getAlpha(); paint.setAlpha(modulateAlpha(prevAlpha, mShapeState.mAlpha)); - if (mShapeState.mShape != null) { - // need the save both for the translate, and for the (unknown) Shape - int count = canvas.save(); - canvas.translate(r.left, r.top); - onDraw(mShapeState.mShape, canvas, paint); - canvas.restoreToCount(count); - } else { - canvas.drawRect(r, paint); + // only draw shape if it may affect output + if (paint.getAlpha() != 0 || paint.getXfermode() != null || paint.hasShadow) { + if (mShapeState.mShape != null) { + // need the save both for the translate, and for the (unknown) Shape + int count = canvas.save(); + canvas.translate(r.left, r.top); + onDraw(mShapeState.mShape, canvas, paint); + canvas.restoreToCount(count); + } else { + canvas.drawRect(r, paint); + } } - + // restore paint.setAlpha(prevAlpha); } |