[6.40] [asimage] Fix filled shapes drawn with a semi-transparent colour - #23109
Open
root-project-bot wants to merge 2 commits into
Open
[6.40] [asimage] Fix filled shapes drawn with a semi-transparent colour#23109root-project-bot wants to merge 2 commits into
root-project-bot wants to merge 2 commits into
Conversation
libAfterImage builds a filled shape by drawing its outline into a scratch canvas, flood-filling the interior, and only then merging the scratch into the image. That merge already applies the brush alpha, because it hands the scratch value to alpha_blend_point_argb32() as the blend ratio -- but the colored tool and fill functions were scaling what they wrote by the same alpha. It was therefore applied twice, and the value the flood fill writes came to depend on it while the threshold that fill compares against did not. Two failures followed whenever TASImage::DrawCircle() and friends were given a colour that is not fully opaque. At an alpha of 0x8C or below the value written never left the range the fill accepts, so every filled pixel was rediscovered and ctx_flood_fill() never returned. Between 0x8D and 0xFE it did return, but the anti-aliased outline no longer reached the threshold either, so the fill leaked past it and covered the whole image instead of the shape. Writing the coverage unscaled fixes both, because the threshold comparison stops depending on the brush. Output for a fully opaque brush is unchanged: 255 * ratio / 255 == ratio, and a circle, a manual filled path and an unfilled circle all render bit-identically before and after. Refs root-project#23014 Assisted-by: Claude (Anthropic); the change and the test were AI-assisted, then reviewed, measured and verified by the author. (cherry picked from commit 2eb51d4)
Covers both ways DrawCircle() failed before the previous commit: at an alpha of 0x7F it hung, and at 0xC0 it filled the whole image rather than the circle. The opaque case guards the common path against a regression. Corner pixels are compared against their own values from before the draw, so the test does not depend on how a fresh TASImage is initialised. Refs root-project#23014 Assisted-by: Claude (Anthropic); the change and the test were AI-assisted, then reviewed, measured and verified by the author. (cherry picked from commit 1d28aaa)
2 tasks
Test Results 22 files 22 suites 3d 11h 0m 8s ⏱️ For more details on these failures, see this check. Results for commit 649e612. |
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.
Backport of #23023, requested by @dpiparo. For your information @tekinertekin