@@ -61,7 +61,6 @@ UIKIT_STATIC_INLINE void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath
6161#define RCTUIScrollView UIScrollView
6262#define RCTPlatformImage UIImage
6363
64-
6564UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent (RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
6665{
6766 return [view hitTest: point withEvent: event];
@@ -268,7 +267,6 @@ extern "C" {
268267
269268// UIGraphics.h
270269CGContextRef UIGraphicsGetCurrentContext (void );
271- CGImageRef UIImageGetCGImageRef (NSImage *image);
272270
273271#ifdef __cplusplus
274272}
@@ -334,18 +332,30 @@ NS_INLINE NSEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat botto
334332#define UIApplication NSApplication
335333
336334// UIImage
335+ // RCTUIImage is a subclass of NSImage that caches its CGImage representation.
336+ // This is needed because NSImage's CGImageForProposedRect: returns a new autoreleased
337+ // CGImage each time, which causes issues when used with CALayer.contents.
338+ @interface RCTUIImage : NSImage
339+ @property (nonatomic , readonly , nullable ) CGImageRef CGImage;
340+ @property (nonatomic , readonly ) CGFloat scale;
341+ @end
342+
337343typedef NS_ENUM (NSInteger , UIImageRenderingMode) {
338344 UIImageRenderingModeAlwaysOriginal,
339345 UIImageRenderingModeAlwaysTemplate,
340346};
341347
342348#ifdef __cplusplus
343- extern " C"
349+ extern " C" {
344350#endif
345- CGFloat UIImageGetScale (NSImage *image);
346351
352+ CGFloat UIImageGetScale (NSImage *image);
347353CGImageRef UIImageGetCGImageRef (NSImage *image);
348354
355+ #ifdef __cplusplus
356+ }
357+ #endif
358+
349359NS_INLINE NSImage *UIImageWithContentsOfFile (NSString *filePath)
350360{
351361 return [[NSImage alloc ] initWithContentsOfFile: filePath];
@@ -626,7 +636,7 @@ typedef void (^RCTUIGraphicsImageDrawingActions)(RCTUIGraphicsImageRendererConte
626636
627637- (instancetype )initWithSize : (CGSize)size ;
628638- (instancetype )initWithSize : (CGSize)size format : (RCTUIGraphicsImageRendererFormat *)format ;
629- - (NSImage *)imageWithActions : (NS_NOESCAPE RCTUIGraphicsImageDrawingActions)actions ;
639+ - (RCTUIImage *)imageWithActions : (NS_NOESCAPE RCTUIGraphicsImageDrawingActions)actions ;
630640
631641@end
632642NS_ASSUME_NONNULL_END
0 commit comments