From 7c82e7edc10645e86c27d6389c58aa92a0164c75 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Jan 2025 17:21:08 +0100 Subject: [PATCH 1/4] Add FlxGraphic.dump --- flixel/graphics/FlxGraphic.hx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/flixel/graphics/FlxGraphic.hx b/flixel/graphics/FlxGraphic.hx index 6dbf70adfc..f68c1a50a3 100644 --- a/flixel/graphics/FlxGraphic.hx +++ b/flixel/graphics/FlxGraphic.hx @@ -421,7 +421,22 @@ class FlxGraphic implements IFlxDestroyable if (newBitmap != null) bitmap = newBitmap; } - + + /** + * Frees the software image buffer for this graphic's `BitmapData`. + * This can significantly reduce RAM usage at the cost of not being able to draw on the graphic. + * + * Note that this operation might not complete immediately; + * it might take a bit for the garbage collector to collect the bitmap. + * + * @see `openfl.display.BitmapData.disposeImage()` + */ + public function dump():Void + { + if (bitmap != null) + bitmap.disposeImage(); + } + @:deprecated("`undump` is deprecated, use `refresh`") public function undump():Void { From 7ac1bdb23124df9720135a05961fdea64a5c6048 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Feb 2025 22:06:48 +0100 Subject: [PATCH 2/4] dump -> freeImageBuffer --- flixel/graphics/FlxGraphic.hx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flixel/graphics/FlxGraphic.hx b/flixel/graphics/FlxGraphic.hx index f68c1a50a3..eefb40c0c4 100644 --- a/flixel/graphics/FlxGraphic.hx +++ b/flixel/graphics/FlxGraphic.hx @@ -423,15 +423,15 @@ class FlxGraphic implements IFlxDestroyable } /** - * Frees the software image buffer for this graphic's `BitmapData`. + * If possible, frees the software image buffer for this graphic's `BitmapData`. * This can significantly reduce RAM usage at the cost of not being able to draw on the graphic. + * Call `FlxGraphic.refresh()` to refresh this graphic's `BitmapData` and restore drawing functionality. * - * Note that this operation might not complete immediately; - * it might take a bit for the garbage collector to collect the bitmap. + * Note that the buffer may not be cleaned up immediately. * * @see `openfl.display.BitmapData.disposeImage()` */ - public function dump():Void + public function freeImageBuffer():Void { if (bitmap != null) bitmap.disposeImage(); From 82581df48e6c81f7ab669663e05a2b169706a945 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Feb 2025 22:23:42 +0100 Subject: [PATCH 3/4] Add FLX_FREE_IMAGE_BUFFER --- flixel/graphics/FlxGraphic.hx | 4 ++++ flixel/system/macros/FlxDefines.hx | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/flixel/graphics/FlxGraphic.hx b/flixel/graphics/FlxGraphic.hx index eefb40c0c4..e4f2ca892f 100644 --- a/flixel/graphics/FlxGraphic.hx +++ b/flixel/graphics/FlxGraphic.hx @@ -633,6 +633,10 @@ class FlxGraphic implements IFlxDestroyable FlxG.log.warn('Graphic dimensions (${width}x${height}) exceed the maximum allowed size (${max}x${max}), which may cause rendering issues.'); } #end + + #if FLX_FREE_IMAGE_BUFFER + freeImageBuffer(); + #end } return value; diff --git a/flixel/system/macros/FlxDefines.hx b/flixel/system/macros/FlxDefines.hx index 71eafd21c9..fad7d94952 100644 --- a/flixel/system/macros/FlxDefines.hx +++ b/flixel/system/macros/FlxDefines.hx @@ -58,6 +58,12 @@ private enum UserDefines * If this flag is set to any string, that is used for the file extension */ FLX_DEFAULT_SOUND_EXT; + /** + * If enabled, FlxGraphic instances will automatically call `FlxGraphic.freeImageBuffer()`. + * This significantly decreases RAM usage but makes the bitmap uneditable. + * Call `FlxGraphic.refresh()` to restore functionality for drawing on the bitmap. + */ + FLX_FREE_IMAGE_BUFFER; } /** From cb3e63dbd034e19b2e53aa62c11c9bc6ceb81fc5 Mon Sep 17 00:00:00 2001 From: ACrazyTown <47027981+ACrazyTown@users.noreply.github.com> Date: Thu, 10 Apr 2025 16:38:28 +0200 Subject: [PATCH 4/4] Revert "Add FLX_FREE_IMAGE_BUFFER" This reverts commit 82581df48e6c81f7ab669663e05a2b169706a945. --- flixel/graphics/FlxGraphic.hx | 4 ---- flixel/system/macros/FlxDefines.hx | 6 ------ 2 files changed, 10 deletions(-) diff --git a/flixel/graphics/FlxGraphic.hx b/flixel/graphics/FlxGraphic.hx index e4f2ca892f..eefb40c0c4 100644 --- a/flixel/graphics/FlxGraphic.hx +++ b/flixel/graphics/FlxGraphic.hx @@ -633,10 +633,6 @@ class FlxGraphic implements IFlxDestroyable FlxG.log.warn('Graphic dimensions (${width}x${height}) exceed the maximum allowed size (${max}x${max}), which may cause rendering issues.'); } #end - - #if FLX_FREE_IMAGE_BUFFER - freeImageBuffer(); - #end } return value; diff --git a/flixel/system/macros/FlxDefines.hx b/flixel/system/macros/FlxDefines.hx index fad7d94952..71eafd21c9 100644 --- a/flixel/system/macros/FlxDefines.hx +++ b/flixel/system/macros/FlxDefines.hx @@ -58,12 +58,6 @@ private enum UserDefines * If this flag is set to any string, that is used for the file extension */ FLX_DEFAULT_SOUND_EXT; - /** - * If enabled, FlxGraphic instances will automatically call `FlxGraphic.freeImageBuffer()`. - * This significantly decreases RAM usage but makes the bitmap uneditable. - * Call `FlxGraphic.refresh()` to restore functionality for drawing on the bitmap. - */ - FLX_FREE_IMAGE_BUFFER; } /**