am 96160dea: am 8e645d58: am 649c3c44: am 7290d93d: Merge "Yell loudly about undefined behind in Bitmap, but work anyway" into mnc-dev
* commit '96160dea490ade7ac6ba106457c9ce3f29d719d9':
Yell loudly about undefined behind in Bitmap, but work anyway
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index 670d3c0..fbe3ece 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -218,7 +218,6 @@
}
const SkImageInfo& Bitmap::info() const {
- assertValid();
return mPixelRef->info();
}
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 8ad7c12..3e4d93b 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -23,6 +23,7 @@
import android.os.Parcelable;
import android.os.Trace;
import android.util.DisplayMetrics;
+import android.util.Log;
import dalvik.system.VMRuntime;
@@ -33,6 +34,8 @@
import java.nio.ShortBuffer;
public final class Bitmap implements Parcelable {
+ private static final String TAG = "Bitmap";
+
/**
* Indicates that the bitmap was created for an unknown pixel density.
*
@@ -159,6 +162,9 @@
* @see #DENSITY_NONE
*/
public int getDensity() {
+ if (mRecycled) {
+ Log.w(TAG, "Called getDensity() on a recycle()'d bitmap! This is undefined behavior!");
+ }
return mDensity;
}
@@ -330,7 +336,9 @@
* @return The current generation ID for this bitmap.
*/
public int getGenerationId() {
- if (mRecycled) return 0;
+ if (mRecycled) {
+ Log.w(TAG, "Called getGenerationId() on a recycle()'d bitmap! This is undefined behavior!");
+ }
return nativeGenerationId(mFinalizer.mNativeBitmap);
}
@@ -1057,7 +1065,9 @@
* @see BitmapFactory.Options#inPremultiplied
*/
public final boolean isPremultiplied() {
- if (mRecycled) return false;
+ if (mRecycled) {
+ Log.w(TAG, "Called isPremultiplied() on a recycle()'d bitmap! This is undefined behavior!");
+ }
return nativeIsPremultiplied(mFinalizer.mNativeBitmap);
}
@@ -1089,11 +1099,17 @@
/** Returns the bitmap's width */
public final int getWidth() {
+ if (mRecycled) {
+ Log.w(TAG, "Called getWidth() on a recycle()'d bitmap! This is undefined behavior!");
+ }
return mWidth;
}
/** Returns the bitmap's height */
public final int getHeight() {
+ if (mRecycled) {
+ Log.w(TAG, "Called getHeight() on a recycle()'d bitmap! This is undefined behavior!");
+ }
return mHeight;
}
@@ -1176,7 +1192,9 @@
* @return number of bytes between rows of the native bitmap pixels.
*/
public final int getRowBytes() {
- if (mRecycled) return 0;
+ if (mRecycled) {
+ Log.w(TAG, "Called getRowBytes() on a recycle()'d bitmap! This is undefined behavior!");
+ }
return nativeRowBytes(mFinalizer.mNativeBitmap);
}
@@ -1220,7 +1238,9 @@
* that config, otherwise return null.
*/
public final Config getConfig() {
- if (mRecycled) return Config.ARGB_8888;
+ if (mRecycled) {
+ Log.w(TAG, "Called getConfig() on a recycle()'d bitmap! This is undefined behavior!");
+ }
return Config.nativeToConfig(nativeConfig(mFinalizer.mNativeBitmap));
}
@@ -1233,7 +1253,9 @@
* it will return true by default.
*/
public final boolean hasAlpha() {
- if (mRecycled) return false;
+ if (mRecycled) {
+ Log.w(TAG, "Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior!");
+ }
return nativeHasAlpha(mFinalizer.mNativeBitmap);
}
@@ -1270,7 +1292,9 @@
* @see #setHasMipMap(boolean)
*/
public final boolean hasMipMap() {
- if (mRecycled) return false;
+ if (mRecycled) {
+ Log.w(TAG, "Called hasMipMap() on a recycle()'d bitmap! This is undefined behavior!");
+ }
return nativeHasMipMap(mFinalizer.mNativeBitmap);
}