Skip to content
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

Update Core Animation rendering engine to use device RGB color space #1801

Merged
merged 4 commits into from
Nov 7, 2022

Conversation

calda
Copy link
Member

@calda calda commented Nov 7, 2022

This PR updates the Core Animation rendering engine to use the same color space as the Main Thread rendering engine (CGColorSpaceCreateDeviceRGB()). Fixes #1800.

Currently the Main Thread rendering engine and Core Animation rendering engine use different color spaces, which can cause the two engines to render colors differently. For consistency between the two implementations, we should use the same color space.

CGColorSpaceCreateDeviceRGB() produces the exact same color as the web player:

Screen Shot 2022-11-07 at 10 04 00 AM

CGColor(red:green:blue:alpha:) creates a lighter color in this case:

Screen Shot 2022-11-07 at 10 04 15 AM

Since CGColorSpaceCreateDeviceRGB() is the existing behavior, and best matches other platforms, we should be using that instead.

@@ -103,8 +103,8 @@ private class MaskLayer: CALayer {
addSublayer(maskLayer)
anchorPoint = .zero
maskLayer.fillColor = mask.mode == .add
? CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [1, 0, 0, 1])
: CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [0, 1, 0, 1])
? .rgb(1, 0, 0)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consolidated all CGColor.init call sites to the same helper

@calda calda force-pushed the cal--update-color-spaces branch from 765bad9 to 7ef726a Compare November 7, 2022 18:16
@calda calda merged commit 9e19fd1 into master Nov 7, 2022
@calda calda deleted the cal--update-color-spaces branch November 7, 2022 20:27
iago849 pushed a commit to atteamapps/lottie-ios that referenced this pull request Feb 8, 2024
MoroziOS pushed a commit to MoroziOS/tmg-lottie-ios that referenced this pull request May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improper background (white veil) with coreAnimation rendering engine.
2 participants