Ver Fonte

[hl] Move hl.Format into lib format/heaps (#1250)

Yuxiao Mao há 9 meses atrás
pai
commit
e982664311
5 ficheiros alterados com 36 adições e 8 exclusões
  1. 2 2
      hxd/BitmapData.hx
  2. 1 1
      hxd/Pixels.hx
  3. 1 1
      hxd/fmt/fbx/HMDOut.hx
  4. 4 4
      hxd/res/Image.hx
  5. 28 0
      hxd/tools/Mikktspace.hx

+ 2 - 2
hxd/BitmapData.hx

@@ -1,6 +1,6 @@
 package hxd;
 
-#if js 
+#if js
 typedef BitmapInnerData = js.html.CanvasRenderingContext2D;
 #else
 typedef BitmapInnerData = BitmapInnerDataImpl;
@@ -97,7 +97,7 @@ class BitmapData {
 		if( x < 0 || y < 0 || width < 0 || height < 0 || srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 ||
 			x + width > this.width || y + height > this.height || srcX + srcWidth > src.width || srcY + srcHeight > src.height )
 			throw "Outside bounds";
-		hl.Format.scaleImage(
+		format.hl.Native.scaleImage(
 			data.pixels, (x + y * this.width) << 2, this.width<<2, width, height,
 			src.data.pixels, (srcX + srcY * src.width)<<2, src.width<<2, srcWidth, srcHeight,
 			smooth?1:0

+ 1 - 1
hxd/Pixels.hx

@@ -397,7 +397,7 @@ class Pixels {
 		case [S3TC(ver),_]:
 			if( (width|height)&3 != 0 ) throw "Texture size should be 4x4 multiple";
 			var out = haxe.io.Bytes.alloc(width * height * 4);
-			if( !hl.Format.decodeDXT((this.bytes:hl.Bytes).offset(this.offset), out, width, height, ver) )
+			if( !std.format.hl.Native.decodeDXT((this.bytes:hl.Bytes).offset(this.offset), out, width, height, ver) )
 				throw "Failed to decode DDS";
 			offset = 0;
 			this.bytes = out;

+ 1 - 1
hxd/fmt/fbx/HMDOut.hx

@@ -43,7 +43,7 @@ class HMDOut extends BaseLibrary {
 			throw "Need UVs to build tangents" + (geom.lib != null ? ' in ${geom.lib.fileName}' : '');
 
 		#if (hl && !hl_disable_mikkt)
-		var m = new hl.Format.Mikktspace();
+		var m = new hxd.tools.Mikktspace();
 		m.buffer = new hl.Bytes(8 * 4 * index.vidx.length);
 		m.stride = 8;
 		m.xPos = 0;

+ 4 - 4
hxd/res/Image.hx

@@ -444,7 +444,7 @@ class Image extends Resource {
 	#if hl
 	static function decodeJPG(src:haxe.io.Bytes, width:Int, height:Int, requestedFmt:hxd.PixelFormat) {
 		var outFmt = requestedFmt;
-		var ifmt:hl.Format.PixelFormat = switch (requestedFmt) {
+		var ifmt:format.hl.Native.PixelFormat = switch (requestedFmt) {
 			case RGBA: RGBA;
 			case BGRA: BGRA;
 			case ARGB: ARGB;
@@ -453,7 +453,7 @@ class Image extends Resource {
 				BGRA;
 		};
 		var dst = haxe.io.Bytes.alloc(width * height * 4);
-		if (!hl.Format.decodeJPG(src.getData(), src.length, dst.getData(), width, height, width * 4, ifmt, 0))
+		if (!format.hl.Native.decodeJPG(src.getData(), src.length, dst.getData(), width, height, width * 4, ifmt, 0))
 			return null;
 		var pix = new hxd.Pixels(width, height, dst, outFmt);
 		return pix;
@@ -461,7 +461,7 @@ class Image extends Resource {
 
 	static function decodePNG(src:haxe.io.Bytes, width:Int, height:Int, requestedFmt:hxd.PixelFormat) {
 		var outFmt = requestedFmt;
-		var ifmt:hl.Format.PixelFormat = switch (requestedFmt) {
+		var ifmt:format.hl.Native.PixelFormat = switch (requestedFmt) {
 			case RGBA: RGBA;
 			case BGRA: BGRA;
 			case ARGB: ARGB;
@@ -491,7 +491,7 @@ class Image extends Resource {
 			default:
 		}
 		var dst = haxe.io.Bytes.alloc(width * height * pxsize);
-		if (!hl.Format.decodePNG(src.getData(), src.length, dst.getData(), width, height, width * stride, ifmt, 0))
+		if (!format.hl.Native.decodePNG(src.getData(), src.length, dst.getData(), width, height, width * stride, ifmt, 0))
 			return null;
 		var pix = new hxd.Pixels(width, height, dst, outFmt);
 		return pix;

+ 28 - 0
hxd/tools/Mikktspace.hx

@@ -0,0 +1,28 @@
+package hxd.tools;
+
+class Mikktspace {
+	public var buffer:hl.BytesAccess<Single>;
+	public var stride:Int;
+	public var xPos:Int;
+	public var normalPos:Int;
+	public var uvPos:Int;
+	public var tangents:hl.BytesAccess<Single>;
+	public var tangentStride:Int;
+	public var tangentPos:Int;
+	public var indexes:hl.BytesAccess<Int>;
+	public var indices:Int;
+
+	public function new() {}
+
+	#if hl
+	public function compute(threshold = 180.) {
+		if (!_compute(this, threshold))
+			throw "assert";
+	}
+
+	@:hlNative("fmt", "compute_mikkt_tangents")
+	static function _compute(m:Dynamic, threshold:Float):Bool {
+		return false;
+	}
+	#end
+}