Fix the unintended blending of fill/hatch/stroke when drawing patches - #32343
Open
ayshih wants to merge 5 commits into
Open
Fix the unintended blending of fill/hatch/stroke when drawing patches#32343ayshih wants to merge 5 commits into
ayshih wants to merge 5 commits into
Conversation
ayshih
force-pushed
the
patch_blending
branch
6 times, most recently
from
September 12, 2026 16:02
35e707b to
362656e
Compare
ayshih
marked this pull request as ready for review
September 13, 2026 05:01
ayshih
force-pushed
the
patch_blending
branch
from
September 13, 2026 12:23
8abe2c2 to
3cd26de
Compare
iccir
approved these changes
Sep 13, 2026
iccir
left a comment
Contributor
There was a problem hiding this comment.
Approved. I'm a bit uneasy with the PGF format/backend, so others may want to examine that in more detail.
ayshih
force-pushed
the
patch_blending
branch
from
September 13, 2026 22:33
3cd26de to
1cf904d
Compare
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.
PR summary
This PR fixes a bug in the Agg/Cairo/PGF backends where applying a non-"normal" blend mode to a patch unintentionally resulted in blending the fill/hatch/stroke with each other using that same blend mode. Instead, the correct behavior – which the PDF/SVG backends already do – is for the fill/hatch/stroke to always be blended with each other using the "normal" blend mode, and then the result is blended with the backdrop using the non-"normal" blend mode. This PR makes the Agg/Cairo/PGF backends match the PDF/SVG backends.
The changes to the Cairo/PGF backends are straightforward because we can use
open_blend_group()/close_blend_group()to create an isolated blend group for the fill/hatch/stroke. The blend group is used only if an non-"normal" blend mode is specified and if more than one of fill/hatch/stroke is involved. (If there is only one of fill/hatch/stroke, no unintended blending can happen.) The changes to the Agg backend are a little trickier since the drawing function is at a deeper code layer than those renderer methods, so we have to mimic an isolated blend group by manually swapping a fresh buffer in and out of the C++ renderer.Since this PR is related to blend modes (#31162), it is not to be backported.
In the plots below, the first row is "normal" blend mode, and the second row is "multiply" blend mode. Note how in the "before this PR" image, the part of the stroke that overlaps the fill is being "multiply" blended instead of "normal" blended, and the star hatching plus fill is a different color even over the white backdrop because the stars are getting "multiply" blended with the fill.
Before this PR
After this PR
Generating code
AI Disclosure
No AI was used
PR quality check