Fix issue where filter layer was not the same shape as the underlying layer (#46138)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46138

jorge-cab noticed that filters on iOS do not fit the shape of the layer if we have rounded corners. Fix is pretty straight forward.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D61612655

fbshipit-source-id: 91785ed10a039e031c5440bde131c1583ba3992a
This commit is contained in:
Joe Vilches
2024-08-22 12:12:46 -07:00
committed by Facebook GitHub Bot
parent 9bfbf948df
commit 5bb4ef5dec
@@ -855,6 +855,13 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
blue:multiplicativeBrightness
alpha:self.layer.opacity]
.CGColor;
if (borderMetrics.borderRadii.isUniform()) {
_filterLayer.cornerRadius = borderMetrics.borderRadii.topLeft;
} else {
RCTCornerInsets cornerInsets =
RCTGetCornerInsets(RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero);
_filterLayer.mask = [self createMaskLayer:self.bounds cornerInsets:cornerInsets];
}
// So that this layer is always above any potential sublayers this view may
// add
_filterLayer.zPosition = CGFLOAT_MAX;