From 717afaf3177a2e0925b18ae3445119efe808b129 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 16 Sep 2026 14:46:16 -0300 Subject: Add macOS backdrop blur and preserve PDF ink opacity --- test/macos-snapshots/rendering-parity.golden | 14 +++++++------- test/macos_e2e.swift | 21 +++++++++++++++------ 2 files changed, 22 insertions(+), 13 deletions(-) (limited to 'test') diff --git a/test/macos-snapshots/rendering-parity.golden b/test/macos-snapshots/rendering-parity.golden index 536f6800..cbb56ab2 100644 --- a/test/macos-snapshots/rendering-parity.golden +++ b/test/macos-snapshots/rendering-parity.golden @@ -5,10 +5,10 @@ == backgrounds invalid-stays-0 uniform == context context-100 compact separators verified == context context-71 compact separators verified -== pdf pdf-100 native page opacity verified -== pdf pdf-0 native page opacity verified -== pdf pdf-71 native page opacity verified -== pdf pdf-fit-height native page opacity verified -== pdf pdf-full-tint native page opacity verified -== pdf pdf-original-colors native page opacity verified -== pdf pdf-scrolled native page opacity verified +== pdf pdf-100 paper opacity and opaque ink verified +== pdf pdf-0 paper opacity and opaque ink verified +== pdf pdf-71 paper opacity and opaque ink verified +== pdf pdf-fit-height paper opacity and opaque ink verified +== pdf pdf-full-tint paper opacity and opaque ink verified +== pdf pdf-original-colors paper opacity and opaque ink verified +== pdf pdf-scrolled paper opacity and opaque ink verified diff --git a/test/macos_e2e.swift b/test/macos_e2e.swift index 5427c3ad..5efc366c 100644 --- a/test/macos_e2e.swift +++ b/test/macos_e2e.swift @@ -687,13 +687,22 @@ private final class Driver: PardesViewDelegate { throw ScriptError(message: "PDF: placement is outside its physical-pixel viewport") } let backing = CGFloat(rep.pixelsWide) / view.bounds.width - var matched = 0 - for fraction in [CGFloat(0.2), 0.4, 0.6, 0.8] { - if let c = rep.colorAt(x: Int((x + width * fraction) * backing), - y: Int((y + height * fraction) * backing)), abs(c.alphaComponent - view.backgroundAlpha) < 2.0 / 255 { matched += 1 } + guard image.paper_bg != UInt32(PARDES_COLOR_DEFAULT) else { + throw ScriptError(message: "PDF: missing separate paper background") } - guard matched == 4 else { throw ScriptError(message: "PDF: raster opacity does not match WindowOpacity") } - output += "== pdf \(label) native page opacity verified\n" + var lowest: CGFloat = 1, highest: CGFloat = 0 + for py in stride(from: Int(y * backing) + 2, to: Int((y + height) * backing) - 2, by: 2) { + for px in stride(from: Int(x * backing) + 2, to: Int((x + width) * backing) - 2, by: 2) { + if let c = rep.colorAt(x: px, y: py) { + lowest = min(lowest, c.alphaComponent) + highest = max(highest, c.alphaComponent) + } + } + } + guard abs(lowest - view.backgroundAlpha) < 2.0 / 255, highest > 0.98 else { + throw ScriptError(message: "PDF: expected translucent paper and opaque ink, got alpha \(lowest)...\(highest)") + } + output += "== pdf \(label) paper opacity and opaque ink verified\n" } // MARK: - the script -- cgit v1.3