Loading graphics/java/android/graphics/drawable/Ripple.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -139,6 +139,10 @@ class Ripple { clampStartingPosition(); clampStartingPosition(); } } public boolean isHardwareAnimating() { return mHardwareAnimating; } private void clampStartingPosition() { private void clampStartingPosition() { final float cX = mBounds.exactCenterX(); final float cX = mBounds.exactCenterX(); final float cY = mBounds.exactCenterY(); final float cY = mBounds.exactCenterY(); Loading graphics/java/android/graphics/drawable/RippleBackground.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -122,6 +122,10 @@ class RippleBackground { mDensity = density; mDensity = density; } } public boolean isHardwareAnimating() { return mHardwareAnimating; } public void onHotspotBoundsChanged() { public void onHotspotBoundsChanged() { if (!mHasMaxRadius) { if (!mHasMaxRadius) { final float halfWidth = mBounds.width() / 2.0f; final float halfWidth = mBounds.width() / 2.0f; Loading graphics/java/android/graphics/drawable/RippleDrawable.java +22 −5 Original line number Original line Diff line number Diff line Loading @@ -202,24 +202,31 @@ public class RippleDrawable extends LayerDrawable { public void jumpToCurrentState() { public void jumpToCurrentState() { super.jumpToCurrentState(); super.jumpToCurrentState(); boolean needsDraw = false; if (mRipple != null) { if (mRipple != null) { needsDraw |= mRipple.isHardwareAnimating(); mRipple.jump(); mRipple.jump(); } } if (mBackground != null) { if (mBackground != null) { needsDraw |= mBackground.isHardwareAnimating(); mBackground.jump(); mBackground.jump(); } } cancelExitingRipples(); needsDraw |= cancelExitingRipples(); mNeedsDraw = true; mNeedsDraw = needsDraw; invalidateSelf(); invalidateSelf(); } } private void cancelExitingRipples() { private boolean cancelExitingRipples() { boolean needsDraw = false; final int count = mExitingRipplesCount; final int count = mExitingRipplesCount; final Ripple[] ripples = mExitingRipples; final Ripple[] ripples = mExitingRipples; for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) { needsDraw |= ripples[i].isHardwareAnimating(); ripples[i].cancel(); ripples[i].cancel(); } } Loading @@ -227,6 +234,8 @@ public class RippleDrawable extends LayerDrawable { Arrays.fill(ripples, 0, count, null); Arrays.fill(ripples, 0, count, null); } } mExitingRipplesCount = 0; mExitingRipplesCount = 0; return needsDraw; } } @Override @Override Loading Loading @@ -546,19 +555,23 @@ public class RippleDrawable extends LayerDrawable { * background. Nothing will be drawn after this method is called. * background. Nothing will be drawn after this method is called. */ */ private void clearHotspots() { private void clearHotspots() { boolean needsDraw = false; if (mRipple != null) { if (mRipple != null) { needsDraw |= mRipple.isHardwareAnimating(); mRipple.cancel(); mRipple.cancel(); mRipple = null; mRipple = null; } } if (mBackground != null) { if (mBackground != null) { needsDraw |= mBackground.isHardwareAnimating(); mBackground.cancel(); mBackground.cancel(); mBackground = null; mBackground = null; } } cancelExitingRipples(); needsDraw |= cancelExitingRipples(); mNeedsDraw = true; mNeedsDraw = needsDraw; invalidateSelf(); invalidateSelf(); } } Loading Loading @@ -657,6 +670,10 @@ public class RippleDrawable extends LayerDrawable { // least draw a color so that hardware invalidation works correctly. // least draw a color so that hardware invalidation works correctly. if (contentLayer < 0 && backgroundLayer < 0 && rippleLayer < 0 && mNeedsDraw) { if (contentLayer < 0 && backgroundLayer < 0 && rippleLayer < 0 && mNeedsDraw) { canvas.drawColor(Color.TRANSPARENT); canvas.drawColor(Color.TRANSPARENT); // Request another draw so we can avoid adding a transparent layer // during the next display list refresh. invalidateSelf(); } } mNeedsDraw = false; mNeedsDraw = false; Loading Loading
graphics/java/android/graphics/drawable/Ripple.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -139,6 +139,10 @@ class Ripple { clampStartingPosition(); clampStartingPosition(); } } public boolean isHardwareAnimating() { return mHardwareAnimating; } private void clampStartingPosition() { private void clampStartingPosition() { final float cX = mBounds.exactCenterX(); final float cX = mBounds.exactCenterX(); final float cY = mBounds.exactCenterY(); final float cY = mBounds.exactCenterY(); Loading
graphics/java/android/graphics/drawable/RippleBackground.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -122,6 +122,10 @@ class RippleBackground { mDensity = density; mDensity = density; } } public boolean isHardwareAnimating() { return mHardwareAnimating; } public void onHotspotBoundsChanged() { public void onHotspotBoundsChanged() { if (!mHasMaxRadius) { if (!mHasMaxRadius) { final float halfWidth = mBounds.width() / 2.0f; final float halfWidth = mBounds.width() / 2.0f; Loading
graphics/java/android/graphics/drawable/RippleDrawable.java +22 −5 Original line number Original line Diff line number Diff line Loading @@ -202,24 +202,31 @@ public class RippleDrawable extends LayerDrawable { public void jumpToCurrentState() { public void jumpToCurrentState() { super.jumpToCurrentState(); super.jumpToCurrentState(); boolean needsDraw = false; if (mRipple != null) { if (mRipple != null) { needsDraw |= mRipple.isHardwareAnimating(); mRipple.jump(); mRipple.jump(); } } if (mBackground != null) { if (mBackground != null) { needsDraw |= mBackground.isHardwareAnimating(); mBackground.jump(); mBackground.jump(); } } cancelExitingRipples(); needsDraw |= cancelExitingRipples(); mNeedsDraw = true; mNeedsDraw = needsDraw; invalidateSelf(); invalidateSelf(); } } private void cancelExitingRipples() { private boolean cancelExitingRipples() { boolean needsDraw = false; final int count = mExitingRipplesCount; final int count = mExitingRipplesCount; final Ripple[] ripples = mExitingRipples; final Ripple[] ripples = mExitingRipples; for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) { needsDraw |= ripples[i].isHardwareAnimating(); ripples[i].cancel(); ripples[i].cancel(); } } Loading @@ -227,6 +234,8 @@ public class RippleDrawable extends LayerDrawable { Arrays.fill(ripples, 0, count, null); Arrays.fill(ripples, 0, count, null); } } mExitingRipplesCount = 0; mExitingRipplesCount = 0; return needsDraw; } } @Override @Override Loading Loading @@ -546,19 +555,23 @@ public class RippleDrawable extends LayerDrawable { * background. Nothing will be drawn after this method is called. * background. Nothing will be drawn after this method is called. */ */ private void clearHotspots() { private void clearHotspots() { boolean needsDraw = false; if (mRipple != null) { if (mRipple != null) { needsDraw |= mRipple.isHardwareAnimating(); mRipple.cancel(); mRipple.cancel(); mRipple = null; mRipple = null; } } if (mBackground != null) { if (mBackground != null) { needsDraw |= mBackground.isHardwareAnimating(); mBackground.cancel(); mBackground.cancel(); mBackground = null; mBackground = null; } } cancelExitingRipples(); needsDraw |= cancelExitingRipples(); mNeedsDraw = true; mNeedsDraw = needsDraw; invalidateSelf(); invalidateSelf(); } } Loading Loading @@ -657,6 +670,10 @@ public class RippleDrawable extends LayerDrawable { // least draw a color so that hardware invalidation works correctly. // least draw a color so that hardware invalidation works correctly. if (contentLayer < 0 && backgroundLayer < 0 && rippleLayer < 0 && mNeedsDraw) { if (contentLayer < 0 && backgroundLayer < 0 && rippleLayer < 0 && mNeedsDraw) { canvas.drawColor(Color.TRANSPARENT); canvas.drawColor(Color.TRANSPARENT); // Request another draw so we can avoid adding a transparent layer // during the next display list refresh. invalidateSelf(); } } mNeedsDraw = false; mNeedsDraw = false; Loading