Remove calls to deprecated SkBitmap::setIsOpaque()
setIsOpaque() has been removed from ToT Skia. Update setters for mIsPremultiplied and hasAlpha to take the other into consideration. Change-Id: I1b36b0b0ce7126031eb7b769b563c17dcd4b306a
This commit is contained in:
@@ -67,6 +67,16 @@ public final class Bitmap implements Parcelable {
|
||||
* setPremultiplied() aren't order dependent, despite being setters.
|
||||
*/
|
||||
private boolean mIsPremultiplied;
|
||||
|
||||
/**
|
||||
* Whether the Bitmap's content is expected to have alpha. Note that hasAlpha()
|
||||
* does not directly return this value, because hasAlpha() may never return true
|
||||
* for a 565 Bitmap.
|
||||
*
|
||||
* Any time this or mIsPremultiplied is changed, both are passed to native so they
|
||||
* are not order dependent.
|
||||
*/
|
||||
private boolean mHasAlpha;
|
||||
private byte[] mNinePatchChunk; // may be null
|
||||
private int[] mLayoutBounds; // may be null
|
||||
private int mWidth;
|
||||
@@ -554,7 +564,7 @@ public final class Bitmap implements Parcelable {
|
||||
checkRecycled("Can't copy a recycled bitmap");
|
||||
Bitmap b = nativeCopy(mNativeBitmap, config.nativeInt, isMutable);
|
||||
if (b != null) {
|
||||
b.mIsPremultiplied = mIsPremultiplied;
|
||||
b.setAlphaAndPremultiplied(mHasAlpha, mIsPremultiplied);
|
||||
b.mDensity = mDensity;
|
||||
}
|
||||
return b;
|
||||
@@ -727,12 +737,12 @@ public final class Bitmap implements Parcelable {
|
||||
paint.setAntiAlias(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The new bitmap was created from a known bitmap source so assume that
|
||||
// they use the same density
|
||||
bitmap.mDensity = source.mDensity;
|
||||
bitmap.mIsPremultiplied = source.mIsPremultiplied;
|
||||
|
||||
bitmap.setAlphaAndPremultiplied(source.mHasAlpha, source.mIsPremultiplied);
|
||||
|
||||
canvas.setBitmap(bitmap);
|
||||
canvas.drawBitmap(source, srcR, dstR, paint);
|
||||
canvas.setBitmap(null);
|
||||
@@ -810,9 +820,9 @@ public final class Bitmap implements Parcelable {
|
||||
if (display != null) {
|
||||
bm.mDensity = display.densityDpi;
|
||||
}
|
||||
bm.setHasAlpha(hasAlpha);
|
||||
if (config == Config.ARGB_8888 && !hasAlpha) {
|
||||
nativeErase(bm.mNativeBitmap, 0xff000000);
|
||||
nativeSetHasAlpha(bm.mNativeBitmap, hasAlpha);
|
||||
}
|
||||
// No need to initialize the bitmap to zeroes with other configs;
|
||||
// it is backed by a VM byte array which is by definition preinitialized
|
||||
@@ -884,6 +894,7 @@ public final class Bitmap implements Parcelable {
|
||||
if (display != null) {
|
||||
bm.mDensity = display.densityDpi;
|
||||
}
|
||||
bm.mHasAlpha = true;
|
||||
return bm;
|
||||
}
|
||||
|
||||
@@ -1041,11 +1052,24 @@ public final class Bitmap implements Parcelable {
|
||||
* <p>This method will not affect the behavior of a bitmap without an alpha
|
||||
* channel, or if {@link #hasAlpha()} returns false.</p>
|
||||
*
|
||||
* <p>Calling {@link createBitmap()} or {@link createScaledBitmap()} with a source
|
||||
* Bitmap whose colors are not pre-multiplied may result in a RuntimeException,
|
||||
* since those functions require drawing the source, which is not supported for
|
||||
* un-pre-multiplied Bitmaps.</p>
|
||||
*
|
||||
* @see Bitmap#isPremultiplied()
|
||||
* @see BitmapFactory.Options#inPremultiplied
|
||||
*/
|
||||
public final void setPremultiplied(boolean premultiplied) {
|
||||
mIsPremultiplied = premultiplied;
|
||||
nativeSetAlphaAndPremultiplied(mNativeBitmap, mHasAlpha, premultiplied);
|
||||
}
|
||||
|
||||
/** Helper function to set both alpha and premultiplied. **/
|
||||
private final void setAlphaAndPremultiplied(boolean hasAlpha, boolean premultiplied) {
|
||||
mHasAlpha = hasAlpha;
|
||||
mIsPremultiplied = premultiplied;
|
||||
nativeSetAlphaAndPremultiplied(mNativeBitmap, hasAlpha, premultiplied);
|
||||
}
|
||||
|
||||
/** Returns the bitmap's width */
|
||||
@@ -1206,7 +1230,8 @@ public final class Bitmap implements Parcelable {
|
||||
* non-opaque per-pixel alpha values.
|
||||
*/
|
||||
public void setHasAlpha(boolean hasAlpha) {
|
||||
nativeSetHasAlpha(mNativeBitmap, hasAlpha);
|
||||
mHasAlpha = hasAlpha;
|
||||
nativeSetAlphaAndPremultiplied(mNativeBitmap, hasAlpha, mIsPremultiplied);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1611,7 +1636,8 @@ public final class Bitmap implements Parcelable {
|
||||
|
||||
private static native void nativePrepareToDraw(int nativeBitmap);
|
||||
private static native boolean nativeHasAlpha(int nativeBitmap);
|
||||
private static native void nativeSetHasAlpha(int nBitmap, boolean hasAlpha);
|
||||
private static native void nativeSetAlphaAndPremultiplied(int nBitmap, boolean hasAlpha,
|
||||
boolean isPremul);
|
||||
private static native boolean nativeHasMipMap(int nativeBitmap);
|
||||
private static native void nativeSetHasMipMap(int nBitmap, boolean hasMipMap);
|
||||
private static native boolean nativeSameAs(int nb0, int nb1);
|
||||
|
||||
Reference in New Issue
Block a user