Skip to content

Commit 2ba7381

Browse files
committed
use reconfigure() when bitmap has enough space
1 parent d81f0b2 commit 2ba7381

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/src/processing/a2d/PGraphicsAndroid2D.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,12 @@ public void requestDraw() {
183183

184184
protected Canvas checkCanvas() {
185185
if ((canvas == null || sized) && (useBitmap || !primaryGraphics)) {
186-
if (bitmap != null) bitmap.recycle();
187-
bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
186+
if (bitmap == null || bitmap.getWidth() * bitmap.getHeight() < width * height) {
187+
if (bitmap != null) bitmap.recycle();
188+
bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
189+
} else {
190+
bitmap.reconfigure(width, height, bitmap.getConfig());
191+
}
188192
canvas = new Canvas(bitmap);
189193
sized = false;
190194
}

0 commit comments

Comments
 (0)