Преглед на файлове

prepare refactor for haxe 4-rc2

Nicolas Cannasse преди 6 години
родител
ревизия
471e161aae
променени са 7 файла, в които са добавени 31 реда и са изтрити 18 реда
  1. 8 10
      h3d/impl/GlDriver.hx
  2. 1 1
      h3d/shader/Buffers.hx
  3. 5 4
      hxd/FloatBuffer.hx
  4. 1 1
      hxd/fmt/fbx/HMDOut.hx
  5. 14 0
      hxd/impl/TypedArray.hx
  6. 1 1
      hxd/impl/UncheckedBytes.hx
  7. 1 1
      hxd/snd/Mp3Data.hx

+ 8 - 10
h3d/impl/GlDriver.hx

@@ -7,9 +7,7 @@ import h3d.mat.Data;
 #if (js||cpp||hlsdl||usegl)
 
 #if js
-import js.html.Uint16Array;
-import js.html.Uint8Array;
-import js.html.Float32Array;
+import hxd.impl.TypedArray;
 private typedef GL = js.html.webgl.GL;
 private extern class GL2 extends js.html.webgl.GL {
 	// webgl2
@@ -1134,9 +1132,9 @@ class GlDriver extends Driver {
 		gl.texImage2D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, 0, getChannels(t.t), t.t.pixelFmt, bytesToUint8Array(pixels.bytes));
 		#elseif js
 		var buffer = switch( t.format ) {
-		case RGBA32F, R32F, RG32F, RGB32F: new js.html.Float32Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset);
-		case RGBA16F, R16F, RG16F, RGB16F: new js.html.Uint16Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset);
-		case RGB10A2, RG11B10UF: new js.html.Uint32Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset);
+		case RGBA32F, R32F, RG32F, RGB32F: new Float32Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset);
+		case RGBA16F, R16F, RG16F, RGB16F: new Uint16Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset);
+		case RGB10A2, RG11B10UF: new Uint32Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset);
 		default: bytesToUint8Array(pixels.bytes,pixels.offset);
 		}
 		if( t.format.match(S3TC(_)) )
@@ -1611,11 +1609,11 @@ class GlDriver extends Driver {
 			throw "Can't capture main render buffer in GL";
 		discardError();
 		#if js
-		var buffer : js.html.ArrayBufferView = @:privateAccess pixels.bytes.b;
+		var buffer : ArrayBufferView = @:privateAccess pixels.bytes.b;
 		switch( curTarget.format ) {
-		case RGBA32F, R32F, RG32F, RGB32F: buffer = new js.html.Float32Array(buffer.buffer);
-		case RGBA16F, R16F, RG16F, RGB16F: buffer = new js.html.Uint16Array(buffer.buffer);
-		case RGB10A2, RG11B10UF: buffer = new js.html.Uint32Array(buffer.buffer);
+		case RGBA32F, R32F, RG32F, RGB32F: buffer = new Float32Array(buffer.buffer);
+		case RGBA16F, R16F, RG16F, RGB16F: buffer = new Uint16Array(buffer.buffer);
+		case RGB10A2, RG11B10UF: buffer = new Uint32Array(buffer.buffer);
 		default:
 		}
 		#else

+ 1 - 1
h3d/shader/Buffers.hx

@@ -7,7 +7,7 @@ package h3d.shader;
 	public var Buffers = 3;
 }
 
-typedef ShaderBufferData = #if js js.html.Float32Array #else haxe.ds.Vector<hxd.impl.Float32> #end;
+typedef ShaderBufferData = hxd.impl.TypedArray.Float32Array;
 
 class ShaderBuffers {
 

+ 5 - 4
hxd/FloatBuffer.hx

@@ -1,20 +1,21 @@
 package hxd;
+import hxd.impl.TypedArray;
 
 private typedef InnerData = #if flash flash.Vector<Float> #elseif js Float32Expand #else Array<hxd.impl.Float32> #end
 
 #if js
-private abstract Float32Expand({ pos : Int, array : js.html.Float32Array }) {
+private abstract Float32Expand({ pos : Int, array : hxd.impl.TypedArray.Float32Array }) {
 
 	public var length(get, set) : Int;
 
 	public function new(length) {
-		this = { pos : 0, array : new js.html.Float32Array(new js.html.ArrayBuffer(length<<2)) };
+		this = { pos : 0, array : new Float32Array(new ArrayBuffer(length<<2)) };
 	}
 
 	inline function get_length() return this.pos;
 	inline function set_length(v:Int) {
 		if( length != v ) {
-			var newArray = new js.html.Float32Array(v);
+			var newArray = new Float32Array(v);
 			newArray.set(this.array);
 			this.array = newArray;
 		}
@@ -26,7 +27,7 @@ private abstract Float32Expand({ pos : Int, array : js.html.Float32Array }) {
 		if( this.pos == this.array.length ) {
 			var newSize = this.array.length << 1;
 			if( newSize < 128 ) newSize = 128;
-			var newArray = new js.html.Float32Array(newSize);
+			var newArray = new Float32Array(newSize);
 			newArray.set(this.array);
 			this.array = newArray;
 		}

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

@@ -182,7 +182,7 @@ class HMDOut extends BaseLibrary {
 			for( _ in skin.splitJoints ) ibufs.push(new hxd.IndexBuffer());
 
 		g.bounds = new h3d.col.Bounds();
-		var tmpBuf = #if js new js.html.Float32Array(stride) #else new haxe.ds.Vector<hxd.impl.Float32>(stride) #end;
+		var tmpBuf = new hxd.impl.TypedArray.Float32Array(stride);
 		var vertexRemap = new Array<Int>();
 		var index = geom.getPolygons();
 		var count = 0, matPos = 0, stri = 0;

+ 14 - 0
hxd/impl/TypedArray.hx

@@ -0,0 +1,14 @@
+package hxd.impl;
+
+#if js
+
+typedef Float32Array = js.html.Float32Array;
+typedef Uint16Array = js.html.Uint16Array;
+typedef Uint8Array = js.html.Uint8Array;
+typedef ArrayBuffer = js.html.ArrayBuffer;
+typedef Uint32Array = js.html.Uint32Array;
+typedef ArrayBufferView = js.html.ArrayBufferView;
+
+#else
+typedef Float32Array = haxe.ds.Vector<Float32>;
+#end

+ 1 - 1
hxd/impl/UncheckedBytes.hx

@@ -1,6 +1,6 @@
 package hxd.impl;
 
-private typedef InnerData = #if hl hl.Bytes #elseif js js.html.Uint8Array #else haxe.io.BytesData #end
+private typedef InnerData = #if hl hl.Bytes #elseif js TypedArray.Uint8Array #else haxe.io.BytesData #end
 
 abstract UncheckedBytes(InnerData) {
 

+ 1 - 1
hxd/snd/Mp3Data.hx

@@ -125,7 +125,7 @@ class Mp3Data extends Data {
 		}
 
 		var right = buf.numberOfChannels < 2 ? left : buf.getChannelData(1);
-		var join = new js.html.Float32Array(left.length * 2);
+		var join = new hxd.impl.TypedArray.Float32Array(left.length * 2);
 		var w = 0;
 		for( i in 0...buf.length ) {
 			join[w++] = left[i];