Remove instances of @hide from RecordingCanvas
Bug: 155905258 Test: make Remove MAX_BITMAP_SIZE. It was based on a limitation of the old renderer. Remove override of throwIfCannotDraw, which was only there for comparing the size of a Bitmap against MAX_BITMAP_SIZE and throwing if it was too big. Remove MAX_BITMAP_SIZE from WallpaperManagerService, which was a copy of the one in RecordingCanvas, and only there due to it. Mark obtain, recycle, and finishRecording as being used by the package. Change-Id: I141d6d79520871df1a3c2a9267ec872a8314ffdb
This commit is contained in:
@@ -39,9 +39,6 @@ public final class RecordingCanvas extends BaseRecordingCanvas {
|
||||
// view hierarchy because display lists are generated recursively.
|
||||
private static final int POOL_LIMIT = 25;
|
||||
|
||||
/** @hide */
|
||||
public static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; // 100 MB
|
||||
|
||||
private static final SynchronizedPool<RecordingCanvas> sPool =
|
||||
new SynchronizedPool<>(POOL_LIMIT);
|
||||
|
||||
@@ -52,7 +49,7 @@ public final class RecordingCanvas extends BaseRecordingCanvas {
|
||||
private int mWidth;
|
||||
private int mHeight;
|
||||
|
||||
/** @hide */
|
||||
/*package*/
|
||||
static RecordingCanvas obtain(@NonNull RenderNode node, int width, int height) {
|
||||
if (node == null) throw new IllegalArgumentException("node cannot be null");
|
||||
RecordingCanvas canvas = sPool.acquire();
|
||||
@@ -68,13 +65,13 @@ public final class RecordingCanvas extends BaseRecordingCanvas {
|
||||
return canvas;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
/*package*/
|
||||
void recycle() {
|
||||
mNode = null;
|
||||
sPool.release(this);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
/*package*/
|
||||
long finishRecording() {
|
||||
return nFinishRecording(mNativeCanvasWrapper);
|
||||
}
|
||||
@@ -263,18 +260,6 @@ 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
|
||||
|
||||
@@ -137,9 +137,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
|
||||
private static final boolean DEBUG = false;
|
||||
private static final boolean DEBUG_LIVE = true;
|
||||
|
||||
// This 100MB limitation is defined in RecordingCanvas.
|
||||
private static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024;
|
||||
|
||||
public static class Lifecycle extends SystemService {
|
||||
private IWallpaperManagerService mService;
|
||||
|
||||
@@ -657,14 +654,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
|
||||
// may be we can try to remove this optimized way in the future,
|
||||
// that means, we will always go into the 'else' block.
|
||||
|
||||
// This is just a quick estimation, may be smaller than it is.
|
||||
long estimateSize = options.outWidth * options.outHeight * 4;
|
||||
|
||||
// A bitmap over than MAX_BITMAP_SIZE will make drawBitmap() fail.
|
||||
// Please see: RecordingCanvas#throwIfCannotDraw.
|
||||
if (estimateSize < MAX_BITMAP_SIZE) {
|
||||
success = FileUtils.copyFile(wallpaper.wallpaperFile, wallpaper.cropFile);
|
||||
}
|
||||
success = FileUtils.copyFile(wallpaper.wallpaperFile, wallpaper.cropFile);
|
||||
|
||||
if (!success) {
|
||||
wallpaper.cropFile.delete();
|
||||
@@ -672,6 +662,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
// This is just a quick estimation, may be smaller than it is.
|
||||
long estimateSize = options.outWidth * options.outHeight * 4;
|
||||
Slog.v(TAG, "Null crop of new wallpaper, estimate size="
|
||||
+ estimateSize + ", success=" + success);
|
||||
}
|
||||
@@ -753,13 +745,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
|
||||
+ " h=" + finalCrop.getHeight());
|
||||
}
|
||||
|
||||
// A bitmap over than MAX_BITMAP_SIZE will make drawBitmap() fail.
|
||||
// Please see: RecordingCanvas#throwIfCannotDraw.
|
||||
if (finalCrop.getByteCount() > MAX_BITMAP_SIZE) {
|
||||
throw new RuntimeException(
|
||||
"Too large bitmap, limit=" + MAX_BITMAP_SIZE);
|
||||
}
|
||||
|
||||
f = new FileOutputStream(wallpaper.cropFile);
|
||||
bos = new BufferedOutputStream(f, 32*1024);
|
||||
finalCrop.compress(Bitmap.CompressFormat.JPEG, 100, bos);
|
||||
|
||||
Reference in New Issue
Block a user