Merge "Re-hide shader mutation, remove colorfilter mutation" into oc-dev am: 0f9f0f90e7
am: 0d6ea6a1f5
Change-Id: I84496c4aeee4cccc73f5d17f909d91f6910f1d85
diff --git a/api/current.txt b/api/current.txt
index fc0dd62..df3822c 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -12601,7 +12601,6 @@
public class BitmapShader extends android.graphics.Shader {
ctor public BitmapShader(android.graphics.Bitmap, android.graphics.Shader.TileMode, android.graphics.Shader.TileMode);
- method public void set(android.graphics.Bitmap, android.graphics.Shader.TileMode, android.graphics.Shader.TileMode);
}
public class BlurMaskFilter extends android.graphics.MaskFilter {
@@ -12854,8 +12853,6 @@
ctor public ColorMatrixColorFilter(android.graphics.ColorMatrix);
ctor public ColorMatrixColorFilter(float[]);
method public void getColorMatrix(android.graphics.ColorMatrix);
- method public void setColorMatrix(android.graphics.ColorMatrix);
- method public void setColorMatrixArray(float[]);
}
public abstract class ColorSpace {
@@ -12996,8 +12993,6 @@
public class ComposeShader extends android.graphics.Shader {
ctor public ComposeShader(android.graphics.Shader, android.graphics.Shader, android.graphics.Xfermode);
ctor public ComposeShader(android.graphics.Shader, android.graphics.Shader, android.graphics.PorterDuff.Mode);
- method public void set(android.graphics.Shader, android.graphics.Shader, android.graphics.Xfermode);
- method public void set(android.graphics.Shader, android.graphics.Shader, android.graphics.PorterDuff.Mode);
}
public class CornerPathEffect extends android.graphics.PathEffect {
@@ -13070,15 +13065,11 @@
ctor public LightingColorFilter(int, int);
method public int getColorAdd();
method public int getColorMultiply();
- method public void setColorAdd(int);
- method public void setColorMultiply(int);
}
public class LinearGradient extends android.graphics.Shader {
ctor public LinearGradient(float, float, float, float, int[], float[], android.graphics.Shader.TileMode);
ctor public LinearGradient(float, float, float, float, int, int, android.graphics.Shader.TileMode);
- method public void set(float, float, float, float, int[], float[], android.graphics.Shader.TileMode);
- method public void set(float, float, float, float, int, int, android.graphics.Shader.TileMode);
}
public class MaskFilter {
@@ -13588,10 +13579,6 @@
public class PorterDuffColorFilter extends android.graphics.ColorFilter {
ctor public PorterDuffColorFilter(int, android.graphics.PorterDuff.Mode);
- method public int getColor();
- method public android.graphics.PorterDuff.Mode getMode();
- method public void setColor(int);
- method public void setMode(android.graphics.PorterDuff.Mode);
}
public class PorterDuffXfermode extends android.graphics.Xfermode {
@@ -13601,8 +13588,6 @@
public class RadialGradient extends android.graphics.Shader {
ctor public RadialGradient(float, float, float, int[], float[], android.graphics.Shader.TileMode);
ctor public RadialGradient(float, float, float, int, int, android.graphics.Shader.TileMode);
- method public void set(float, float, float, int[], float[], android.graphics.Shader.TileMode);
- method public void set(float, float, float, int, int, android.graphics.Shader.TileMode);
}
public final class Rect implements android.os.Parcelable {
@@ -13787,8 +13772,6 @@
public class SweepGradient extends android.graphics.Shader {
ctor public SweepGradient(float, float, int[], float[]);
ctor public SweepGradient(float, float, int, int);
- method public void set(float, float, int[], float[]);
- method public void set(float, float, int, int);
}
public class Typeface {
diff --git a/api/system-current.txt b/api/system-current.txt
index 9cf0a6d..0a761a2 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -13375,7 +13375,6 @@
public class BitmapShader extends android.graphics.Shader {
ctor public BitmapShader(android.graphics.Bitmap, android.graphics.Shader.TileMode, android.graphics.Shader.TileMode);
- method public void set(android.graphics.Bitmap, android.graphics.Shader.TileMode, android.graphics.Shader.TileMode);
}
public class BlurMaskFilter extends android.graphics.MaskFilter {
@@ -13628,8 +13627,6 @@
ctor public ColorMatrixColorFilter(android.graphics.ColorMatrix);
ctor public ColorMatrixColorFilter(float[]);
method public void getColorMatrix(android.graphics.ColorMatrix);
- method public void setColorMatrix(android.graphics.ColorMatrix);
- method public void setColorMatrixArray(float[]);
}
public abstract class ColorSpace {
@@ -13770,8 +13767,6 @@
public class ComposeShader extends android.graphics.Shader {
ctor public ComposeShader(android.graphics.Shader, android.graphics.Shader, android.graphics.Xfermode);
ctor public ComposeShader(android.graphics.Shader, android.graphics.Shader, android.graphics.PorterDuff.Mode);
- method public void set(android.graphics.Shader, android.graphics.Shader, android.graphics.Xfermode);
- method public void set(android.graphics.Shader, android.graphics.Shader, android.graphics.PorterDuff.Mode);
}
public class CornerPathEffect extends android.graphics.PathEffect {
@@ -13844,15 +13839,11 @@
ctor public LightingColorFilter(int, int);
method public int getColorAdd();
method public int getColorMultiply();
- method public void setColorAdd(int);
- method public void setColorMultiply(int);
}
public class LinearGradient extends android.graphics.Shader {
ctor public LinearGradient(float, float, float, float, int[], float[], android.graphics.Shader.TileMode);
ctor public LinearGradient(float, float, float, float, int, int, android.graphics.Shader.TileMode);
- method public void set(float, float, float, float, int[], float[], android.graphics.Shader.TileMode);
- method public void set(float, float, float, float, int, int, android.graphics.Shader.TileMode);
}
public class MaskFilter {
@@ -14362,10 +14353,6 @@
public class PorterDuffColorFilter extends android.graphics.ColorFilter {
ctor public PorterDuffColorFilter(int, android.graphics.PorterDuff.Mode);
- method public int getColor();
- method public android.graphics.PorterDuff.Mode getMode();
- method public void setColor(int);
- method public void setMode(android.graphics.PorterDuff.Mode);
}
public class PorterDuffXfermode extends android.graphics.Xfermode {
@@ -14375,8 +14362,6 @@
public class RadialGradient extends android.graphics.Shader {
ctor public RadialGradient(float, float, float, int[], float[], android.graphics.Shader.TileMode);
ctor public RadialGradient(float, float, float, int, int, android.graphics.Shader.TileMode);
- method public void set(float, float, float, int[], float[], android.graphics.Shader.TileMode);
- method public void set(float, float, float, int, int, android.graphics.Shader.TileMode);
}
public final class Rect implements android.os.Parcelable {
@@ -14561,8 +14546,6 @@
public class SweepGradient extends android.graphics.Shader {
ctor public SweepGradient(float, float, int[], float[]);
ctor public SweepGradient(float, float, int, int);
- method public void set(float, float, int[], float[]);
- method public void set(float, float, int, int);
}
public class Typeface {
diff --git a/api/test-current.txt b/api/test-current.txt
index 9652fdf..53cc4b8 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -12643,7 +12643,6 @@
public class BitmapShader extends android.graphics.Shader {
ctor public BitmapShader(android.graphics.Bitmap, android.graphics.Shader.TileMode, android.graphics.Shader.TileMode);
- method public void set(android.graphics.Bitmap, android.graphics.Shader.TileMode, android.graphics.Shader.TileMode);
}
public class BlurMaskFilter extends android.graphics.MaskFilter {
@@ -12896,8 +12895,6 @@
ctor public ColorMatrixColorFilter(android.graphics.ColorMatrix);
ctor public ColorMatrixColorFilter(float[]);
method public void getColorMatrix(android.graphics.ColorMatrix);
- method public void setColorMatrix(android.graphics.ColorMatrix);
- method public void setColorMatrixArray(float[]);
}
public abstract class ColorSpace {
@@ -13038,8 +13035,6 @@
public class ComposeShader extends android.graphics.Shader {
ctor public ComposeShader(android.graphics.Shader, android.graphics.Shader, android.graphics.Xfermode);
ctor public ComposeShader(android.graphics.Shader, android.graphics.Shader, android.graphics.PorterDuff.Mode);
- method public void set(android.graphics.Shader, android.graphics.Shader, android.graphics.Xfermode);
- method public void set(android.graphics.Shader, android.graphics.Shader, android.graphics.PorterDuff.Mode);
}
public class CornerPathEffect extends android.graphics.PathEffect {
@@ -13112,15 +13107,11 @@
ctor public LightingColorFilter(int, int);
method public int getColorAdd();
method public int getColorMultiply();
- method public void setColorAdd(int);
- method public void setColorMultiply(int);
}
public class LinearGradient extends android.graphics.Shader {
ctor public LinearGradient(float, float, float, float, int[], float[], android.graphics.Shader.TileMode);
ctor public LinearGradient(float, float, float, float, int, int, android.graphics.Shader.TileMode);
- method public void set(float, float, float, float, int[], float[], android.graphics.Shader.TileMode);
- method public void set(float, float, float, float, int, int, android.graphics.Shader.TileMode);
}
public class MaskFilter {
@@ -13630,10 +13621,6 @@
public class PorterDuffColorFilter extends android.graphics.ColorFilter {
ctor public PorterDuffColorFilter(int, android.graphics.PorterDuff.Mode);
- method public int getColor();
- method public android.graphics.PorterDuff.Mode getMode();
- method public void setColor(int);
- method public void setMode(android.graphics.PorterDuff.Mode);
}
public class PorterDuffXfermode extends android.graphics.Xfermode {
@@ -13643,8 +13630,6 @@
public class RadialGradient extends android.graphics.Shader {
ctor public RadialGradient(float, float, float, int[], float[], android.graphics.Shader.TileMode);
ctor public RadialGradient(float, float, float, int, int, android.graphics.Shader.TileMode);
- method public void set(float, float, float, int[], float[], android.graphics.Shader.TileMode);
- method public void set(float, float, float, int, int, android.graphics.Shader.TileMode);
}
public final class Rect implements android.os.Parcelable {
@@ -13829,8 +13814,6 @@
public class SweepGradient extends android.graphics.Shader {
ctor public SweepGradient(float, float, int[], float[]);
ctor public SweepGradient(float, float, int, int);
- method public void set(float, float, int[], float[]);
- method public void set(float, float, int, int);
}
public class Typeface {
diff --git a/graphics/java/android/graphics/BitmapShader.java b/graphics/java/android/graphics/BitmapShader.java
index 7e6756e..5577f53 100644
--- a/graphics/java/android/graphics/BitmapShader.java
+++ b/graphics/java/android/graphics/BitmapShader.java
@@ -41,35 +41,16 @@
* @param tileY The tiling mode for y to draw the bitmap in.
*/
public BitmapShader(@NonNull Bitmap bitmap, @NonNull TileMode tileX, @NonNull TileMode tileY) {
- set(bitmap, tileX, tileY);
+ this(bitmap, tileX.nativeInt, tileY.nativeInt);
}
private BitmapShader(Bitmap bitmap, int tileX, int tileY) {
- setInternal(bitmap, tileX, tileY);
- }
-
- /**
- * Reinitialize the BitmapShader's Bitmap and tile modes.
- *
- * @param bitmap The bitmap to use inside the shader
- * @param tileX The tiling mode for x to draw the bitmap in.
- * @param tileY The tiling mode for y to draw the bitmap in.
- */
- public void set(@NonNull Bitmap bitmap, @NonNull TileMode tileX, @NonNull TileMode tileY) {
- if (tileX == null || tileY == null) {
- throw new IllegalArgumentException();
- }
- setInternal(bitmap, tileX.nativeInt, tileY.nativeInt);
- }
-
- private void setInternal(Bitmap bitmap, int tileX, int tileY) {
if (bitmap == null) {
throw new IllegalArgumentException("Bitmap must be non-null");
}
if (bitmap == mBitmap && tileX == mTileX && tileY == mTileY) {
return;
}
- discardNativeInstance();
mBitmap = bitmap;
mTileX = tileX;
mTileY = tileY;
diff --git a/graphics/java/android/graphics/ColorMatrixColorFilter.java b/graphics/java/android/graphics/ColorMatrixColorFilter.java
index 61f6cc5..9201a2e 100644
--- a/graphics/java/android/graphics/ColorMatrixColorFilter.java
+++ b/graphics/java/android/graphics/ColorMatrixColorFilter.java
@@ -73,6 +73,8 @@
* @see #getColorMatrix(ColorMatrix)
* @see #setColorMatrixArray(float[])
* @see ColorMatrix#reset()
+ *
+ * @hide
*/
public void setColorMatrix(@Nullable ColorMatrix matrix) {
discardNativeInstance();
@@ -99,6 +101,8 @@
*
* @throws ArrayIndexOutOfBoundsException if the specified array's
* length is < 20
+ *
+ * @hide
*/
public void setColorMatrixArray(@Nullable float[] array) {
// called '...Array' so that passing null isn't ambiguous
diff --git a/graphics/java/android/graphics/ComposeShader.java b/graphics/java/android/graphics/ComposeShader.java
index 8438bf2..e107ea7 100644
--- a/graphics/java/android/graphics/ComposeShader.java
+++ b/graphics/java/android/graphics/ComposeShader.java
@@ -59,43 +59,10 @@
}
private ComposeShader(Shader shaderA, Shader shaderB, int nativeMode) {
- setInternal(shaderA, shaderB, nativeMode);
- }
-
- /**
- * Reinitialize the ComposeShader's component Shaders and blend mode.
- *
- * @param shaderA The colors from this shader are seen as the "dst" by the mode
- * @param shaderB The colors from this shader are seen as the "src" by the mode
- * @param mode The PorterDuff mode that combines the colors from the two shaders.
- */
- public void set(@NonNull Shader shaderA, @NonNull Shader shaderB, @NonNull Xfermode mode) {
- setInternal(shaderA, shaderB, mode.porterDuffMode);
- }
-
- /**
- * Reinitialize the ComposeShader's component Shaders and blend mode.
- *
- * @param shaderA The colors from this shader are seen as the "dst" by the mode
- * @param shaderB The colors from this shader are seen as the "src" by the mode
- * @param mode The PorterDuff mode that combines the colors from the two shaders.
- */
- public void set(@NonNull Shader shaderA, @NonNull Shader shaderB,
- @NonNull PorterDuff.Mode mode) {
- setInternal(shaderA, shaderB, mode.nativeInt);
- }
-
- private void setInternal(Shader shaderA, Shader shaderB, int nativeMode) {
if (shaderA == null || shaderB == null) {
throw new IllegalArgumentException("Shader parameters must not be null");
}
- if (shaderA == mShaderA && shaderB == mShaderB && mPorterDuffMode == nativeMode) {
- // no work to do...
- return;
- }
-
- discardNativeInstance();
mShaderA = shaderA;
mShaderB = shaderB;
mPorterDuffMode = nativeMode;
@@ -109,16 +76,6 @@
mShaderA.getNativeInstance(), mShaderB.getNativeInstance(), mPorterDuffMode);
}
- @Override
- void verifyNativeInstance() {
- if (mShaderA.getNativeInstance() != mNativeInstanceShaderA
- || mShaderB.getNativeInstance() != mNativeInstanceShaderB) {
- // Child shader native instance has been updated,
- // so our cached native instance is no longer valid - discard it
- discardNativeInstance();
- }
- }
-
/**
* @hide
*/
diff --git a/graphics/java/android/graphics/LightingColorFilter.java b/graphics/java/android/graphics/LightingColorFilter.java
index b0c145b..1578ffb 100644
--- a/graphics/java/android/graphics/LightingColorFilter.java
+++ b/graphics/java/android/graphics/LightingColorFilter.java
@@ -57,8 +57,6 @@
/**
* Returns the RGB color used to multiply the source color when the
* color filter is applied.
- *
- * @see #setColorMultiply(int)
*/
@ColorInt
public int getColorMultiply() {
@@ -71,6 +69,8 @@
* The alpha channel of this color is ignored.
*
* @see #getColorMultiply()
+ *
+ * @hide
*/
public void setColorMultiply(@ColorInt int mul) {
if (mMul != mul) {
@@ -82,8 +82,6 @@
/**
* Returns the RGB color that will be added to the source color
* when the color filter is applied.
- *
- * @see #setColorAdd(int)
*/
@ColorInt
public int getColorAdd() {
@@ -96,6 +94,8 @@
* The alpha channel of this color is ignored.
*
* @see #getColorAdd()
+ *
+ * @hide
*/
public void setColorAdd(@ColorInt int add) {
if (mAdd != add) {
diff --git a/graphics/java/android/graphics/LinearGradient.java b/graphics/java/android/graphics/LinearGradient.java
index 0e4cd0a..7139efe 100644
--- a/graphics/java/android/graphics/LinearGradient.java
+++ b/graphics/java/android/graphics/LinearGradient.java
@@ -57,7 +57,20 @@
*/
public LinearGradient(float x0, float y0, float x1, float y1, @NonNull @ColorInt int colors[],
@Nullable float positions[], @NonNull TileMode tile) {
- set(x0, y0, x1, y1, colors, positions, tile);
+ if (colors.length < 2) {
+ throw new IllegalArgumentException("needs >= 2 number of colors");
+ }
+ if (positions != null && colors.length != positions.length) {
+ throw new IllegalArgumentException("color and position arrays must be of equal length");
+ }
+ mType = TYPE_COLORS_AND_POSITIONS;
+ mX0 = x0;
+ mY0 = y0;
+ mX1 = x1;
+ mY1 = y1;
+ mColors = colors.clone();
+ mPositions = positions != null ? positions.clone() : null;
+ mTileMode = tile;
}
/**
@@ -74,56 +87,6 @@
public LinearGradient(float x0, float y0, float x1, float y1,
@ColorInt int color0, @ColorInt int color1,
@NonNull TileMode tile) {
- set(x0, y0, x1, y1, color0, color1, tile);
- }
-
- /**
- * Reinitialize the shader.
- *
- * @param x0 The x-coordinate for the start of the gradient line
- * @param y0 The y-coordinate for the start of the gradient line
- * @param x1 The x-coordinate for the end of the gradient line
- * @param y1 The y-coordinate for the end of the gradient line
- * @param colors The colors to be distributed along the gradient line
- * @param positions May be null. The relative positions [0..1] of
- * each corresponding color in the colors array. If this is null,
- * the the colors are distributed evenly along the gradient line.
- * @param tile The Shader tiling mode
- */
- public void set(float x0, float y0, float x1, float y1, @NonNull @ColorInt int colors[],
- @Nullable float positions[], @NonNull TileMode tile) {
- if (colors.length < 2) {
- throw new IllegalArgumentException("needs >= 2 number of colors");
- }
- if (positions != null && colors.length != positions.length) {
- throw new IllegalArgumentException("color and position arrays must be of equal length");
- }
- discardNativeInstance();
- mType = TYPE_COLORS_AND_POSITIONS;
- mX0 = x0;
- mY0 = y0;
- mX1 = x1;
- mY1 = y1;
- mColors = colors.clone();
- mPositions = positions != null ? positions.clone() : null;
- mTileMode = tile;
- }
-
- /**
- * Reinitialize the shader.
- *
- * @param x0 The x-coordinate for the start of the gradient line
- * @param y0 The y-coordinate for the start of the gradient line
- * @param x1 The x-coordinate for the end of the gradient line
- * @param y1 The y-coordinate for the end of the gradient line
- * @param color0 The color at the start of the gradient line.
- * @param color1 The color at the end of the gradient line.
- * @param tile The Shader tiling mode
- */
- public void set(float x0, float y0, float x1, float y1,
- @ColorInt int color0, @ColorInt int color1,
- @NonNull TileMode tile) {
- discardNativeInstance();
mType = TYPE_COLOR_START_AND_COLOR_END;
mX0 = x0;
mY0 = y0;
diff --git a/graphics/java/android/graphics/PorterDuffColorFilter.java b/graphics/java/android/graphics/PorterDuffColorFilter.java
index ccc6ead..01d5825 100644
--- a/graphics/java/android/graphics/PorterDuffColorFilter.java
+++ b/graphics/java/android/graphics/PorterDuffColorFilter.java
@@ -49,6 +49,8 @@
*
* @see Color
* @see #setColor(int)
+ *
+ * @hide
*/
@ColorInt
public int getColor() {
@@ -64,6 +66,8 @@
* @see Color
* @see #getColor()
* @see #getMode()
+ *
+ * @hide
*/
public void setColor(@ColorInt int color) {
if (mColor != color) {
@@ -78,6 +82,8 @@
*
* @see PorterDuff
* @see #setMode(android.graphics.PorterDuff.Mode)
+ *
+ * @hide
*/
public PorterDuff.Mode getMode() {
return mMode;
@@ -90,6 +96,8 @@
* @see PorterDuff
* @see #getMode()
* @see #getColor()
+ *
+ * @hide
*/
public void setMode(@NonNull PorterDuff.Mode mode) {
if (mode == null) {
diff --git a/graphics/java/android/graphics/RadialGradient.java b/graphics/java/android/graphics/RadialGradient.java
index ae8f7da..f4b1191 100644
--- a/graphics/java/android/graphics/RadialGradient.java
+++ b/graphics/java/android/graphics/RadialGradient.java
@@ -57,7 +57,22 @@
public RadialGradient(float centerX, float centerY, float radius,
@NonNull @ColorInt int colors[], @Nullable float stops[],
@NonNull TileMode tileMode) {
- set(centerX, centerY, radius, colors, stops, tileMode);
+ if (radius <= 0) {
+ throw new IllegalArgumentException("radius must be > 0");
+ }
+ if (colors.length < 2) {
+ throw new IllegalArgumentException("needs >= 2 number of colors");
+ }
+ if (stops != null && colors.length != stops.length) {
+ throw new IllegalArgumentException("color and position arrays must be of equal length");
+ }
+ mType = TYPE_COLORS_AND_POSITIONS;
+ mX = centerX;
+ mY = centerY;
+ mRadius = radius;
+ mColors = colors.clone();
+ mPositions = stops != null ? stops.clone() : null;
+ mTileMode = tileMode;
}
/**
@@ -72,59 +87,9 @@
*/
public RadialGradient(float centerX, float centerY, float radius,
@ColorInt int centerColor, @ColorInt int edgeColor, @NonNull TileMode tileMode) {
- set(centerX, centerY, radius, centerColor, edgeColor, tileMode);
- }
-
- /**
- * Reinitialize the shader.
- *
- * @param centerX The x-coordinate of the center of the radius
- * @param centerY The y-coordinate of the center of the radius
- * @param radius Must be positive. The radius of the circle for this gradient.
- * @param colors The colors to be distributed between the center and edge of the circle
- * @param stops May be <code>null</code>. Valid values are between <code>0.0f</code> and
- * <code>1.0f</code>. The relative position of each corresponding color in
- * the colors array. If <code>null</code>, colors are distributed evenly
- * between the center and edge of the circle.
- * @param tileMode The Shader tiling mode
- */
- public void set(float centerX, float centerY, float radius,
- @NonNull @ColorInt int colors[], @Nullable float stops[], @NonNull TileMode tileMode) {
if (radius <= 0) {
throw new IllegalArgumentException("radius must be > 0");
}
- if (colors.length < 2) {
- throw new IllegalArgumentException("needs >= 2 number of colors");
- }
- if (stops != null && colors.length != stops.length) {
- throw new IllegalArgumentException("color and position arrays must be of equal length");
- }
- discardNativeInstance();
- mType = TYPE_COLORS_AND_POSITIONS;
- mX = centerX;
- mY = centerY;
- mRadius = radius;
- mColors = colors.clone();
- mPositions = stops != null ? stops.clone() : null;
- mTileMode = tileMode;
- }
-
- /**
- * Reinitialize the shader.
- *
- * @param centerX The x-coordinate of the center of the radius
- * @param centerY The y-coordinate of the center of the radius
- * @param radius Must be positive. The radius of the circle for this gradient
- * @param centerColor The color at the center of the circle.
- * @param edgeColor The color at the edge of the circle.
- * @param tileMode The Shader tiling mode
- */
- public void set(float centerX, float centerY, float radius,
- @ColorInt int centerColor, @ColorInt int edgeColor, @NonNull TileMode tileMode) {
- if (radius <= 0) {
- throw new IllegalArgumentException("radius must be > 0");
- }
- discardNativeInstance();
mType = TYPE_COLOR_CENTER_AND_COLOR_EDGE;
mX = centerX;
mY = centerY;
diff --git a/graphics/java/android/graphics/Shader.java b/graphics/java/android/graphics/Shader.java
index 8410ab2..c744757 100644
--- a/graphics/java/android/graphics/Shader.java
+++ b/graphics/java/android/graphics/Shader.java
@@ -105,20 +105,13 @@
return 0;
}
- void discardNativeInstance() {
+ private void discardNativeInstance() {
if (mNativeInstance != 0) {
nativeSafeUnref(mNativeInstance);
mNativeInstance = 0;
}
}
- /**
- * Callback for subclasses to call {@link #discardNativeInstance()} if the most recently
- * constructed native instance is no longer valid.
- */
- void verifyNativeInstance() {
- }
-
@Override
protected void finalize() throws Throwable {
try {
@@ -155,9 +148,6 @@
throw new IllegalStateException("attempting to use a finalized Shader");
}
- // verify mNativeInstance is valid
- verifyNativeInstance();
-
if (mNativeInstance == 0) {
mNativeInstance = createNativeInstance(mLocalMatrix == null
? 0 : mLocalMatrix.native_instance);
diff --git a/graphics/java/android/graphics/SweepGradient.java b/graphics/java/android/graphics/SweepGradient.java
index 0a1aef6..b6b80b4 100644
--- a/graphics/java/android/graphics/SweepGradient.java
+++ b/graphics/java/android/graphics/SweepGradient.java
@@ -54,7 +54,18 @@
*/
public SweepGradient(float cx, float cy,
@NonNull @ColorInt int colors[], @Nullable float positions[]) {
- set(cx, cy, colors, positions);
+ if (colors.length < 2) {
+ throw new IllegalArgumentException("needs >= 2 number of colors");
+ }
+ if (positions != null && colors.length != positions.length) {
+ throw new IllegalArgumentException(
+ "color and position arrays must be of equal length");
+ }
+ mType = TYPE_COLORS_AND_POSITIONS;
+ mCx = cx;
+ mCy = cy;
+ mColors = colors.clone();
+ mPositions = positions != null ? positions.clone() : null;
}
/**
@@ -66,50 +77,6 @@
* @param color1 The color to use at the end of the sweep
*/
public SweepGradient(float cx, float cy, @ColorInt int color0, @ColorInt int color1) {
- set(cx, cy, color0, color1);
- }
-
- /**
- * Reinitialize the shader.
- *
- * @param cx The x-coordinate of the center
- * @param cy The y-coordinate of the center
- * @param colors The colors to be distributed between around the center.
- * There must be at least 2 colors in the array.
- * @param positions May be NULL. The relative position of
- * each corresponding color in the colors array, beginning
- * with 0 and ending with 1.0. If the values are not
- * monotonic, the drawing may produce unexpected results.
- * If positions is NULL, then the colors are automatically
- * spaced evenly.
- */
- public void set(float cx, float cy,
- @NonNull @ColorInt int colors[], @Nullable float positions[]) {
- if (colors.length < 2) {
- throw new IllegalArgumentException("needs >= 2 number of colors");
- }
- if (positions != null && colors.length != positions.length) {
- throw new IllegalArgumentException(
- "color and position arrays must be of equal length");
- }
- discardNativeInstance();
- mType = TYPE_COLORS_AND_POSITIONS;
- mCx = cx;
- mCy = cy;
- mColors = colors.clone();
- mPositions = positions != null ? positions.clone() : null;
- }
-
- /**
- * Reinitialize the shader.
- *
- * @param cx The x-coordinate of the center
- * @param cy The y-coordinate of the center
- * @param color0 The color to use at the start of the sweep
- * @param color1 The color to use at the end of the sweep
- */
- public void set(float cx, float cy, @ColorInt int color0, @ColorInt int color1) {
- discardNativeInstance();
mType = TYPE_COLOR_START_AND_COLOR_END;
mCx = cx;
mCy = cy;