Fix compositing multi source with alpha #1453
Merged
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.
Fix an issue with compositing sources in the multi source caused by alpha range. We composite tiles using pre-multiplied alpha values. When we have 8 bit images and apply an affine transform, we do this in float precision so that compositing does not lose precision prematurely. The function fullAlphaValue is used to determine the range of the alpha values we expect; for uint8 this is 255, for float it is 1. Since the values have been cast to float but NOT scaled, this ends up with the wrong values. Functionally, this was multiplying incomplete tiles by 255 and then taking the low 8 bits of the resultant integer cast, which looked like nonsense.