diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/Color.cpp b/packages/react-native/ReactCommon/react/renderer/graphics/Color.cpp index 94c9ad2c9b2..08f43575864 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/Color.cpp +++ b/packages/react-native/ReactCommon/react/renderer/graphics/Color.cpp @@ -14,7 +14,7 @@ bool isColorMeaningful(const SharedColor& color) noexcept { return false; } - return colorComponentsFromColor(color).alpha > 0; + return hostPlatformColorIsColorMeaningful(*color); } // Create Color from float RGBA values in [0, 1] range diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/HostPlatformColor.h b/packages/react-native/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/HostPlatformColor.h index 0703aa558a5..a09eb626d2e 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/HostPlatformColor.h +++ b/packages/react-native/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/HostPlatformColor.h @@ -56,4 +56,8 @@ inline float blueFromHostPlatformColor(Color color) { return static_cast((color >> 0) & 0xff); } +inline bool hostPlatformColorIsColorMeaningful(Color color) noexcept { + return alphaFromHostPlatformColor(color) > 0; +} + } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/HostPlatformColor.h b/packages/react-native/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/HostPlatformColor.h index 0003bbd6b9f..3bbcb1e11ea 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/HostPlatformColor.h +++ b/packages/react-native/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/HostPlatformColor.h @@ -49,6 +49,10 @@ inline float blueFromHostPlatformColor(Color color) { return static_cast((color >> 0) & 0xff); } +inline bool hostPlatformColorIsColorMeaningful(Color color) noexcept { + return alphaFromHostPlatformColor(color) > 0; +} + inline ColorComponents colorComponentsFromHostPlatformColor(Color color) { float ratio = 255; return ColorComponents{ diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h b/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h index 5dd1ac810e5..8deffedcb1d 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h +++ b/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h @@ -104,6 +104,10 @@ inline float blueFromHostPlatformColor(Color color) { return color.getChannel(2) * 255; } +inline bool hostPlatformColorIsColorMeaningful(Color color) noexcept { + return alphaFromHostPlatformColor(color) > 0; +} + } // namespace facebook::react template <>