PDFBOX-6077: Add regression tests for stencil-mask pattern fills - #492
Draft
valerybokov wants to merge 3 commits into
Draft
PDFBOX-6077: Add regression tests for stencil-mask pattern fills#492valerybokov wants to merge 3 commits into
valerybokov wants to merge 3 commits into
Conversation
A stencil image filled with a pattern draws the paint and the mask into separate scratch images and then combines them. The combine step unconditionally overwrote the paint's alpha with the mask's alpha, so any pixel the pattern itself never painted into (e.g. the gaps between tiles of a tiling pattern) turned opaque black instead of staying transparent. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
A soft mask's Paint/PaintContext looks up its backing raster using absolute page-device pixel coordinates, fixed when the soft mask group was rendered. The stencil-mask-with-pattern code renders into an isolated scratch image rather than directly onto the page graphics, so those coordinates no longer lined up and the soft mask silently applied zero alpha everywhere, making the pattern disappear. Unwrap the soft mask, fill the scratch image with its plain underlying paint instead, and apply the soft mask's own alpha afterwards by directly looking up its backing raster through a per-pixel device transform, rather than relying on the Paint/PaintContext machinery that assumed it was rendering onto the real page raster. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Downloads the two JIRA-attached PDFs exercising the alpha-combine and soft-mask fixes, and asserts on specific pixels that distinguish the fixed rendering from each bug: a gap between a tiling pattern's tiles that must stay transparent, and a soft-masked pattern's icon that must still be visible when used as a stencil mask fill. Co-Authored-By: Claude Sonnet 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
Adds regression tests for the two bugs fixed on the fix-image-masks branch (from which this branch is built): a stencil-mask image filled with a pattern, where either the pattern itself has gaps (e.g. between tiles) or a soft mask is applied to the pattern (#491).
What's added
This is a rough draft of the tests, as the POM file will likely need to be modified.
Per https://www.apache.org/legal/generative-tooling.html: portions of this PR were produced with assistance from Claude Code (Anthropic), based on a bug from PDFBOX Issue Tracker (6077).
I've reviewed the generated code and test, verified the test fails against the pre-fix implementation and passes against the fix, and confirm to the best of my knowledge that the output does not include any third-party copyrighted material and is compatible with the Apache License 2.0.