-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Support alpha in Gradients, fix uneven stops. #36100
Conversation
|
|
||
| for (auto i = 1u; i < texture_size - 1; i++) { | ||
| auto scaled_i = i / texture_size; | ||
| auto scaled_i = i / (texture_size * 1.0); |
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.
woops
| // or very small stops. | ||
| AppendColor(next_color, &color_stop_channels); | ||
|
|
||
| // We've slightly overshot the previous stop. |
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.
This isn't the case I though it was. If we've passed the previous stop, then we essentially just treat the current stop as the previous stop and run the same code as above.
bdero
left a comment
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.
LGTM! Should we land this for the other color sources too? (Could be done in followup(s))
| gradient_info.tile_mode, | ||
| gradient_info.tile_mode); | ||
| frag_color = vec4(frag_color.xyz * frag_color.a, frag_color.a); | ||
| frag_color = vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha; |
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.
I left this comment on the other PR, but this still makes me wonder if IPSampleWithTileMode shouldn't really just be IPSampleWithTileModeAndAlpha so we don't forget to do this somewhere - e.g. if and when we implement two point conical gradients.
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.
Binding non-premultiplied images is the uncommon case -- all layer textures and UI images are premultiplied.
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.
One idea for making this a bit more semantic is to add an IPPremultiply utility to the shader library and wrap the sampling function in it when we need to premultiply something. This way new contributors who don't know why we're doing the funky alpha multiplies can get a bit more context when first encountering it.
We happen to already have IPUnpremultiply because the advanced blends need to happen with unpremultiplied colors.
All shader functions get flattened by ImpellerC, so utilities like this are free.
Gives all gradients/color source contents an alpha. Additionall corrects some implementation in errors when lerping gradients
Opacity:
Fixes Stops:
Fixes flutter/flutter#111313