Merge "Add a EdgeEffect#setBlendMode API."
diff --git a/api/current.txt b/api/current.txt
index 9366a9b..abab901 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -55548,6 +55548,7 @@
ctor public EdgeEffect(android.content.Context);
method public boolean draw(android.graphics.Canvas);
method public void finish();
+ method @Nullable public android.graphics.BlendMode getBlendMode();
method @ColorInt public int getColor();
method public int getMaxHeight();
method public boolean isFinished();
@@ -55555,8 +55556,10 @@
method public void onPull(float);
method public void onPull(float, float);
method public void onRelease();
+ method public void setBlendMode(@Nullable android.graphics.BlendMode);
method public void setColor(@ColorInt int);
method public void setSize(int, int);
+ field public static final android.graphics.BlendMode DEFAULT_BLEND_MODE;
}
public class EditText extends android.widget.TextView {
diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java
index 7e42862..fa0af78 100644
--- a/core/java/android/widget/EdgeEffect.java
+++ b/core/java/android/widget/EdgeEffect.java
@@ -17,14 +17,15 @@
package android.widget;
import android.annotation.ColorInt;
+import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.TypedArray;
+import android.graphics.BlendMode;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
+import android.os.Build;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
@@ -48,6 +49,12 @@
* {@link #draw(Canvas)} method.</p>
*/
public class EdgeEffect {
+
+ /**
+ * The default blend mode used by {@link EdgeEffect}.
+ */
+ public static final BlendMode DEFAULT_BLEND_MODE = BlendMode.SRC_ATOP;
+
@SuppressWarnings("UnusedDeclaration")
private static final String TAG = "EdgeEffect";
@@ -108,7 +115,7 @@
private float mPullDistance;
private final Rect mBounds = new Rect();
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769450)
private final Paint mPaint = new Paint();
private float mRadius;
private float mBaseGlowScale;
@@ -128,7 +135,7 @@
a.recycle();
mPaint.setColor((themeColor & 0xffffff) | 0x33000000);
mPaint.setStyle(Paint.Style.FILL);
- mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
+ mPaint.setBlendMode(DEFAULT_BLEND_MODE);
mInterpolator = new DecelerateInterpolator();
}
@@ -302,6 +309,22 @@
}
/**
+ * Set or clear the blend mode. A blend mode defines how source pixels
+ * (generated by a drawing command) are composited with the destination pixels
+ * (content of the render target).
+ * <p />
+ * Pass null to clear any previous blend mode.
+ * <p />
+ *
+ * @see BlendMode
+ *
+ * @param blendmode May be null. The blend mode to be installed in the paint
+ */
+ public void setBlendMode(@Nullable BlendMode blendmode) {
+ mPaint.setBlendMode(blendmode);
+ }
+
+ /**
* Return the color of this edge effect in argb.
* @return The color of this edge effect in argb
*/
@@ -310,6 +333,20 @@
return mPaint.getColor();
}
+
+ /**
+ * Returns the blend mode. A blend mode defines how source pixels
+ * (generated by a drawing command) are composited with the destination pixels
+ * (content of the render target).
+ * <p />
+ *
+ * @return BlendMode
+ */
+ @Nullable
+ public BlendMode getBlendMode() {
+ return mPaint.getBlendMode();
+ }
+
/**
* Draw into the provided canvas. Assumes that the canvas has been rotated
* accordingly and the size has been set. The effect will be drawn the full
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 73442db..e617c42 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -1279,7 +1279,6 @@
* (content of the render target).
* <p />
* Pass null to clear any previous blend mode.
- * As a convenience, the parameter passed is also returned.
* <p />
*
* @see BlendMode