Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hxd/BitmapData.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package hxd;

#if js
#if js
typedef BitmapInnerData = js.html.CanvasRenderingContext2D;
#else
typedef BitmapInnerData = BitmapInnerDataImpl;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hxd/Pixels.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion hxd/fmt/fbx/HMDOut.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions hxd/res/Image.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -453,15 +453,15 @@ 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;
}

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;
Expand Down Expand Up @@ -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;
Expand Down
28 changes: 28 additions & 0 deletions hxd/tools/Mikktspace.hx
Original file line number Diff line number Diff line change
@@ -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
}