forked from Blendman974/faceclaw
Introduce oxlint, and fix lint warnings
This commit is contained in:
1 parent
cb6dddd120
commit
06146c2b08
89 files changed
+818
-469
No files matched your search
@@ -121,24 +121,24 @@ export function readDisplayList(bytes: Uint8Array, offset: number, now = Date.no
|
||||
const x = r.i16(), y = r.i16(), width = r.u16(), height = r.u16(), depth = r.u8() << 24 >> 24;
|
||||
const token = r.u32(), elapsed = r.u32(), count = r.u16(); integer(count, 0, 256);
|
||||
const resources: ListImage[] = [];
|
||||
for (let i = 0; i < count; i++) { const width = r.u16(), height = r.u16(); resources.push({ width, height, pixels: r.take(width * height) }); }
|
||||
for (let i = 0; i < count; i++) { const w = r.u16(), h = r.u16(); resources.push({ width: w, height: h, pixels: r.take(w * h) }); }
|
||||
const calls: ListCall[] = [], callCount = r.u16(); integer(callCount, 0, 4096);
|
||||
for (let i = 0; i < callCount; i++) {
|
||||
const header = r.u8(), op = header & ~CLIPPED, depth = r.i16();
|
||||
const header = r.u8(), op = header & ~CLIPPED, callDepth = r.i16();
|
||||
const clip = header & CLIPPED ? { x: r.i16(), y: r.i16(), width: r.u16(), height: r.u16() } : undefined;
|
||||
const common = clip ? { depth, clip } : { depth };
|
||||
const common = clip ? { depth: callDepth, clip } : { depth: callDepth };
|
||||
if (op === DrawOp.ROUNDED_RECT) calls.push({ op, ...common, x: readValue(r), y: readValue(r), width: r.u16(), height: r.u16(), radius: r.u16(), background: r.u8(), border: r.u8() });
|
||||
else if (op === DrawOp.IMAGE) calls.push({ op, ...common, resource: r.u16(), x: r.i16(), y: r.i16(), transparent: (r.u8() & 16) !== 0 });
|
||||
else if (op === DrawOp.RECT_COPY) calls.push({ op, ...common, resource: r.u16(), x: readValue(r), y: readValue(r), width: r.u16(), height: r.u16(), dx: readValue(r), dy: readValue(r) });
|
||||
else if (op === DrawOp.CLEAR) calls.push({ op, ...common, color: r.u8() });
|
||||
else if (op === DrawOp.DRAWS) {
|
||||
const x = readValue(r), y = readValue(r), records = r.u16(), start = r.offset;
|
||||
const drawX = readValue(r), drawY = readValue(r), records = r.u16(), start = r.offset;
|
||||
for (let n = 0; n < records; n++) {
|
||||
const size = RECORD_BYTES[r.bytes[r.offset]!];
|
||||
if (!size) throw new Error('Unsupported display-list draw record');
|
||||
r.take(size);
|
||||
}
|
||||
calls.push({ op, ...common, x, y, count: records, records: r.bytes.slice(start, r.offset) });
|
||||
calls.push({ op, ...common, x: drawX, y: drawY, count: records, records: r.bytes.slice(start, r.offset) });
|
||||
} else throw new Error('Unsupported display-list call');
|
||||
}
|
||||
if (r.offset !== length) throw new Error('Trailing display-list bytes');
|
||||
|
||||
@@ -112,10 +112,10 @@ export function evaluate(value: DrawValue, elapsed: number, presentTime = 0): {
|
||||
if (typeof value === 'number') return { value, pending: false };
|
||||
const reader = new DrawBytes(Uint8Array.from(value.code)), stack: { value: number; float: boolean }[] = [];
|
||||
let pending = false;
|
||||
const push = (value: number, float = false) => {
|
||||
value = float ? Math.fround(value) : value | 0;
|
||||
if (!Number.isFinite(value) || stack.length === 32) throw new Error('Invalid expression stack');
|
||||
stack.push({ value, float });
|
||||
const push = (n: number, float = false) => {
|
||||
n = float ? Math.fround(n) : n | 0;
|
||||
if (!Number.isFinite(n) || stack.length === 32) throw new Error('Invalid expression stack');
|
||||
stack.push({ value: n, float });
|
||||
};
|
||||
const pop = (float: boolean) => { const v = stack.pop(); if (!v || v.float !== float) throw new Error('Expression type mismatch'); return v.value; };
|
||||
const toInt = (v: number) => { if (v < -2147483648 || v >= 2147483648) throw new Error('Invalid integer conversion'); return Math.trunc(v); };
|
||||
|
||||
@@ -192,7 +192,7 @@ export function prepareFrameDraws(draws: readonly DeferredDraw[]): ArrayBuffer |
|
||||
offset = writeGlyphRecord(out, offset, state, placed);
|
||||
} else if (placed.kind === "image") {
|
||||
if (!inRange16(placed.x) || !inRange16(placed.y)) continue;
|
||||
if (placed.presentation) { const bytes = presentations.get(placed)!; new Uint8Array(out.buffer).set(bytes, offset); offset += bytes.length; continue; }
|
||||
if (placed.presentation) { const record = presentations.get(placed)!; new Uint8Array(out.buffer).set(record, offset); offset += record.length; continue; }
|
||||
const id = imageId(placed);
|
||||
if (id === null) continue;
|
||||
offset = writeImageRecord(out, offset, id, placed);
|
||||
|
||||
@@ -288,7 +288,9 @@ export class GrayImage {
|
||||
const dst = this.pixels;
|
||||
// A blit within one image copies pixel by pixel, forwards, as it always has.
|
||||
const bulk = !opts.transparentZero && source !== this;
|
||||
for (let row = rowStart; span > 0 && row < rowEnd; row++) {
|
||||
// No columns in range means no rows to copy.
|
||||
const rowLimit = span > 0 ? rowEnd : rowStart;
|
||||
for (let row = rowStart; row < rowLimit; row++) {
|
||||
const from = (srcY + row) * source.width + srcX + colStart;
|
||||
const to = (destY + row) * this.width + destX + colStart;
|
||||
if (bulk) {
|
||||
|
||||
@@ -30,7 +30,7 @@ export function encodeShellScene(planes: readonly Plane[]): Uint8Array {
|
||||
presentation: { ...d.presentation!, depth: d.presentation!.depth + (plane.depth ?? 0) } }))
|
||||
layers.push({ depth: plane.depth ?? 0, selections, image: cropped.image, x: plane.x + left, y: plane.y + top, key: plane.shellKey!, dim: Math.round((plane.dimUnderneath ?? 1) * 256) })
|
||||
}
|
||||
const result = new Uint8Array(2 + layers.reduce((n, l) => n + 16 + l.image.pixels.length + l.selections.reduce((n, b) => n + b.length, 0), 0))
|
||||
const result = new Uint8Array(2 + layers.reduce((n, l) => n + 16 + l.image.pixels.length + l.selections.reduce((sum, b) => sum + b.length, 0), 0))
|
||||
const view = new DataView(result.buffer); let p = 0
|
||||
const word = (n: number) => { view.setUint16(p, n, true); p += 2 }
|
||||
word(layers.length)
|
||||
|
||||
Reference in new issue
Block a user