diff options
author | Alan Viverette <alanv@google.com> | 2014-04-28 11:22:40 -0700 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2014-04-28 11:22:40 -0700 |
commit | 323596de4efc46149719b41de5a9f668d7f3f784 (patch) | |
tree | 18db98f925fb67fec94867a7f789877f41b062d9 /graphics | |
parent | 2a56ef70cd57accae240ef91863ce42fa71f11c6 (diff) | |
download | frameworks_base-323596de4efc46149719b41de5a9f668d7f3f784.zip frameworks_base-323596de4efc46149719b41de5a9f668d7f3f784.tar.gz frameworks_base-323596de4efc46149719b41de5a9f668d7f3f784.tar.bz2 |
Pull out dirty bounds before nulling ripples
BUG: 14378485
Change-Id: I286374db9865d2338852fd0df896928099a8eb24
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/drawable/TouchFeedbackDrawable.java | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/graphics/java/android/graphics/drawable/TouchFeedbackDrawable.java b/graphics/java/android/graphics/drawable/TouchFeedbackDrawable.java index 824e108..0e8831f 100644 --- a/graphics/java/android/graphics/drawable/TouchFeedbackDrawable.java +++ b/graphics/java/android/graphics/drawable/TouchFeedbackDrawable.java @@ -501,10 +501,32 @@ public class TouchFeedbackDrawable extends LayerDrawable { } private int drawRippleLayer(Canvas canvas, Rect bounds, boolean maskOnly) { - final Ripple[] activeRipples = mActiveRipples; final int ripplesCount = mActiveRipplesCount; + if (ripplesCount == 0) { + return -1; + } + + final Ripple[] activeRipples = mActiveRipples; + final boolean projected = isProjected(); + final Rect layerBounds = projected ? getDirtyBounds() : bounds; + + // Separate the ripple color and alpha channel. The alpha will be + // applied when we merge the ripples down to the canvas. + final int rippleColor; + if (mState.mTint != null) { + rippleColor = mState.mTint.getColorForState(getState(), Color.TRANSPARENT); + } else { + rippleColor = Color.TRANSPARENT; + } + final int rippleAlpha = Color.alpha(rippleColor); + + if (mRipplePaint == null) { + mRipplePaint = new Paint(); + mRipplePaint.setAntiAlias(true); + } + final Paint ripplePaint = mRipplePaint; + ripplePaint.setColor(rippleColor); - Paint ripplePaint = null; boolean drewRipples = false; int restoreToCount = -1; int activeRipplesCount = 0; @@ -524,20 +546,9 @@ public class TouchFeedbackDrawable extends LayerDrawable { // If we're masking the ripple layer, make sure we have a layer // first. This will merge SRC_OVER (directly) onto the canvas. if (restoreToCount < 0) { - // Separate the ripple color and alpha channel. The alpha will be - // applied when we merge the ripples down to the canvas. - final int rippleColor; - if (mState.mTint != null) { - rippleColor = mState.mTint.getColorForState(getState(), Color.TRANSPARENT); - } else { - rippleColor = Color.TRANSPARENT; - } - final int rippleAlpha = Color.alpha(rippleColor); - // If we're projecting or we only have a mask, we want to treat the // underlying canvas as our content and merge the ripple layer down // using the tint xfermode. - final boolean projected = isProjected(); final PorterDuffXfermode xfermode; if (projected || maskOnly) { xfermode = mState.getTintXfermode(); @@ -547,18 +558,12 @@ public class TouchFeedbackDrawable extends LayerDrawable { final Paint layerPaint = getMaskingPaint(xfermode); layerPaint.setAlpha(rippleAlpha); - final Rect layerBounds = projected ? getDirtyBounds() : bounds; restoreToCount = canvas.saveLayer(layerBounds.left, layerBounds.top, layerBounds.right, layerBounds.bottom, layerPaint); layerPaint.setAlpha(255); } - if (mRipplePaint == null) { - mRipplePaint = new Paint(); - mRipplePaint.setAntiAlias(true); - } - - drewRipples |= ripple.draw(canvas, mRipplePaint); + drewRipples |= ripple.draw(canvas, ripplePaint); activeRipples[activeRipplesCount] = activeRipples[i]; activeRipplesCount++; |