-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Sort gradient stops by offset #31318
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
Conversation
Updated the gradient stop processing to order stops by their offset before populating color and offset arrays. This ensures gradients are rendered correctly according to stop positions.
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 fixes Android gradient rendering by ensuring gradient stops are processed in the correct order. The issue was that gradient stops were being rendered in their declaration order rather than sorted by their offset position, causing incorrect gradient appearance.
- Sorts gradient stops by their offset value before processing colors and positions
- Ensures gradients render correctly according to stop positions rather than declaration order
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
|
||
| int count = 0; | ||
| foreach (var orderStop in orderStops) | ||
| foreach (var orderStop in orderStops.OrderBy(s => s.Offset)) |
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.
Can sort manually? Can use Sortthat modifies the list in place avoiding the overhead of creating a new collection.
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.
But: If some code elsewhere is depending on the original ordering (e.g., holding onto indices or iterating concurrently), we may break that assumption.
* [Android] Sort gradient stops by offset Updated the gradient stop processing to order stops by their offset before populating color and offset arrays. This ensures gradients are rendered correctly according to stop positions. * Added a UITest * Add snapshots --------- Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
* [Android] Sort gradient stops by offset Updated the gradient stop processing to order stops by their offset before populating color and offset arrays. This ensures gradients are rendered correctly according to stop positions. * Added a UITest * Add snapshots --------- Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
* [Android] Sort gradient stops by offset Updated the gradient stop processing to order stops by their offset before populating color and offset arrays. This ensures gradients are rendered correctly according to stop positions. * Added a UITest * Add snapshots --------- Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
* [Android] Sort gradient stops by offset Updated the gradient stop processing to order stops by their offset before populating color and offset arrays. This ensures gradients are rendered correctly according to stop positions. * Added a UITest * Add snapshots --------- Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
* [Android] Sort gradient stops by offset Updated the gradient stop processing to order stops by their offset before populating color and offset arrays. This ensures gradients are rendered correctly according to stop positions. * Added a UITest * Add snapshots --------- Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
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!
Description of Change
Updated the gradient stop processing to order stops by their offset before populating color and offset arrays. This ensures gradients are rendered correctly according to stop positions.
Applied the same approach as in here: https://github.dev/kubaflo/maui/blob/be7d14bd4c4c1c31f3dad7bc9e836374aa38c7b1/src/Core/src/Graphics/PaintExtensions.Android.cs#L105
Issues Fixed
Fixes #31314