From e6ef47aff8361f3d0fd7748165d3744549f3dbd4 Mon Sep 17 00:00:00 2001 From: Joe Vilches Date: Wed, 31 Jul 2024 10:13:20 -0700 Subject: [PATCH] Simplify some clipping logic for inset shadows (#45678) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45678 This doesn't need to be an explicit path, its just tracing out a rect. CG has a method for that Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D60202842 fbshipit-source-id: 61faa21e57b1341c3b96961f12503eb4a7f3020b --- .../react-native/React/Fabric/Utils/RCTBoxShadow.mm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/react-native/React/Fabric/Utils/RCTBoxShadow.mm b/packages/react-native/React/Fabric/Utils/RCTBoxShadow.mm index 1a9438fa335..4918f6d199f 100644 --- a/packages/react-native/React/Fabric/Utils/RCTBoxShadow.mm +++ b/packages/react-native/React/Fabric/Utils/RCTBoxShadow.mm @@ -183,15 +183,10 @@ static void renderInsetShadows( // First, create a clipping area so we only draw within the view's bounds. // If we do not do this, blur artifacts will show up outside the view. - CGMutablePathRef outerPath = CGPathCreateMutable(); - CGPathMoveToPoint(outerPath, nil, 0, 0); - CGPathAddLineToPoint(outerPath, nil, boundingRect.size.width, 0); - CGPathAddLineToPoint(outerPath, nil, boundingRect.size.width, boundingRect.size.height); - CGPathAddLineToPoint(outerPath, nil, 0, boundingRect.size.height); - CGPathCloseSubpath(outerPath); + CGRect outerClippingRect = CGRectMake(0, 0, boundingRect.size.width, boundingRect.size.height); // Add the path twice so we only draw inside the view with the EO crop rule - CGContextAddPath(context, outerPath); - CGContextAddPath(context, outerPath); + CGContextAddRect(context, outerClippingRect); + CGContextAddRect(context, outerClippingRect); const RCTCornerInsets cornerInsetsForLayer = RCTGetCornerInsets(cornerRadiiForBoxShadow(cornerRadii, 0), UIEdgeInsetsZero); CGPathRef layerPath = RCTPathCreateWithRoundedRect(