[engine] [cocos2d-x] [jsb-adapter] 适配引擎 v2.4.12 版本

This commit is contained in:
SmallMain
2023-10-30 22:32:32 +08:00
parent 2508616ad9
commit 0092eb9f05
787 changed files with 206249 additions and 422 deletions

View File

@@ -543,6 +543,7 @@ var downloaders = {
'.image' : downloadImage,
'.pvr': downloadArrayBuffer,
'.pkm': downloadArrayBuffer,
'.astc': downloadArrayBuffer,
// Audio
'.mp3' : downloadAudio,

View File

@@ -148,6 +148,7 @@ const producers = {
'.image' : createTexture,
'.pvr': createTexture,
'.pkm': createTexture,
'.astc': createTexture,
// Audio
'.mp3' : createAudioClip,

View File

@@ -263,6 +263,113 @@ var parser = {
}
})(),
parseASTCTex: (function () {
//= ==============//
// ASTC constants //
//= ==============//
// struct astc_header
// {
// uint8_t magic[4];
// uint8_t blockdim_x;
// uint8_t blockdim_y;
// uint8_t blockdim_z;
// uint8_t xsize[3]; // x-size = xsize[0] + xsize[1] + xsize[2]
// uint8_t ysize[3]; // x-size, y-size and z-size are given in texels;
// uint8_t zsize[3]; // block count is inferred
// };
const ASTC_MAGIC = 0x5CA1AB13;
const ASTC_HEADER_LENGTH = 16; // The header length
const ASTC_HEADER_MAGIC = 4;
const ASTC_HEADER_BLOCKDIM = 3;
const ASTC_HEADER_SIZE_X_BEGIN = 7;
const ASTC_HEADER_SIZE_Y_BEGIN = 10;
const ASTC_HEADER_SIZE_Z_BEGIN = 13;
function getASTCFormat (xdim, ydim) {
if (xdim === 4) {
return cc.Texture2D.PixelFormat.RGBA_ASTC_4x4;
} if (xdim === 5) {
if (ydim === 4) {
return cc.Texture2D.PixelFormat.RGBA_ASTC_5x4;
}
return cc.Texture2D.PixelFormat.RGBA_ASTC_5x5;
} if (xdim === 6) {
if (ydim === 5) {
return cc.Texture2D.PixelFormat.RGBA_ASTC_6x5;
}
return cc.Texture2D.PixelFormat.RGBA_ASTC_6x6;
} if (xdim === 8) {
if (ydim === 5) {
return cc.Texture2D.PixelFormat.RGBA_ASTC_8x5;
} if (ydim === 6) {
return cc.Texture2D.PixelFormat.RGBA_ASTC_8x6;
}
return cc.Texture2D.PixelFormat.RGBA_ASTC_8x8;
} if (xdim === 10) {
if (ydim === 5) {
return cc.Texture2D.PixelFormat.RGBA_ASTC_10x5;
} if (ydim === 6) {
return cc.Texture2D.PixelFormat.RGBA_ASTC_10x6;
} if (ydim === 8) {
return cc.Texture2D.PixelFormat.RGBA_ASTC_10x8;
}
return cc.Texture2D.PixelFormat.RGBA_ASTC_10x10;
}
if (ydim === 10) {
return cc.Texture2D.PixelFormat.RGBA_ASTC_12x10;
}
return cc.Texture2D.PixelFormat.RGBA_ASTC_12x12;
}
return function (file, options, onComplete) {
let err = null, out = null;
try {
const buffer = file instanceof ArrayBuffer ? file : file.buffer;
const header = new Uint8Array(buffer);
const magicval = header[0] + (header[1] << 8) + (header[2] << 16) + (header[3] << 24);
if (magicval !== ASTC_MAGIC) {
return new Error('Invalid magic number in ASTC header');
}
const xdim = header[ASTC_HEADER_MAGIC];
const ydim = header[ASTC_HEADER_MAGIC + 1];
const zdim = header[ASTC_HEADER_MAGIC + 2];
if ((xdim < 3 || xdim > 6 || ydim < 3 || ydim > 6 || zdim < 3 || zdim > 6)
&& (xdim < 4 || xdim === 7 || xdim === 9 || xdim === 11 || xdim > 12
|| ydim < 4 || ydim === 7 || ydim === 9 || ydim === 11 || ydim > 12 || zdim !== 1)) {
return new Error('Invalid block number in ASTC header');
}
const format = getASTCFormat(xdim, ydim);
const xsize = header[ASTC_HEADER_SIZE_X_BEGIN] + (header[ASTC_HEADER_SIZE_X_BEGIN + 1] << 8)
+ (header[ASTC_HEADER_SIZE_X_BEGIN + 2] << 16);
const ysize = header[ASTC_HEADER_SIZE_Y_BEGIN] + (header[ASTC_HEADER_SIZE_Y_BEGIN + 1] << 8)
+ (header[ASTC_HEADER_SIZE_Y_BEGIN + 2] << 16);
const zsize = header[ASTC_HEADER_SIZE_Z_BEGIN] + (header[ASTC_HEADER_SIZE_Z_BEGIN + 1] << 8)
+ (header[ASTC_HEADER_SIZE_Z_BEGIN + 2] << 16);
// buffer = buffer.slice(ASTC_HEADER_LENGTH, buffer.byteLength);
const astcData = new Uint8Array(buffer, ASTC_HEADER_LENGTH);
out = {
_data: astcData,
_compressed: true,
width: xsize,
height: ysize,
format,
};
} catch (e) {
err = e;
}
onComplete(err, out);
}
})(),
/*
* !#en
* Parse plist file
@@ -426,6 +533,7 @@ var parsers = {
'.image' : parser.parseImage,
'.pvr' : parser.parsePVRTex,
'.pkm' : parser.parsePKMTex,
'.astc' : parser.parseASTCTex,
// Audio
'.mp3' : parser.parseAudio,
'.ogg' : parser.parseAudio,