Repository navigation
Interpolate animated colors in the build's pixel format - #77
Open
nejdetkadir wants to merge 1 commit into
Open
nejdetkadir wants to merge 1 commit into
nejdetkadir wants to merge 1 commit into
Conversation
A color keyframe holds the native style value that parseColorStyleValue produces. That is RGB565 on 16-bit boards but a 32-bit color on RGBA8888 and ARGB8888 builds, which is what the macOS and iOS targets use. The sampler always ran lerpColor565, which only reads the low 16 bits, so on those builds an animated color loses its other two bytes: with RGBA8888 blue and alpha come out as zero and red and green are mixed up. The breathing button in macos-native-showcase animates from #5856d6 to #ae64ce and renders dark green. Interpolate 32-bit colors byte by byte when the pixel format is 8888 and keep the RGB565 path for the other formats. run-css-animation-color-format.sh samples a color track in RGB565, RGBA8888 and ARGB8888.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On macOS, an animated color comes out wrong. In
examples/apps/macos-native-showcasethe Breathing button animatesbackground-colorfrom#5856d6to#ae64ceand renders dark green instead of purple.A color keyframe holds the native style value from
parseColorStyleValue. On RGB565 builds that is an RGB565 value. The macOS and iOS targets build withGEA_EMBEDDED_PIXEL_FORMAT=1(RGBA8888), so there it is a 32-bit color.sampleSegmentincss/animation.hinterpolates every color track withlerpColor565, which reads only the low 16 bits. With RGBA8888 that leaves blue and alpha at zero and mixes up red and green.Change
css/interpolate.h: addlerpColor8888, which interpolates a 32-bit color one byte at a time. That covers RGBA8888 and ARGB8888.css/animation.h: use it for color tracks whenGEA_PIXEL_FORMAT_IS_8888, and keeplerpColor565for the other formats.test/run-css-animation-color-format.shbuildstest/test_css_animation_color_format.cppfor formats 0, 1 and 2 and checks a color track at five points, including alpha.Tests
On macOS with Apple clang:
bouncing-balls-regressions.ymlpass (13 of 13).run-compiled-pcm-worklet.sh, whichrun-tests.shskips. With the env vars set, the 15 env-var tests (GEA_COMPILER_CLI,GEA_JSDOM_PACKAGEand so on) pass with compiler 1.0.44, and the UI memory census reports the same allocations as main.macos-native-showcasebuilt against the npm packages (core 0.1.49, apple 0.2.18) with this change applied to the engine: the Breathing button is purple. Sampled at different points of the animation, a pixel in the button reads718856,585617and6e935fwithout the change and8774d3,5b57cfandc5a2ddwith it.Notes for review
lerpColor565path. I did not check how color animations behave there.background-colorkeyframes only.colorkeyframes andbackground-colorandcolortransitions go through the same interpolation, but I did not run them.ios_main.mmnever callsStyleSheet::startCssAnimationsorAnimationEngine::tick. That part is in geastack/apple, so it is not in this PR. With that fixed locally and this change applied, an animated color on an iPhone 11 matched the expected values exactly.