فهرست منبع

minor hxd.Pixels change

Nicolas Cannasse 9 سال پیش
والد
کامیت
c681a44916
3فایلهای تغییر یافته به همراه10 افزوده شده و 7 حذف شده
  1. 1 1
      h3d/impl/GlDriver.hx
  2. 1 1
      h3d/impl/Stage3dDriver.hx
  3. 8 5
      hxd/Pixels.hx

+ 1 - 1
h3d/impl/GlDriver.hx

@@ -781,7 +781,7 @@ class GlDriver extends Driver {
 			throw "Can't capture main render buffer in GL";
 		#if (js || hl)
 		gl.readPixels(0, 0, pixels.width, pixels.height, GL.RGBA, GL.UNSIGNED_BYTE, @:privateAccess pixels.bytes.b);
-		pixels.format = RGBA;
+		@:privateAccess pixels.innerFormat = RGBA;
 		pixels.flags.set(FlipY);
 		#end
 	}

+ 1 - 1
h3d/impl/Stage3dDriver.hx

@@ -198,7 +198,7 @@ class Stage3dDriver extends Driver {
 		var b = pixels.bytes.getData();
 		b.position = 0;
 		b.writeBytes(pix, 0, pixels.width * pixels.height * 4);
-		pixels.format = ARGB;
+		@:privateAccess pixels.innerFormat = ARGB;
 		pixels.flags.set(AlphaPremultiplied);
 	}
 

+ 8 - 5
hxd/Pixels.hx

@@ -37,18 +37,19 @@ abstract PixelsARGB(Pixels) to Pixels {
 @:noDebug
 class Pixels {
 	public var bytes : haxe.io.Bytes;
-	public var format(default,set) : PixelFormat;
+	public var format(get,never) : PixelFormat;
 	public var width : Int;
 	public var height : Int;
 	public var offset : Int;
 	public var flags: haxe.EnumFlags<Flags>;
 	var bpp : Int;
+	var innerFormat(default, set) : PixelFormat;
 
 	public function new(width : Int, height : Int, bytes : haxe.io.Bytes, format : hxd.PixelFormat, offset = 0) {
 		this.width = width;
 		this.height = height;
 		this.bytes = bytes;
-		this.format = format;
+		this.innerFormat = format;
 		this.offset = offset;
 	}
 
@@ -60,8 +61,10 @@ class Pixels {
 		return (v & 0xFF00FF00) | ((v << 16) & 0xFF0000) | ((v >> 16) & 0xFF);
 	}
 
-	function set_format(fmt) {
-		this.format = fmt;
+	inline function get_format() return innerFormat;
+
+	function set_innerFormat(fmt) {
+		this.innerFormat = fmt;
 		bpp = bytesPerPixel(fmt);
 		return fmt;
 	}
@@ -289,7 +292,7 @@ class Pixels {
 		default:
 			throw "Cannot convert from " + format + " to " + target;
 		}
-		format = target;
+		innerFormat = target;
 	}
 
 	public function getPixel(x, y) : Int {