Skip to content

Commit 68f6ece

Browse files
authored
feat(0.79): Implement RCTPerfMonitor (#2804)
1 parent eaec0c4 commit 68f6ece

5 files changed

Lines changed: 381 additions & 67 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
__default__: patch
3+
---
4+
5+
feat: implement RCTPerfMonitor

packages/react-native/React/Base/RCTUIKit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ UIKIT_STATIC_INLINE CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path)
6464
#define RCTPlatformView UIView
6565
#define RCTUIView UIView
6666
#define RCTUIScrollView UIScrollView
67+
#define RCTUIPanGestureRecognizer UIPanGestureRecognizer
6768

6869
UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
6970
{
@@ -337,6 +338,7 @@ NS_INLINE NSEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat botto
337338
// UIGestureRecognizer
338339
#define UIGestureRecognizer NSGestureRecognizer
339340
#define UIGestureRecognizerDelegate NSGestureRecognizerDelegate
341+
#define RCTUIPanGestureRecognizer NSPanGestureRecognizer
340342

341343
// UIApplication
342344
#define UIApplication NSApplication

packages/react-native/React/CoreModules/RCTDevMenu.mm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,12 @@ - (void)setDefaultJSBundle
326326
}]];
327327
}
328328

329-
#if !TARGET_OS_OSX // [macOS]
330329
id perfMonitorItemOpaque = [_moduleRegistry moduleForName:"PerfMonitor"];
331330
SEL devMenuItem = @selector(devMenuItem);
332331
if ([perfMonitorItemOpaque respondsToSelector:devMenuItem]) {
333332
RCTDevMenuItem *perfMonitorItem = [perfMonitorItemOpaque devMenuItem];
334333
[items addObject:perfMonitorItem];
335334
}
336-
#endif // [macOS]
337335

338336
[items
339337
addObject:[RCTDevMenuItem

packages/react-native/React/CoreModules/RCTFPSGraph.mm

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#if !TARGET_OS_OSX // [macOS
9-
108
#import <React/RCTFPSGraph.h>
119

1210
#import <React/RCTAssert.h>
11+
#import <React/RCTUIKit.h> // [macOS]
12+
#if TARGET_OS_OSX // [macOS
13+
#import <QuartzCore/QuartzCore.h>
14+
#endif // macOS]
1315

1416
#if RCT_DEV
1517

1618
@interface RCTFPSGraph ()
1719

1820
@property (nonatomic, strong, readonly) CAShapeLayer *graph;
19-
@property (nonatomic, strong, readonly) UILabel *label;
21+
@property (nonatomic, strong, readonly) RCTUILabel *label; // [macOS]
2022

2123
@end
2224

2325
@implementation RCTFPSGraph {
2426
CAShapeLayer *_graph;
25-
UILabel *_label;
27+
RCTUILabel *_label; // [macOS]
2628

2729
CGFloat *_frames;
2830
RCTUIColor *_color; // [macOS]
@@ -40,6 +42,9 @@ @implementation RCTFPSGraph {
4042
- (instancetype)initWithFrame:(CGRect)frame color:(RCTUIColor *)color // [macOS]
4143
{
4244
if ((self = [super initWithFrame:frame])) {
45+
#if TARGET_OS_OSX // [macOS
46+
self.wantsLayer = YES;
47+
#endif // macOS]
4348
_frameCount = -1;
4449
_prevTime = -1;
4550
_maxFPS = 0;
@@ -76,10 +81,10 @@ - (CAShapeLayer *)graph
7681
return _graph;
7782
}
7883

79-
- (UILabel *)label
84+
- (RCTUILabel *)label // [macOS]
8085
{
8186
if (!_label) {
82-
_label = [[UILabel alloc] initWithFrame:self.bounds];
87+
_label = [[RCTUILabel alloc] initWithFrame:self.bounds];
8388
_label.font = [UIFont boldSystemFontOfSize:13];
8489
_label.textAlignment = NSTextAlignmentCenter;
8590
}
@@ -128,5 +133,3 @@ - (void)onTick:(NSTimeInterval)timestamp
128133
@end
129134

130135
#endif
131-
132-
#endif // macOS]

0 commit comments

Comments
 (0)