Merge "Clamp ink color alpha" into sc-dev
This commit is contained in:
@@ -23,6 +23,7 @@ import static java.lang.annotation.ElementType.PARAMETER;
|
|||||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||||
|
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
|
import android.annotation.ColorInt;
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
@@ -960,9 +961,11 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
float radius = getComputedRadius();
|
float radius = getComputedRadius();
|
||||||
RippleAnimationSession.AnimationProperties<Float, Paint> properties;
|
RippleAnimationSession.AnimationProperties<Float, Paint> properties;
|
||||||
RippleShader shader = new RippleShader();
|
RippleShader shader = new RippleShader();
|
||||||
final int color = mMaskColorFilter == null
|
// Grab the color for the current state and cut the alpha channel in
|
||||||
|
// half so that the ripple and background together yield full alpha.
|
||||||
|
final int color = clampAlpha(mMaskColorFilter == null
|
||||||
? mState.mColor.getColorForState(getState(), Color.BLACK)
|
? mState.mColor.getColorForState(getState(), Color.BLACK)
|
||||||
: mMaskColorFilter.getColor();
|
: mMaskColorFilter.getColor());
|
||||||
final int effectColor = mState.mEffectColor.getColorForState(getState(), Color.MAGENTA);
|
final int effectColor = mState.mEffectColor.getColorForState(getState(), Color.MAGENTA);
|
||||||
shader.setColor(color, effectColor);
|
shader.setColor(color, effectColor);
|
||||||
shader.setOrigin(cx, cy);
|
shader.setOrigin(cx, cy);
|
||||||
@@ -984,6 +987,13 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int clampAlpha(@ColorInt int color) {
|
||||||
|
if (Color.alpha(color) > 128) {
|
||||||
|
return (color & 0x00FFFFFF) | 0x80000000;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean shouldUseCanvasProps(Canvas c) {
|
private boolean shouldUseCanvasProps(Canvas c) {
|
||||||
return !mForceSoftware && c.isHardwareAccelerated();
|
return !mForceSoftware && c.isHardwareAccelerated();
|
||||||
}
|
}
|
||||||
@@ -1194,10 +1204,7 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
|
|
||||||
// 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
|
||||||
// half so that the ripple and background together yield full alpha.
|
// half so that the ripple and background together yield full alpha.
|
||||||
int color = mState.mColor.getColorForState(getState(), Color.BLACK);
|
final int color = clampAlpha(mState.mColor.getColorForState(getState(), Color.BLACK));
|
||||||
if (Color.alpha(color) > 128) {
|
|
||||||
color = (color & 0x00FFFFFF) | 0x80000000;
|
|
||||||
}
|
|
||||||
final Paint p = mRipplePaint;
|
final Paint p = mRipplePaint;
|
||||||
|
|
||||||
if (mMaskColorFilter != null) {
|
if (mMaskColorFilter != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user