Support tinting blur drawable
In order to achieve the look and feel of colored surfaces, the blur drawable should be able to receive a color and draw it on top of the blur region. Test: manual Fixes: 172372852 Change-Id: I4cab21e337ca18f617780531368ba70154027b72
This commit is contained in:
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
@@ -75,7 +76,8 @@ public final class BackgroundBlurDrawable extends Drawable {
|
||||
|
||||
private BackgroundBlurDrawable(Aggregator aggregator) {
|
||||
mAggregator = aggregator;
|
||||
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
|
||||
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
|
||||
mPaint.setColor(Color.TRANSPARENT);
|
||||
mRenderNode = new RenderNode("BackgroundBlurDrawable");
|
||||
mRenderNode.addPositionUpdateListener(mPositionUpdateListener);
|
||||
}
|
||||
@@ -85,10 +87,16 @@ public final class BackgroundBlurDrawable extends Drawable {
|
||||
if (mRectPath.isEmpty() || !isVisible() || getAlpha() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
canvas.drawPath(mRectPath, mPaint);
|
||||
canvas.drawRenderNode(mRenderNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTint(int tintColor) {
|
||||
mPaint.setColor(tintColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setVisible(boolean visible, boolean restart) {
|
||||
boolean changed = super.setVisible(visible, restart);
|
||||
|
||||
Reference in New Issue
Block a user