@@ -288,12 +288,14 @@ static void renderInsetShadows(
288
288
CALayer *layer)
289
289
{
290
290
CGRect boundingRect = RCTGetBoundingRect (shadows, layer.bounds .size );
291
- #if !TARGET_OS_OSX // [macOS]
292
- UIGraphicsImageRendererFormat *const rendererFormat = [UIGraphicsImageRendererFormat defaultFormat ];
293
- UIGraphicsImageRenderer *const renderer = [[UIGraphicsImageRenderer alloc ] initWithSize: boundingRect.size
294
- format: rendererFormat];
291
+ // [macOS Use RCTUIGraphicsImageRenderer shim
292
+ RCTUIGraphicsImageRendererFormat *const rendererFormat = [RCTUIGraphicsImageRendererFormat defaultFormat ];
293
+ RCTUIGraphicsImageRenderer *const renderer = [[RCTUIGraphicsImageRenderer alloc ] initWithSize: boundingRect.size
294
+ format: rendererFormat];
295
+ // macOS]
296
+
295
297
UIImage *const boxShadowImage =
296
- [renderer imageWithActions: ^(UIGraphicsImageRendererContext *_Nonnull rendererContext) {
298
+ [renderer imageWithActions: ^(RCTUIGraphicsImageRendererContext *_Nonnull rendererContext) { // [macOS]
297
299
auto [outsetShadows, insetShadows] = splitBoxShadowsByInset (shadows);
298
300
const CGContextRef context = rendererContext.CGContext ;
299
301
// Outset shadows should be before inset shadows since outset needs to
@@ -303,22 +305,6 @@ static void renderInsetShadows(
303
305
renderOutsetShadows (outsetShadows, cornerRadii, layer, boundingRect, context);
304
306
renderInsetShadows (insetShadows, cornerRadii, edgeInsets, layer, boundingRect, context);
305
307
}];
306
- #else // [macOS
307
- UIGraphicsBeginImageContextWithOptions (boundingRect.size , YES , 0.0 );
308
- CGContextRef context = UIGraphicsGetCurrentContext ();
309
-
310
- // Mostly copied from above iOS block
311
- auto [outsetShadows, insetShadows] = splitBoxShadowsByInset (shadows);
312
- // Outset shadows should be before inset shadows since outset needs to
313
- // clear out a region in the view so we do not block its contents.
314
- // Inset shadows could draw over those outset shadows but if the shadow
315
- // colors have alpha < 1 then we will have inaccurate alpha compositing
316
- renderOutsetShadows (outsetShadows, cornerRadii, layer, boundingRect, context);
317
- renderInsetShadows (insetShadows, cornerRadii, edgeInsets, layer, boundingRect, context);
318
-
319
- UIImage *boxShadowImage = UIGraphicsGetImageFromCurrentImageContext ();
320
- UIGraphicsEndImageContext ();
321
- #endif // macOS]
322
308
323
309
return boxShadowImage;
324
310
}
0 commit comments