pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
1 lines • 2.5 kB
Source Map (JSON)
{"version":3,"file":"fastCopy.mjs","sources":["../../../../../../src/rendering/renderers/shared/buffer/utils/fastCopy.ts"],"sourcesContent":["/**\n * Copies from one ArrayBuffer to another.\n * Uses Float64Array (8-byte), Float32Array (4-byte), or Uint8Array depending on alignment.\n * @param sourceBuffer - the array buffer to copy from\n * @param destinationBuffer - the array buffer to copy to\n * @param sourceOffset - the byte offset to start copying from (default 0)\n * @param byteLength - the number of bytes to copy (default: min of source available and destination size)\n * @category rendering\n * @advanced\n */\nexport function fastCopy(\n sourceBuffer: ArrayBuffer | ArrayBufferLike,\n destinationBuffer: ArrayBuffer | ArrayBufferLike,\n sourceOffset?: number,\n byteLength?: number\n): void\n{\n sourceOffset ??= 0;\n byteLength ??= Math.min(sourceBuffer.byteLength - sourceOffset, destinationBuffer.byteLength);\n\n if (!(sourceOffset & 7) && !(byteLength & 7))\n {\n // 8-byte aligned - use Float64Array (8x faster)\n const len = byteLength / 8;\n\n new Float64Array(destinationBuffer, 0, len).set(new Float64Array(sourceBuffer, sourceOffset, len));\n }\n else if (!(sourceOffset & 3) && !(byteLength & 3))\n {\n // 4-byte aligned - use Float32Array (4x faster)\n const len = byteLength / 4;\n\n new Float32Array(destinationBuffer, 0, len).set(new Float32Array(sourceBuffer, sourceOffset, len));\n }\n else\n {\n // Fall back to byte-by-byte copy\n new Uint8Array(destinationBuffer).set(new Uint8Array(sourceBuffer, sourceOffset, byteLength));\n }\n}\n"],"names":[],"mappings":";AAUO,SAAS,QAAA,CACZ,YAAA,EACA,iBAAA,EACA,YAAA,EACA,UAAA,EAEJ;AACI,EAAA,YAAA,KAAA,YAAA,GAAiB,CAAA,CAAA;AACjB,EAAA,UAAA,KAAA,UAAA,GAAe,KAAK,GAAA,CAAI,YAAA,CAAa,UAAA,GAAa,YAAA,EAAc,kBAAkB,UAAU,CAAA,CAAA;AAE5F,EAAA,IAAI,EAAE,YAAA,GAAe,CAAA,CAAA,IAAM,EAAE,aAAa,CAAA,CAAA,EAC1C;AAEI,IAAA,MAAM,MAAM,UAAA,GAAa,CAAA;AAEzB,IAAA,IAAI,YAAA,CAAa,iBAAA,EAAmB,CAAA,EAAG,GAAG,CAAA,CAAE,GAAA,CAAI,IAAI,YAAA,CAAa,YAAA,EAAc,YAAA,EAAc,GAAG,CAAC,CAAA;AAAA,EACrG,WACS,EAAE,YAAA,GAAe,CAAA,CAAA,IAAM,EAAE,aAAa,CAAA,CAAA,EAC/C;AAEI,IAAA,MAAM,MAAM,UAAA,GAAa,CAAA;AAEzB,IAAA,IAAI,YAAA,CAAa,iBAAA,EAAmB,CAAA,EAAG,GAAG,CAAA,CAAE,GAAA,CAAI,IAAI,YAAA,CAAa,YAAA,EAAc,YAAA,EAAc,GAAG,CAAC,CAAA;AAAA,EACrG,CAAA,MAEA;AAEI,IAAA,IAAI,UAAA,CAAW,iBAAiB,CAAA,CAAE,GAAA,CAAI,IAAI,UAAA,CAAW,YAAA,EAAc,YAAA,EAAc,UAAU,CAAC,CAAA;AAAA,EAChG;AACJ;;;;"}