perf(desktop): compare complete RGBA pixels in the screenshot readiness check (#12633)

This commit is contained in:
RRFZ authored and GitHub committed 2026-11-20 01:12:28 +00:00
1 parent 6c7d69245e
commit bd70cf94ff
3 files changed
+9 -5

No files matched your search

@@ -7,7 +7,6 @@
"src/domain/native/elfPointerRelocations.ts": 6,
"src/domain/native/nativeAotPe.ts": 10,
"src/domain/native/readBinaryContainer.ts": 1,
"src/domain/pngVisualDiff.ts": 2,
"src/ghidra/extensions/GhidraExtensions.ts": 1,
"src/il2cpp/Il2cppBinaryImage.ts": 2,
"src/il2cpp/Il2cppBinaryRegistration.ts": 8,
+7
View File
@@ -199,6 +199,13 @@ describe("PNG visual diff", () => {
});
describe("isOneColourPng", () => {
it("accepts a single pixel and detects an alpha change at the row boundary", () => {
const pixel = [15, 35, 55, 75];
expect(isOneColourPng(png(1, 1, pixel).toString("base64"))).toBe(true);
const pixels = [...pixel, ...pixel, 15, 35, 55, 76, ...pixel];
expect(isOneColourPng(png(2, 2, pixels).toString("base64"))).toBe(false);
});
it("tells a one-colour frame from a drawn one, and an unreadable one from both", () => {
const base64 = (pixels: readonly number[]) =>
png(2, 2, pixels).toString("base64");
+2 -4
View File
@@ -117,10 +117,8 @@ export const isOneColourPng = (dataBase64: string): boolean | undefined => {
} catch {
return undefined;
}
const first = rgba.readUInt32BE(0);
for (let offset = 4; offset < rgba.length; offset += 4)
if (rgba.readUInt32BE(offset) !== first) return false;
return true;
// A uniform frame matches itself shifted by one RGBA pixel.
return rgba.subarray(4).equals(rgba.subarray(0, -4));
};
const parsePng = (