Merge "Ripple mask shader not drawing properly" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-03-10 20:36:35 +00:00
committed by Android (Google) Code Review

View File

@@ -1098,19 +1098,16 @@ public class RippleDrawable extends LayerDrawable {
} }
// Draw the appropriate mask anchored to (0,0). // Draw the appropriate mask anchored to (0,0).
final int saveCount = mMaskCanvas.save();
final int left = bounds.left; final int left = bounds.left;
final int top = bounds.top; final int top = bounds.top;
if (mState.mRippleStyle == STYLE_SOLID) { mMaskCanvas.translate(-left, -top);
mMaskCanvas.translate(-left, -top);
}
if (maskType == MASK_EXPLICIT) { if (maskType == MASK_EXPLICIT) {
drawMask(mMaskCanvas); drawMask(mMaskCanvas);
} else if (maskType == MASK_CONTENT) { } else if (maskType == MASK_CONTENT) {
drawContent(mMaskCanvas); drawContent(mMaskCanvas);
} }
if (mState.mRippleStyle == STYLE_SOLID) { mMaskCanvas.restoreToCount(saveCount);
mMaskCanvas.translate(left, top);
}
if (mState.mRippleStyle == STYLE_PATTERNED) { if (mState.mRippleStyle == STYLE_PATTERNED) {
for (int i = 0; i < mRunningAnimations.size(); i++) { for (int i = 0; i < mRunningAnimations.size(); i++) {
mRunningAnimations.get(i).getProperties().getShader().setShader(mMaskShader); mRunningAnimations.get(i).getProperties().getShader().setShader(mMaskShader);
@@ -1210,9 +1207,13 @@ public class RippleDrawable extends LayerDrawable {
updateMaskShaderIfNeeded(); updateMaskShaderIfNeeded();
// Position the shader to account for canvas translation. // Position the shader to account for canvas translation.
if (mMaskShader != null && mState.mRippleStyle == STYLE_SOLID) { if (mMaskShader != null) {
final Rect bounds = getBounds(); final Rect bounds = getBounds();
mMaskMatrix.setTranslate(bounds.left - x, bounds.top - y); if (mState.mRippleStyle == STYLE_PATTERNED) {
mMaskMatrix.setTranslate(bounds.left, bounds.top);
} else {
mMaskMatrix.setTranslate(bounds.left - x, bounds.top - y);
}
mMaskShader.setLocalMatrix(mMaskMatrix); mMaskShader.setLocalMatrix(mMaskMatrix);
} }