Loading graphics/java/android/graphics/drawable/RevealDrawable.java +13 −8 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.graphics.drawable; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffXfermode; Loading Loading @@ -248,6 +249,7 @@ public class RevealDrawable extends LayerDrawable { } // Draw ripple mask into a buffer that merges using SRC_OVER. boolean needsMask = false; int layerSaveCount = -1; int n = activeRipples.size(); for (int i = 0; i < n; i++) { Loading @@ -261,7 +263,7 @@ public class RevealDrawable extends LayerDrawable { layerSaveCount = canvas.saveLayer(0, 0, width, height, null, 0); } ripple.draw(canvas, mRipplePaint); needsMask |= ripple.draw(canvas, mRipplePaint); } } Loading @@ -269,6 +271,7 @@ public class RevealDrawable extends LayerDrawable { // into another layer and composite using SRC_IN, then composite onto // the original canvas. if (layerSaveCount >= 0) { if (needsMask) { if (mMaskingPaint == null) { mMaskingPaint = new Paint(); mMaskingPaint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); Loading @@ -278,6 +281,8 @@ public class RevealDrawable extends LayerDrawable { // we won't need an extra layer. canvas.saveLayer(0, 0, width, height, mMaskingPaint, 0); getDrawable(1).draw(canvas); } canvas.restoreToCount(layerSaveCount); } } Loading graphics/java/android/graphics/drawable/Ripple.java +28 −20 Original line number Diff line number Diff line Loading @@ -160,7 +160,7 @@ class Ripple { } } public void draw(Canvas c, Paint p) { public boolean draw(Canvas c, Paint p) { final Rect bounds = mBounds; final Rect padding = mPadding; final float dX = Math.max(mX, bounds.right - mX); Loading Loading @@ -221,6 +221,7 @@ class Ripple { } } if (maxAlpha > 0) { if (exitState <= 0) { // Exit state isn't showing, so we can simplify to a solid // circle. Loading @@ -228,6 +229,7 @@ class Ripple { p.setAlpha(maxAlpha); p.setStyle(Style.FILL); c.drawCircle(x, y, outerRadius, p); return true; } } else { // Both states are showing, so we need a circular stroke. Loading @@ -236,11 +238,17 @@ class Ripple { if (strokeWidth > 0) { final float strokeRadius = innerRadius + strokeWidth / 2f; final int alpha = (int) (MathUtils.lerp(maxAlpha, 0, exitState) + 0.5f); if (alpha > 0) { p.setAlpha(alpha); p.setStyle(Style.STROKE); p.setStrokeWidth(strokeWidth); c.drawCircle(x, y, strokeRadius, p); return true; } } } } return false; } } Loading
graphics/java/android/graphics/drawable/RevealDrawable.java +13 −8 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.graphics.drawable; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffXfermode; Loading Loading @@ -248,6 +249,7 @@ public class RevealDrawable extends LayerDrawable { } // Draw ripple mask into a buffer that merges using SRC_OVER. boolean needsMask = false; int layerSaveCount = -1; int n = activeRipples.size(); for (int i = 0; i < n; i++) { Loading @@ -261,7 +263,7 @@ public class RevealDrawable extends LayerDrawable { layerSaveCount = canvas.saveLayer(0, 0, width, height, null, 0); } ripple.draw(canvas, mRipplePaint); needsMask |= ripple.draw(canvas, mRipplePaint); } } Loading @@ -269,6 +271,7 @@ public class RevealDrawable extends LayerDrawable { // into another layer and composite using SRC_IN, then composite onto // the original canvas. if (layerSaveCount >= 0) { if (needsMask) { if (mMaskingPaint == null) { mMaskingPaint = new Paint(); mMaskingPaint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); Loading @@ -278,6 +281,8 @@ public class RevealDrawable extends LayerDrawable { // we won't need an extra layer. canvas.saveLayer(0, 0, width, height, mMaskingPaint, 0); getDrawable(1).draw(canvas); } canvas.restoreToCount(layerSaveCount); } } Loading
graphics/java/android/graphics/drawable/Ripple.java +28 −20 Original line number Diff line number Diff line Loading @@ -160,7 +160,7 @@ class Ripple { } } public void draw(Canvas c, Paint p) { public boolean draw(Canvas c, Paint p) { final Rect bounds = mBounds; final Rect padding = mPadding; final float dX = Math.max(mX, bounds.right - mX); Loading Loading @@ -221,6 +221,7 @@ class Ripple { } } if (maxAlpha > 0) { if (exitState <= 0) { // Exit state isn't showing, so we can simplify to a solid // circle. Loading @@ -228,6 +229,7 @@ class Ripple { p.setAlpha(maxAlpha); p.setStyle(Style.FILL); c.drawCircle(x, y, outerRadius, p); return true; } } else { // Both states are showing, so we need a circular stroke. Loading @@ -236,11 +238,17 @@ class Ripple { if (strokeWidth > 0) { final float strokeRadius = innerRadius + strokeWidth / 2f; final int alpha = (int) (MathUtils.lerp(maxAlpha, 0, exitState) + 0.5f); if (alpha > 0) { p.setAlpha(alpha); p.setStyle(Style.STROKE); p.setStrokeWidth(strokeWidth); c.drawCircle(x, y, strokeRadius, p); return true; } } } } return false; } }