Merge "Re-hide shader mutation, remove colorfilter mutation" into oc-dev
am: 0f9f0f90e7
Change-Id: I9ed9b1d27c28aef19553721266cb531ac410c175
This commit is contained in:
@@ -12599,7 +12599,6 @@ package android.graphics {
|
||||
|
||||
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 {
|
||||
@@ -12852,8 +12851,6 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -12994,8 +12991,6 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -13068,15 +13063,11 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -13586,10 +13577,6 @@ package android.graphics {
|
||||
|
||||
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 {
|
||||
@@ -13599,8 +13586,6 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -13785,8 +13770,6 @@ package android.graphics {
|
||||
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 {
|
||||
|
||||
@@ -13373,7 +13373,6 @@ package android.graphics {
|
||||
|
||||
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 {
|
||||
@@ -13626,8 +13625,6 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -13768,8 +13765,6 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -13842,15 +13837,11 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -14360,10 +14351,6 @@ package android.graphics {
|
||||
|
||||
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 {
|
||||
@@ -14373,8 +14360,6 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -14559,8 +14544,6 @@ package android.graphics {
|
||||
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 {
|
||||
|
||||
@@ -12641,7 +12641,6 @@ package android.graphics {
|
||||
|
||||
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 {
|
||||
@@ -12894,8 +12893,6 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -13036,8 +13033,6 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -13110,15 +13105,11 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -13628,10 +13619,6 @@ package android.graphics {
|
||||
|
||||
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 {
|
||||
@@ -13641,8 +13628,6 @@ package android.graphics {
|
||||
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 {
|
||||
@@ -13827,8 +13812,6 @@ package android.graphics {
|
||||
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 {
|
||||
|
||||
@@ -41,35 +41,16 @@ public class BitmapShader extends Shader {
|
||||
* @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;
|
||||
|
||||
@@ -73,6 +73,8 @@ public class ColorMatrixColorFilter extends ColorFilter {
|
||||
* @see #getColorMatrix(ColorMatrix)
|
||||
* @see #setColorMatrixArray(float[])
|
||||
* @see ColorMatrix#reset()
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setColorMatrix(@Nullable ColorMatrix matrix) {
|
||||
discardNativeInstance();
|
||||
@@ -99,6 +101,8 @@ public class ColorMatrixColorFilter extends ColorFilter {
|
||||
*
|
||||
* @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
|
||||
|
||||
@@ -59,43 +59,10 @@ public class ComposeShader extends Shader {
|
||||
}
|
||||
|
||||
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 @@ public class ComposeShader extends Shader {
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -57,8 +57,6 @@ public class LightingColorFilter extends ColorFilter {
|
||||
/**
|
||||
* 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 @@ public class LightingColorFilter extends ColorFilter {
|
||||
* The alpha channel of this color is ignored.
|
||||
*
|
||||
* @see #getColorMultiply()
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setColorMultiply(@ColorInt int mul) {
|
||||
if (mMul != mul) {
|
||||
@@ -82,8 +82,6 @@ public class LightingColorFilter extends ColorFilter {
|
||||
/**
|
||||
* 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 @@ public class LightingColorFilter extends ColorFilter {
|
||||
* The alpha channel of this color is ignored.
|
||||
*
|
||||
* @see #getColorAdd()
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setColorAdd(@ColorInt int add) {
|
||||
if (mAdd != add) {
|
||||
|
||||
@@ -57,7 +57,20 @@ public class LinearGradient extends Shader {
|
||||
*/
|
||||
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 class LinearGradient extends Shader {
|
||||
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;
|
||||
|
||||
@@ -49,6 +49,8 @@ public class PorterDuffColorFilter extends ColorFilter {
|
||||
*
|
||||
* @see Color
|
||||
* @see #setColor(int)
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@ColorInt
|
||||
public int getColor() {
|
||||
@@ -64,6 +66,8 @@ public class PorterDuffColorFilter extends ColorFilter {
|
||||
* @see Color
|
||||
* @see #getColor()
|
||||
* @see #getMode()
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setColor(@ColorInt int color) {
|
||||
if (mColor != color) {
|
||||
@@ -78,6 +82,8 @@ public class PorterDuffColorFilter extends ColorFilter {
|
||||
*
|
||||
* @see PorterDuff
|
||||
* @see #setMode(android.graphics.PorterDuff.Mode)
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public PorterDuff.Mode getMode() {
|
||||
return mMode;
|
||||
@@ -90,6 +96,8 @@ public class PorterDuffColorFilter extends ColorFilter {
|
||||
* @see PorterDuff
|
||||
* @see #getMode()
|
||||
* @see #getColor()
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setMode(@NonNull PorterDuff.Mode mode) {
|
||||
if (mode == null) {
|
||||
|
||||
@@ -57,7 +57,22 @@ public class RadialGradient extends Shader {
|
||||
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 class RadialGradient extends Shader {
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -105,20 +105,13 @@ public class Shader {
|
||||
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 @@ public class Shader {
|
||||
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);
|
||||
|
||||
@@ -54,7 +54,18 @@ public class SweepGradient extends Shader {
|
||||
*/
|
||||
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 @@ public class SweepGradient extends Shader {
|
||||
* @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;
|
||||
|
||||
Reference in New Issue
Block a user