Merge "Set mask shader after matrix is set" into tm-dev
This commit is contained in:
@@ -881,7 +881,7 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
mAddRipple = false;
|
mAddRipple = false;
|
||||||
if (mRunningAnimations.size() > 0 && !addRipple) {
|
if (mRunningAnimations.size() > 0 && !addRipple) {
|
||||||
// update paint when view is invalidated
|
// update paint when view is invalidated
|
||||||
getRipplePaint();
|
updateRipplePaint();
|
||||||
}
|
}
|
||||||
drawContent(canvas);
|
drawContent(canvas);
|
||||||
drawPatternedBackground(canvas, cx, cy);
|
drawPatternedBackground(canvas, cx, cy);
|
||||||
@@ -940,7 +940,7 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
startBackgroundAnimation();
|
startBackgroundAnimation();
|
||||||
}
|
}
|
||||||
if (mBackgroundOpacity == 0) return;
|
if (mBackgroundOpacity == 0) return;
|
||||||
Paint p = getRipplePaint();
|
Paint p = updateRipplePaint();
|
||||||
float newOpacity = mBackgroundOpacity;
|
float newOpacity = mBackgroundOpacity;
|
||||||
final int origAlpha = p.getAlpha();
|
final int origAlpha = p.getAlpha();
|
||||||
final int alpha = Math.min((int) (origAlpha * newOpacity + 0.5f), 255);
|
final int alpha = Math.min((int) (origAlpha * newOpacity + 0.5f), 255);
|
||||||
@@ -968,7 +968,7 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
@NonNull
|
@NonNull
|
||||||
private RippleAnimationSession.AnimationProperties<Float, Paint> createAnimationProperties(
|
private RippleAnimationSession.AnimationProperties<Float, Paint> createAnimationProperties(
|
||||||
float x, float y, float cx, float cy, float w, float h) {
|
float x, float y, float cx, float cy, float w, float h) {
|
||||||
Paint p = new Paint(getRipplePaint());
|
Paint p = new Paint(updateRipplePaint());
|
||||||
float radius = getComputedRadius();
|
float radius = getComputedRadius();
|
||||||
RippleAnimationSession.AnimationProperties<Float, Paint> properties;
|
RippleAnimationSession.AnimationProperties<Float, Paint> properties;
|
||||||
RippleShader shader = new RippleShader();
|
RippleShader shader = new RippleShader();
|
||||||
@@ -1108,11 +1108,6 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
drawContent(mMaskCanvas);
|
drawContent(mMaskCanvas);
|
||||||
}
|
}
|
||||||
mMaskCanvas.restoreToCount(saveCount);
|
mMaskCanvas.restoreToCount(saveCount);
|
||||||
if (mState.mRippleStyle == STYLE_PATTERNED) {
|
|
||||||
for (int i = 0; i < mRunningAnimations.size(); i++) {
|
|
||||||
mRunningAnimations.get(i).getProperties().getShader().setShader(mMaskShader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMaskType() {
|
private int getMaskType() {
|
||||||
@@ -1169,7 +1164,7 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
final float y = mHotspotBounds.exactCenterY();
|
final float y = mHotspotBounds.exactCenterY();
|
||||||
canvas.translate(x, y);
|
canvas.translate(x, y);
|
||||||
|
|
||||||
final Paint p = getRipplePaint();
|
final Paint p = updateRipplePaint();
|
||||||
|
|
||||||
if (background != null && background.isVisible()) {
|
if (background != null && background.isVisible()) {
|
||||||
background.draw(canvas, p);
|
background.draw(canvas, p);
|
||||||
@@ -1194,7 +1189,7 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
Paint getRipplePaint() {
|
Paint updateRipplePaint() {
|
||||||
if (mRipplePaint == null) {
|
if (mRipplePaint == null) {
|
||||||
mRipplePaint = new Paint();
|
mRipplePaint = new Paint();
|
||||||
mRipplePaint.setAntiAlias(true);
|
mRipplePaint.setAntiAlias(true);
|
||||||
@@ -1215,6 +1210,12 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
mMaskMatrix.setTranslate(bounds.left - x, bounds.top - y);
|
mMaskMatrix.setTranslate(bounds.left - x, bounds.top - y);
|
||||||
}
|
}
|
||||||
mMaskShader.setLocalMatrix(mMaskMatrix);
|
mMaskShader.setLocalMatrix(mMaskMatrix);
|
||||||
|
|
||||||
|
if (mState.mRippleStyle == STYLE_PATTERNED) {
|
||||||
|
for (int i = 0; i < mRunningAnimations.size(); i++) {
|
||||||
|
mRunningAnimations.get(i).getProperties().getShader().setShader(mMaskShader);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the color for the current state and cut the alpha channel in
|
// Grab the color for the current state and cut the alpha channel in
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ class RippleForeground extends RippleComponent {
|
|||||||
mPropX = CanvasProperty.createFloat(getCurrentX());
|
mPropX = CanvasProperty.createFloat(getCurrentX());
|
||||||
mPropY = CanvasProperty.createFloat(getCurrentY());
|
mPropY = CanvasProperty.createFloat(getCurrentY());
|
||||||
mPropRadius = CanvasProperty.createFloat(getCurrentRadius());
|
mPropRadius = CanvasProperty.createFloat(getCurrentRadius());
|
||||||
final Paint paint = mOwner.getRipplePaint();
|
final Paint paint = mOwner.updateRipplePaint();
|
||||||
mPropPaint = CanvasProperty.createPaint(paint);
|
mPropPaint = CanvasProperty.createPaint(paint);
|
||||||
|
|
||||||
final RenderNodeAnimator radius = new RenderNodeAnimator(mPropRadius, mTargetRadius);
|
final RenderNodeAnimator radius = new RenderNodeAnimator(mPropRadius, mTargetRadius);
|
||||||
@@ -290,7 +290,7 @@ class RippleForeground extends RippleComponent {
|
|||||||
opacity.setInterpolator(LINEAR_INTERPOLATOR);
|
opacity.setInterpolator(LINEAR_INTERPOLATOR);
|
||||||
opacity.addListener(mAnimationListener);
|
opacity.addListener(mAnimationListener);
|
||||||
opacity.setStartDelay(computeFadeOutDelay());
|
opacity.setStartDelay(computeFadeOutDelay());
|
||||||
opacity.setStartValue(mOwner.getRipplePaint().getAlpha());
|
opacity.setStartValue(mOwner.updateRipplePaint().getAlpha());
|
||||||
mPendingHwAnimators.add(opacity);
|
mPendingHwAnimators.add(opacity);
|
||||||
invalidateSelf();
|
invalidateSelf();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user