Created
September 21, 2015 23:04
-
-
Save james4k/ee243159edf94817c28c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/openfl/display/BitmapData.hx b/openfl/display/BitmapData.hx | |
index d373ed4..fc4ebf5 100644 | |
--- a/openfl/display/BitmapData.hx | |
+++ b/openfl/display/BitmapData.hx | |
@@ -159,6 +159,7 @@ class BitmapData implements IBitmapDrawable { | |
@:noCompletion private var __buffer:GLBuffer; | |
@:noCompletion private var __isValid:Bool; | |
@:noCompletion private var __surface:CairoSurface; | |
+ @:noCompletion private var __surfaceFinalizer:BitmapDataSurfaceFinalizer; | |
@:noCompletion private var __texture:GLTexture; | |
@:noCompletion private var __textureImage:Image; | |
@:noCompletion private var __framebuffer:FilterTexture; | |
@@ -1139,12 +1140,24 @@ class BitmapData implements IBitmapDrawable { | |
if (__surface == null) { | |
__surface = CairoImageSurface.fromImage (image); | |
+ __surfaceFinalizer = new BitmapDataSurfaceFinalizer (this); | |
} | |
return __surface; | |
} | |
+ | |
+ | |
+ public function destroySurface ():Void { | |
+ | |
+ if (__surface != null) { | |
+ __surface.destroy (); | |
+ __surface = null; | |
+ __surfaceFinalizer = null; | |
+ } | |
+ | |
+ } | |
@:noCompletion @:dox(hide) public function getTexture (gl:GLRenderContext):GLTexture { | |
@@ -2467,6 +2480,27 @@ class BitmapData implements IBitmapDrawable { | |
} | |
+#if !macro | |
+@:build(lime.system.CFFI.build()) | |
+#end | |
+ | |
+@:noCompletion @:dox(hide) private class BitmapDataSurfaceFinalizer { | |
+ | |
+ | |
+ var b:BitmapData; | |
+ | |
+ public function new (b:BitmapData) { | |
+ this.b = b; | |
+ } | |
+ | |
+ @:finalizer private function finalize () { | |
+ b.destroySurface (); | |
+ } | |
+ | |
+ | |
+} | |
+ | |
+ | |
#else | |
typedef BitmapData = openfl._legacy.display.BitmapData; | |
#end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment