Skip to content

Commit 2c34b37

Browse files
author
Ulysse Mizrahi
committed
reduce memory footprint of bitmap copy
1 parent 5b7ff22 commit 2c34b37

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

android/src/main/java/fr/greweb/rnwebgl/RNWebGLTextureBitmap.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@ public class RNWebGLTextureBitmap extends RNWebGLTexture implements Runnable {
1616
public RNWebGLTextureBitmap(ReadableMap config, Bitmap source) {
1717
super(config, source.getWidth(), source.getHeight());
1818
boolean yflip = config.hasKey("yflip") && config.getBoolean("yflip");
19-
Bitmap src;
2019
if (yflip) {
2120
Matrix matrix = new Matrix();
2221
matrix.postScale(1, -1);
23-
src = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
24-
src.setHasAlpha(source.hasAlpha());
22+
bitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
23+
bitmap.setHasAlpha(source.hasAlpha());
24+
} else {
25+
bitmap = source.copy(source.getConfig(), source.isMutable());
2526
}
26-
else {
27-
src = source;
28-
}
29-
bitmap = src.copy(src.getConfig(), src.isMutable());
3027
this.runOnGLThread(this);
3128
}
3229

0 commit comments

Comments
 (0)