浏览代码

add dispose method

bstouls 9 年之前
父节点
当前提交
42fe00518f
共有 1 个文件被更改,包括 20 次插入2 次删除
  1. 20 2
      h3d/mat/BigTexture.hx

+ 20 - 2
h3d/mat/BigTexture.hx

@@ -59,6 +59,24 @@ class BigTexture {
 		pending = [];
 	}
 
+	public function dispose() {
+		if( tex != null ) {
+			tex.dispose();
+			tex = null;
+		}
+		if( allPixels != null ) {
+			allPixels.dispose();
+			allPixels = null;
+		}
+		pending = [];
+		if( waitTimer != null ) {
+			waitTimer.stop();
+			waitTimer = null;
+		}
+		isDone = false;
+		space = null;
+	}
+
 	function initPixels() {
 		if( allPixels == null )
 			allPixels = hxd.Pixels.alloc(size, size, BGRA);
@@ -99,7 +117,7 @@ class BigTexture {
 		return split(q.tl, sw, sh, rw, rh);
 	}
 
-	function allocPos( t : hxd.res.Image, w : Int, h : Int ) {
+	function allocPos( w : Int, h : Int ) {
 		var q = findBest(space, w, h);
 		if( q == null )
 			return null;
@@ -133,7 +151,7 @@ class BigTexture {
 
 	public function add( t : hxd.res.Image ) {
 		var tsize = t.getSize();
-		var q = allocPos(t,tsize.width,tsize.height);
+		var q = allocPos(tsize.width,tsize.height);
 		if( q == null )
 			return null;
 		var x = q.x, y = q.y;