Rename getters and setters on ImageDecoder
Bug: 76448408 Test: Ib8782ff10072c81a5ed2a1031a70475fffee7ccf - Use "is" prefix for booleans instead of "get" - Reverse "require" and "unpremultiplied" for a more natural sound - Add "Required" to "Mutable" methods - Add "Enabled" to "DecodeAsAlphaMask" methods Change-Id: I644ddccd37898d89609e4534ece4ea70f74587c4
This commit is contained in:
@@ -13630,22 +13630,22 @@ package android.graphics {
|
||||
method public int getAllocator();
|
||||
method public boolean getConserveMemory();
|
||||
method public android.graphics.Rect getCrop();
|
||||
method public boolean getDecodeAsAlphaMask();
|
||||
method public boolean getMutable();
|
||||
method public android.graphics.ImageDecoder.OnPartialImageListener getOnPartialImageListener();
|
||||
method public android.graphics.PostProcessor getPostProcessor();
|
||||
method public boolean getRequireUnpremultiplied();
|
||||
method public boolean isDecodeAsAlphaMaskEnabled();
|
||||
method public boolean isMutableRequired();
|
||||
method public boolean isUnpremultipliedRequired();
|
||||
method public android.graphics.ImageDecoder setAllocator(int);
|
||||
method public android.graphics.ImageDecoder setConserveMemory(boolean);
|
||||
method public android.graphics.ImageDecoder setCrop(android.graphics.Rect);
|
||||
method public android.graphics.ImageDecoder setDecodeAsAlphaMask(boolean);
|
||||
method public android.graphics.ImageDecoder setMutable(boolean);
|
||||
method public android.graphics.ImageDecoder setDecodeAsAlphaMaskEnabled(boolean);
|
||||
method public android.graphics.ImageDecoder setMutableRequired(boolean);
|
||||
method public android.graphics.ImageDecoder setOnPartialImageListener(android.graphics.ImageDecoder.OnPartialImageListener);
|
||||
method public android.graphics.ImageDecoder setPostProcessor(android.graphics.PostProcessor);
|
||||
method public android.graphics.ImageDecoder setRequireUnpremultiplied(boolean);
|
||||
method public android.graphics.ImageDecoder setTargetColorSpace(android.graphics.ColorSpace);
|
||||
method public android.graphics.ImageDecoder setTargetSampleSize(int);
|
||||
method public android.graphics.ImageDecoder setTargetSize(int, int);
|
||||
method public android.graphics.ImageDecoder setUnpremultipliedRequired(boolean);
|
||||
field public static final int ALLOCATOR_DEFAULT = 0; // 0x0
|
||||
field public static final int ALLOCATOR_HARDWARE = 3; // 0x3
|
||||
field public static final int ALLOCATOR_SHARED_MEMORY = 2; // 0x2
|
||||
|
||||
@@ -183,7 +183,13 @@ package android.graphics {
|
||||
|
||||
public final class ImageDecoder implements java.lang.AutoCloseable {
|
||||
method public deprecated boolean getAsAlphaMask();
|
||||
method public deprecated boolean getDecodeAsAlphaMask();
|
||||
method public deprecated boolean getMutable();
|
||||
method public deprecated boolean getRequireUnpremultiplied();
|
||||
method public deprecated android.graphics.ImageDecoder setAsAlphaMask(boolean);
|
||||
method public deprecated android.graphics.ImageDecoder setDecodeAsAlphaMask(boolean);
|
||||
method public deprecated android.graphics.ImageDecoder setMutable(boolean);
|
||||
method public deprecated android.graphics.ImageDecoder setRequireUnpremultiplied(boolean);
|
||||
method public deprecated android.graphics.ImageDecoder setResize(int, int);
|
||||
method public deprecated android.graphics.ImageDecoder setResize(int);
|
||||
field public static final deprecated int ERROR_SOURCE_ERROR = 3; // 0x3
|
||||
|
||||
@@ -597,7 +597,7 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
private int mDesiredWidth;
|
||||
private int mDesiredHeight;
|
||||
private int mAllocator = ALLOCATOR_DEFAULT;
|
||||
private boolean mRequireUnpremultiplied = false;
|
||||
private boolean mUnpremultipliedRequired = false;
|
||||
private boolean mMutable = false;
|
||||
private boolean mConserveMemory = false;
|
||||
private boolean mDecodeAsAlphaMask = false;
|
||||
@@ -782,7 +782,7 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
* height that can be achieved by sampling the encoded image. Other widths
|
||||
* and heights may be supported, but will require an additional (internal)
|
||||
* scaling step. Such internal scaling is *not* supported with
|
||||
* {@link #setRequireUnpremultiplied} set to {@code true}.</p>
|
||||
* {@link #setUnpremultipliedRequired} set to {@code true}.</p>
|
||||
*
|
||||
* @param sampleSize Sampling rate of the encoded image.
|
||||
* @return {@link android.util.Size} of the width and height after
|
||||
@@ -909,7 +909,7 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
* Will typically result in a {@link Bitmap.Config#HARDWARE}
|
||||
* allocation, but may be software for small images. In addition, this will
|
||||
* switch to software when HARDWARE is incompatible, e.g.
|
||||
* {@link #setMutable}, {@link #setDecodeAsAlphaMask}.
|
||||
* {@link #setMutableRequired}, {@link #setDecodeAsAlphaMaskEnabled}.
|
||||
*/
|
||||
public static final int ALLOCATOR_DEFAULT = 0;
|
||||
|
||||
@@ -932,8 +932,8 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
* Require a {@link Bitmap.Config#HARDWARE} {@link Bitmap}.
|
||||
*
|
||||
* When this is combined with incompatible options, like
|
||||
* {@link #setMutable} or {@link #setDecodeAsAlphaMask}, {@link #decodeDrawable}
|
||||
* / {@link #decodeBitmap} will throw an
|
||||
* {@link #setMutableRequired} or {@link #setDecodeAsAlphaMaskEnabled},
|
||||
* {@link #decodeDrawable} / {@link #decodeBitmap} will throw an
|
||||
* {@link java.lang.IllegalStateException}.
|
||||
*/
|
||||
public static final int ALLOCATOR_HARDWARE = 3;
|
||||
@@ -984,16 +984,32 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
*
|
||||
* @return this object for chaining.
|
||||
*/
|
||||
public ImageDecoder setRequireUnpremultiplied(boolean requireUnpremultiplied) {
|
||||
mRequireUnpremultiplied = requireUnpremultiplied;
|
||||
public ImageDecoder setUnpremultipliedRequired(boolean unpremultipliedRequired) {
|
||||
mUnpremultipliedRequired = unpremultipliedRequired;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** @removed
|
||||
* @deprecated Renamed to {@link #setUnpremultipliedRequired}.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
public ImageDecoder setRequireUnpremultiplied(boolean unpremultipliedRequired) {
|
||||
return this.setUnpremultipliedRequired(unpremultipliedRequired);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the {@link Bitmap} will have unpremultiplied pixels.
|
||||
*/
|
||||
public boolean isUnpremultipliedRequired() {
|
||||
return mUnpremultipliedRequired;
|
||||
}
|
||||
|
||||
/** @removed
|
||||
* @deprecated Renamed to {@link #isUnpremultipliedRequired}.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
public boolean getRequireUnpremultiplied() {
|
||||
return mRequireUnpremultiplied;
|
||||
return this.isUnpremultipliedRequired();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1105,18 +1121,34 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
*
|
||||
* @return this object for chaining.
|
||||
*/
|
||||
public ImageDecoder setMutable(boolean mutable) {
|
||||
public ImageDecoder setMutableRequired(boolean mutable) {
|
||||
mMutable = mutable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** @removed
|
||||
* @deprecated Renamed to {@link #setMutableRequired}.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
public ImageDecoder setMutable(boolean mutable) {
|
||||
return this.setMutableRequired(mutable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the {@link Bitmap} will be mutable.
|
||||
*/
|
||||
public boolean getMutable() {
|
||||
public boolean isMutableRequired() {
|
||||
return mMutable;
|
||||
}
|
||||
|
||||
/** @removed
|
||||
* @deprecated Renamed to {@link #isMutableRequired}.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
public boolean getMutable() {
|
||||
return this.isMutableRequired();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether to potentially save RAM at the expense of quality.
|
||||
*
|
||||
@@ -1154,20 +1186,28 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
* with only one channel, treat that channel as alpha. Otherwise this call has
|
||||
* no effect.</p>
|
||||
*
|
||||
* <p>setDecodeAsAlphaMask is incompatible with {@link #ALLOCATOR_HARDWARE}. Trying to
|
||||
* <p>This is incompatible with {@link #ALLOCATOR_HARDWARE}. Trying to
|
||||
* combine them will result in {@link #decodeDrawable}/
|
||||
* {@link #decodeBitmap} throwing an
|
||||
* {@link java.lang.IllegalStateException}.</p>
|
||||
*
|
||||
* @return this object for chaining.
|
||||
*/
|
||||
public ImageDecoder setDecodeAsAlphaMask(boolean decodeAsAlphaMask) {
|
||||
mDecodeAsAlphaMask = decodeAsAlphaMask;
|
||||
public ImageDecoder setDecodeAsAlphaMaskEnabled(boolean enabled) {
|
||||
mDecodeAsAlphaMask = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** @removed
|
||||
* @deprecated Call {@link #setDecodeAsAlphaMask} instead.
|
||||
* @deprecated Renamed to {@link #setDecodeAsAlphaMaskEnabled}.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
public ImageDecoder setDecodeAsAlphaMask(boolean enabled) {
|
||||
return this.setDecodeAsAlphaMaskEnabled(enabled);
|
||||
}
|
||||
|
||||
/** @removed
|
||||
* @deprecated Renamed to {@link #setDecodeAsAlphaMaskEnabled}.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
public ImageDecoder setAsAlphaMask(boolean asAlphaMask) {
|
||||
@@ -1177,16 +1217,25 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
/**
|
||||
* Return whether to treat single channel input as alpha.
|
||||
*
|
||||
* <p>This returns whether {@link #setDecodeAsAlphaMask} was set to {@code true}.
|
||||
* It may still return {@code true} even if the image has more than one
|
||||
* channel and therefore will not be treated as an alpha mask.</p>
|
||||
* <p>This returns whether {@link #setDecodeAsAlphaMaskEnabled} was set to
|
||||
* {@code true}. It may still return {@code true} even if the image has
|
||||
* more than one channel and therefore will not be treated as an alpha
|
||||
* mask.</p>
|
||||
*/
|
||||
public boolean isDecodeAsAlphaMaskEnabled() {
|
||||
return mDecodeAsAlphaMask;
|
||||
}
|
||||
|
||||
/** @removed
|
||||
* @deprecated Renamed to {@link #isDecodeAsAlphaMaskEnabled}.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
public boolean getDecodeAsAlphaMask() {
|
||||
return mDecodeAsAlphaMask;
|
||||
}
|
||||
|
||||
/** @removed
|
||||
* @deprecated Call {@link #getDecodeAsAlphaMask} instead.
|
||||
* @deprecated Renamed to {@link #isDecodeAsAlphaMaskEnabled}.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
public boolean getAsAlphaMask() {
|
||||
@@ -1259,7 +1308,7 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
if (mPostProcessor != null && mRequireUnpremultiplied) {
|
||||
if (mPostProcessor != null && mUnpremultipliedRequired) {
|
||||
throw new IllegalStateException("Cannot draw to unpremultiplied pixels!");
|
||||
}
|
||||
|
||||
@@ -1290,7 +1339,7 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
checkState();
|
||||
return nDecodeBitmap(mNativePtr, this, mPostProcessor != null,
|
||||
mDesiredWidth, mDesiredHeight, mCropRect,
|
||||
mMutable, mAllocator, mRequireUnpremultiplied,
|
||||
mMutable, mAllocator, mUnpremultipliedRequired,
|
||||
mConserveMemory, mDecodeAsAlphaMask, mDesiredColorSpace);
|
||||
}
|
||||
|
||||
@@ -1334,7 +1383,7 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
decoder.mSource = src;
|
||||
decoder.callHeaderDecoded(listener, src);
|
||||
|
||||
if (decoder.mRequireUnpremultiplied) {
|
||||
if (decoder.mUnpremultipliedRequired) {
|
||||
// Though this could be supported (ignored) for opaque images,
|
||||
// it seems better to always report this error.
|
||||
throw new IllegalStateException("Cannot decode a Drawable " +
|
||||
@@ -1534,7 +1583,7 @@ public final class ImageDecoder implements AutoCloseable {
|
||||
boolean doPostProcess,
|
||||
int width, int height,
|
||||
@Nullable Rect cropRect, boolean mutable,
|
||||
int allocator, boolean requireUnpremul,
|
||||
int allocator, boolean unpremulRequired,
|
||||
boolean conserveMemory, boolean decodeAsAlphaMask,
|
||||
@Nullable ColorSpace desiredColorSpace)
|
||||
throws IOException;
|
||||
|
||||
Reference in New Issue
Block a user