misc patches done to get everything to play ball

also adds editorconfig
This commit is contained in:
modeco80
2024-04-24 03:41:32 -04:00
parent db97a62046
commit bcbf7db8d9
4 changed files with 35 additions and 17 deletions

View File

@@ -44,7 +44,8 @@ function GetRawSharpOptions(size: Size): sharp.CreateRaw {
}
}
const kJpegPool = new Piscina({
// Thread pool for doing JPEG encoding for rects.
const TheJpegEncoderPool = new Piscina({
filename: path.join(import.meta.dirname + '/JPEGEncoderWorker.js'),
minThreads: 4,
maxThreads: 4
@@ -53,7 +54,7 @@ const kJpegPool = new Piscina({
async function EncodeJpeg(canvas: Buffer, displaySize: Size, rect: Rect): Promise<Buffer> {
let offset = (rect.y * displaySize.width + rect.x) * 4;
let res = await kJpegPool.run({
let res = await TheJpegEncoderPool.run({
buffer: canvas.subarray(offset),
width: rect.width,
height: rect.height,
@@ -61,6 +62,10 @@ async function EncodeJpeg(canvas: Buffer, displaySize: Size, rect: Rect): Promis
quality: kJpegQuality
});
// TODO: There's probably (definitely) a better way to fix this
if(res == undefined)
return Buffer.from([]);
// have to manually turn it back into a buffer because
// Piscina for some reason turns it into a Uint8Array
@@ -1006,4 +1011,4 @@ export default class WSServer {
});
return {yes:yes,no:no};
}
}
}