mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Small perf fix for new iOS view clipping (#46629)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46629 If we clipped and had no border or corner radius we would end up hitting this path every time. We can optimize this a bit to avoid that. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D63299597 fbshipit-source-id: 90031f964b7669049a4a2efe00a553c888d28cd7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eb7c43965e
commit
9ee5fffae0
+12
-9
@@ -1080,15 +1080,10 @@ static RCTBorderStyle RCTBorderStyleFromOutlineStyle(OutlineStyle outlineStyle)
|
||||
}
|
||||
|
||||
// clipping
|
||||
self.currentContainerView.layer.mask = nil;
|
||||
if (self.currentContainerView.clipsToBounds) {
|
||||
BOOL clipToPaddingBox = ReactNativeFeatureFlags::enableIOSViewClipToPaddingBox();
|
||||
if (clipToPaddingBox) {
|
||||
CALayer *maskLayer = [self createMaskLayer:RCTCGRectFromRect(_layoutMetrics.getPaddingFrame())
|
||||
cornerInsets:RCTGetCornerInsets(
|
||||
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii),
|
||||
RCTUIEdgeInsetsFromEdgeInsets(borderMetrics.borderWidths))];
|
||||
self.currentContainerView.layer.mask = maskLayer;
|
||||
} else {
|
||||
if (!clipToPaddingBox) {
|
||||
if (borderMetrics.borderRadii.isUniform()) {
|
||||
self.currentContainerView.layer.cornerRadius = borderMetrics.borderRadii.topLeft.horizontal;
|
||||
} else {
|
||||
@@ -1110,9 +1105,17 @@ static RCTBorderStyle RCTBorderStyleFromOutlineStyle(OutlineStyle outlineStyle)
|
||||
subview.layer.mask = [self createMaskLayer:subview.bounds cornerInsets:cornerInsets];
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
!borderMetrics.borderWidths.isUniform() || borderMetrics.borderWidths.left != 0 ||
|
||||
!borderMetrics.borderRadii.isUniform()) {
|
||||
CALayer *maskLayer = [self createMaskLayer:RCTCGRectFromRect(_layoutMetrics.getPaddingFrame())
|
||||
cornerInsets:RCTGetCornerInsets(
|
||||
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii),
|
||||
RCTUIEdgeInsetsFromEdgeInsets(borderMetrics.borderWidths))];
|
||||
self.currentContainerView.layer.mask = maskLayer;
|
||||
} else {
|
||||
self.currentContainerView.layer.cornerRadius = borderMetrics.borderRadii.topLeft.horizontal;
|
||||
}
|
||||
} else {
|
||||
self.currentContainerView.layer.mask = nil;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user