Skip to content

Commit f32230e

Browse files
committed
hostPlatformColorIsColorMeaningful impl
1 parent 173a968 commit f32230e

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

vnext/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@
99

1010
namespace winrt::Microsoft::ReactNative::Composition::implementation {
1111

12-
// Ideally isColorMeaningful would be sufficient here. But it appears to detect platformColors as not meaningful
13-
// https://github.com/microsoft/react-native-windows/issues/14006
14-
bool isColorMeaningful(
15-
const facebook::react::SharedColor &color,
16-
winrt::Microsoft::ReactNative::Composition::implementation::Theme *theme) noexcept {
17-
if (!color) {
18-
return false;
19-
}
20-
21-
return theme->Color(*color).A > 0;
22-
}
23-
2412
// We don't want half pixel borders, or border radii - they lead to blurry borders
2513
// Also apply scale factor to the radii at this point
2614
void pixelRoundBorderRadii(facebook::react::BorderRadii &borderRadii, float scaleFactor) noexcept {
@@ -354,7 +342,7 @@ void SetBorderLayerPropertiesCommon(
354342
// Clear with transparency
355343
pRT->Clear();
356344

357-
if (!isColorMeaningful(borderColor, theme)) {
345+
if (!facebook::react::isColorMeaningful(borderColor)) {
358346
return;
359347
}
360348

@@ -738,7 +726,7 @@ bool BorderPrimitive::requiresBorder(
738726
auto borderStyle = borderMetrics.borderStyles.left;
739727

740728
bool hasMeaningfulColor =
741-
!borderMetrics.borderColors.isUniform() || isColorMeaningful(borderMetrics.borderColors.left, theme);
729+
!borderMetrics.borderColors.isUniform() || facebook::react::isColorMeaningful(borderMetrics.borderColors.left);
742730
bool hasMeaningfulWidth = !borderMetrics.borderWidths.isUniform() || (borderMetrics.borderWidths.left != 0);
743731
if (!hasMeaningfulColor || !hasMeaningfulWidth) {
744732
return false;
@@ -828,7 +816,7 @@ bool BorderPrimitive::TryUpdateSpecialBorderLayers(
828816
auto borderStyle = borderMetrics.borderStyles.left;
829817

830818
bool hasMeaningfulColor =
831-
!borderMetrics.borderColors.isUniform() || !isColorMeaningful(borderMetrics.borderColors.left, theme);
819+
!borderMetrics.borderColors.isUniform() || !facebook::react::isColorMeaningful(borderMetrics.borderColors.left);
832820
bool hasMeaningfulWidth = !borderMetrics.borderWidths.isUniform() || (borderMetrics.borderWidths.left != 0);
833821
if (!hasMeaningfulColor && !hasMeaningfulWidth) {
834822
return false;

vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ inline ColorComponents colorComponentsFromHostPlatformColor(Color color) {
9999

100100
// windows
101101
inline bool hostPlatformColorIsColorMeaningful(Color color) noexcept {
102+
if (color.m_platformColor.size())
103+
return true;
104+
102105
auto windowsColor = color.AsWindowsColor();
103106
return windowsColor.A > 0;
104107
}

0 commit comments

Comments
 (0)