Repository navigation
harness: compare synthetic pages against a supersampled reference - #78
Merged
Merged
Conversation
PDFium is biased at edges: it over-inks partially covered pixels of diagonal lines by 0.5-0.8 % and loses about 0.9 % of the area of small curves. An exact rasterizer therefore missed the accuracy target against it on dense hairlines and glyphs. New engine `reference` for synthetic scene pages: every operation is rasterized at 8x the resolution through a stilus.Compositor that sums its coverage into the page's pixels, then composited at the page's resolution in floating point. Supersampling the whole page would not be a fair reference: coverage-based antialiasing composites each operation with its own coverage (1-(1-a)(1-b) where two shapes share a pixel, a+b supersampled), about 19/255 on dense hairlines. Strokes thinner than a pixel are drawn one pixel wide, as stilus and PDFium draw them. TestReferenceArea checks it against exact areas within 0.2 %. pdfbench run takes -scene-ref (default `reference`, empty: -ref): synthetic pages are compared against it, and PDFium is measured against it too. The reference is rendered once and left out of the speed table. Also: rows for documents that fail to open no longer count as zero allocations for engines outside the Go heap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
referencefor synthetic scene pages. Each operation is rasterized at 8× resolution through astilus.Compositorthat sums its coverage into the page's pixels. The operation is then composited at page resolution in floating point.pdfbench run -scene-refflag (defaultreference; empty falls back to-ref). Synthetic pages are compared against the reference, and PDFium is measured against it too. The reference renders once and is left out of the speed table.Why not PDFium, and why not a supersampled page
hatch-2000-hairlineandglyphs-30000-uncached.1−(1−a)(1−b)where two shapes share a pixel, versusa+bon a supersampled page. Measured, that is about 19/255 on dense hairlines. Supersampling per operation measures only the coverage.Results (150 dpi, 8 scenes)
The reference takes a few seconds for all eight scenes.
Test plan
TestReferenceArea: a rectangle with edges between pixels, a rotated square, a quadratic circle with r = 3.07 and a hairline match their exact areas within 0.2 %go vet ./...,go test ./...inharnesspdfbench scenes+runon scenes alone and on scenes plus the public corpus; real PDFs still compare against PDFium🤖 Generated with Claude Code