gamnit: free images pixel data from RAM after loading it in GPU memory
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 14 Nov 2017 04:27:45 +0000 (23:27 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 27 Nov 2017 23:57:24 +0000 (18:57 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/android/assets_and_resources.nit
lib/gamnit/display_android.nit
lib/gamnit/display_linux.nit

index 40dace2..930bc17 100644 (file)
@@ -327,6 +327,10 @@ private extern class NativeBitmap in "Java" `{ android.graphics.Bitmap `}
                return self.hasAlpha();
        `}
 
+       fun recycle in "Java" `{
+               self.recycle();
+       `}
+
        # HACK for bug #845
        redef fun new_global_ref import sys, Sys.jni_env `{
                Sys sys = NativeBitmap_sys(self);
index b14cb33..6b069d3 100644 (file)
@@ -74,6 +74,8 @@ redef class TextureAsset
                var pixels = buf.native_array
 
                load_from_pixels(pixels, bmp.width, bmp.height, gl_RGBA)
+               buf.destroy
+               bmp.recycle
 
                jni_env.pop_local_frame
        end
index dcfd963..e9af008 100644 (file)
@@ -139,5 +139,7 @@ redef class TextureAsset
                var pixels = surface.pixels
 
                load_from_pixels(pixels, surface.w, surface.h, format)
+
+               surface.free
        end
 end