Skip to content

[Android] Add basic DisplayP3 color support - #42935

Closed
ryanlntn wants to merge 9 commits into
react:mainfrom
ryanlntn:feat/wide-gamut-color-android
Closed

[Android] Add basic DisplayP3 color support#42935
ryanlntn wants to merge 9 commits into
react:mainfrom
ryanlntn:feat/wide-gamut-color-android

Conversation

@ryanlntn

Copy link
Copy Markdown
Contributor

Summary:

This adds initial support for wide gamut (DisplayP3) colors to React Native Android per the RFC. It provides the ability to enable wide color gamut in MainActivity and provides the native code necessary to support color() function syntax per the W3C CSS Color Module Level 4 spec.

This does not yet support animations and requires additional JS code before fully supporting the color() function syntax. It also does not yet support setting the default color space and, due to the nature of many of the native Android components, they fallback to the previous behavior since they don't directly support wide gamut colors and I couldn't yet find a workaround.

Since Android encodes wide gamut colors as long values I did have to update MapBuffer to support 64bit integers as well. Happy to break that out into a separate PR if that's preferred.

Changelog:

[ANDROID] [ADDED] - Add 64bit integer value support to MapBuffer
[ANDROID] [ADDED] - Add basic DisplayP3 color support

Test Plan:

  1. Update RNTesterActivity.kt to enable wide color gamut:
 class RNTesterActivity : ReactActivity() {
class RNTesterActivityDelegate(val activity: ReactActivity, mainComponentName: String) :
// ... override fun getLaunchOptions() =
if (this::initialProps.isInitialized) initialProps else Bundle()
+ override fun isWideColorGamutEnabled() = true
}
  1. Follow test steps from [JS] Add support for CSS4 color() functions #42831 to test support for color() function syntax.

Screenshot_20240131-100112

@facebook-github-botfacebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Infinite Red Partner: Infinite Red Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Feb 9, 2024
@analysis-bot

Copy link
Copy Markdown
PlatformEngineArchSize (bytes)Diff
androidhermesarm64-v8a17,253,974+20,376
androidhermesarmeabi-v7an/a--
androidhermesx86n/a--
androidhermesx86_64n/a--
androidjscarm64-v8a20,616,478+16,337
androidjscarmeabi-v7an/a--
androidjscx86n/a--
androidjscx86_64n/a--

Base commit: d7dce97
Branch: main

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@ryanlntn

Copy link
Copy Markdown
ContributorAuthor

Per discussion with @cipolleschi I'm going to split this up into separate PRs.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.p: Infinite RedPartner: Infinite RedPartnerShared with MetaApplied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ryanlntn@analysis-bot@facebook-github-bot