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
This commit is contained in:
Joe Vilches
2024-07-31 10:13:20 -07:00
committed by Facebook GitHub Bot
parent 71b5f04986
commit e6ef47aff8
@@ -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(