Merge "Restore MAX_BITMAP_SIZE"

This commit is contained in:
Leon Scroggins
2020-05-20 13:45:58 +00:00
committed by Android (Google) Code Review

View File

@@ -39,6 +39,8 @@ public final class RecordingCanvas extends BaseRecordingCanvas {
// view hierarchy because display lists are generated recursively.
private static final int POOL_LIMIT = 25;
private static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; // 100 MB
private static final SynchronizedPool<RecordingCanvas> sPool =
new SynchronizedPool<>(POOL_LIMIT);
@@ -260,6 +262,18 @@ public final class RecordingCanvas extends BaseRecordingCanvas {
paint.getNativeContainer());
}
/** @hide */
@Override
protected void throwIfCannotDraw(Bitmap bitmap) {
super.throwIfCannotDraw(bitmap);
int bitmapSize = bitmap.getByteCount();
if (bitmapSize > MAX_BITMAP_SIZE) {
throw new RuntimeException(
"Canvas: trying to draw too large(" + bitmapSize + "bytes) bitmap.");
}
}
// ------------------ Fast JNI ------------------------
@FastNative