Loading graphics/java/android/graphics/RecordingCanvas.java +3 −18 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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(); Loading @@ -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); } Loading Loading @@ -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 Loading services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +3 −18 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } if (!success) { wallpaper.cropFile.delete(); Loading @@ -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); } Loading Loading @@ -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); Loading Loading
graphics/java/android/graphics/RecordingCanvas.java +3 −18 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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(); Loading @@ -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); } Loading Loading @@ -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 Loading
services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +3 −18 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } if (!success) { wallpaper.cropFile.delete(); Loading @@ -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); } Loading Loading @@ -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); Loading