Update framework to use M33 Skia. DO NOT MERGE
(These CLs are already in master.) Bug: 13246311 This cherry-picks 7 CLs: ----------------------------------------------------------------------- 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. cherry-pick from: I1b36b0b0ce7126031eb7b769b563c17dcd4b306a ----------------------------------------------------------------------- Merge AssetStream with AssetStreamAdaptor. Add enums to the constructor for AssetStreamAdaptor to choose the different behaviors used by the (former) two different classes. The old clients of AssetStream now get the following features of AssetStreamAdaptor - Debugging statements on error. - The stream is an SkStreamRewindable. - getLength() returns the correct value, and the old way of getting the length (read(NULL, 0)) is no longer implemented, since it is no longer used. - isAtEnd() returns the correct value. ToT Skia makes it pure virtual, so some implementation is necessary. cherry-pick from: I2a5395914e4f53830aaefee396556459083a1c56 ----------------------------------------------------------------------- Deprecate Android-specific SkPaint functions. The following functions were problematic: const SkGlyph& getUnicharMetrics(SkUnichar, const SkMatrix*); const SkGlyph& getGlyphMetrics(uint16_t, const SkMatrix*); const void* findImage(const SkGlyph&, const SkMatrix*); Replacing them with calls through SkGlyphCache solved a nasty crash bug, so they have all been deprecated. Bug: 11968757 cherry-pick from: Id746315d41aec5b211b78b172a883c2061130f08 ----------------------------------------------------------------------- pass SkGlyphCache into updateGlyphCache() Doing so prevents us from double-locking the glyph cache, thereby effectively locking ourselves out of reusing work that we'd just done. Bug: 11968757 cherry-pick from: I5c552f2d0bbe30af2ce9054ba684e7da756a0d89 ----------------------------------------------------------------------- Updates to the Skia API needed to merge the WebView m33 version of Skia. cherry-pick from: I0f63b53f2aae58871413b132742fc84138f069a3 Bugfix for screenshots (recent apps) due to incorrect rowBytes computation bug: 12915192 cherry-pick from: I4d5fe2a2f75baf66099e0970fb646686a1992714 ----------------------------------------------------------------------- Fix bug in AndroidPixelRef where we did not store the correct imageInfo for a recycled bitmap. cherry-pick from: I882483b78886e2f19fa4e43a86e69f5a82b3b7e5 ----------------------------------------------------------------------- Change-Id: Ie2b731a9f0795802418cfecddb4b684c92c64d33 Conflicts: core/jni/android/graphics/Bitmap.cpp core/jni/android/graphics/Graphics.cpp core/jni/android/graphics/Typeface.cpp graphics/java/android/graphics/Bitmap.java
This commit is contained in:
committed by
Ben Murdoch
parent
ca0aba3993
commit
f8d8777ddd
@@ -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;
|
||||
@@ -390,7 +400,7 @@ public final class Bitmap implements Parcelable {
|
||||
* No color information is stored.
|
||||
* With this configuration, each pixel requires 1 byte of memory.
|
||||
*/
|
||||
ALPHA_8 (2),
|
||||
ALPHA_8 (1),
|
||||
|
||||
/**
|
||||
* Each pixel is stored on 2 bytes and only the RGB channels are
|
||||
@@ -406,7 +416,7 @@ public final class Bitmap implements Parcelable {
|
||||
* This configuration may be useful when using opaque bitmaps
|
||||
* that do not require high color fidelity.
|
||||
*/
|
||||
RGB_565 (4),
|
||||
RGB_565 (3),
|
||||
|
||||
/**
|
||||
* Each pixel is stored on 2 bytes. The three RGB color channels
|
||||
@@ -428,7 +438,7 @@ public final class Bitmap implements Parcelable {
|
||||
* it is advised to use {@link #ARGB_8888} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
ARGB_4444 (5),
|
||||
ARGB_4444 (4),
|
||||
|
||||
/**
|
||||
* Each pixel is stored on 4 bytes. Each channel (RGB and alpha
|
||||
@@ -438,13 +448,13 @@ public final class Bitmap implements Parcelable {
|
||||
* This configuration is very flexible and offers the best
|
||||
* quality. It should be used whenever possible.
|
||||
*/
|
||||
ARGB_8888 (6);
|
||||
ARGB_8888 (5);
|
||||
|
||||
final int nativeInt;
|
||||
|
||||
@SuppressWarnings({"deprecation"})
|
||||
private static Config sConfigs[] = {
|
||||
null, null, ALPHA_8, null, RGB_565, ARGB_4444, ARGB_8888
|
||||
null, ALPHA_8, null, RGB_565, ARGB_4444, ARGB_8888
|
||||
};
|
||||
|
||||
Config(int ni) {
|
||||
@@ -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(long nativeBitmap);
|
||||
private static native boolean nativeHasAlpha(long nativeBitmap);
|
||||
private static native void nativeSetHasAlpha(long nativeBitmap, boolean hasAlpha);
|
||||
private static native void nativeSetAlphaAndPremultiplied(long nBitmap, boolean hasAlpha,
|
||||
boolean isPremul);
|
||||
private static native boolean nativeHasMipMap(long nativeBitmap);
|
||||
private static native void nativeSetHasMipMap(long nativeBitmap, boolean hasMipMap);
|
||||
private static native boolean nativeSameAs(long nativeBitmap0, long nativeBitmap1);
|
||||
|
||||
Reference in New Issue
Block a user