-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[Android] - Fix Shadow Rendering For Transparent Fill, Stroke (Lines), and Text on Shapes #29528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hey there @@prakashKannanSf3972! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR resolves an issue where shadows were rendered for fully transparent shapes by refining the shadow rendering logic and ensuring shadow updates are triggered on color property changes.
- Updated PlatformCanvasState.cs to trigger shadow state updates when StrokeColor, FillColor, or FontColor change and to conditionally apply shadows based on alpha values.
- Added a unit test (Issue29394.cs in TestCases.Shared.Tests) and an associated UI test page (Issue29394.cs in TestCases.HostApp) to cover the transparent shadow rendering scenario.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/Graphics/src/Graphics/Platforms/Android/PlatformCanvasState.cs | Refactored to apply shadows based on color alpha and ensure state updates on color changes. |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29394.cs | Added a unit test to verify shadow behavior with transparent colors. |
src/Controls/tests/TestCases.HostApp/Issues/Issue29394.cs | Provided a test page to facilitate automated UI tests for the shadow rendering update. |
} | ||
} | ||
|
||
void UpdateShadowState() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider refactoring UpdateShadowState to batch multiple color updates to avoid redundant calls to SetShadow if several color properties change consecutively. This could improve performance if shadow re-application becomes expensive.
Copilot uses AI. Check for mistakes.
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Root Cause
ShadowLayer
renders shadows even when a shape is filled or drawn using atransparent
color. The Android canvas still processes the shape’s path and applies the shadow, despite the shape itself being visuallytransparent
. This leads to shadows appearing without visible content, potentially causing unintended visual output.Description of Change
Refined
ShadowLayer
to apply shadows only whenFillColor
,StrokeColor
, orFontColor
have a non-zero alpha value, avoiding unnecessary shadow rendering for fully transparent elements.Additionally,
ShadowLayer
is now explicitly invoked whenever any of these color properties change, ensuring consistent and accurate shadow rendering across platforms.Issues Fixed
Fixes #29394
Tested the behaviour in the following platforms
Output