mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-25 12:55:41 +08:00
Fabric: Using finalizeUpdates: in RCTViewComponentView
Summary: Previously we could call `invalidateLayer` twice during a mounting transaction (one for update-props, one for update-layout-metrics), that was sub-optimal. Now, with `finalizeUpdates:` we can do it only once. That should save us some CPU cycles. Reviewed By: JoshuaGross Differential Revision: D14896802 fbshipit-source-id: b6572fb2a4fa48a12b1d1c29144cd7c67f6cff80
This commit is contained in:
committed by
Facebook Github Bot
parent
f4fd1831da
commit
6392894e59
@@ -21,6 +21,7 @@ using namespace facebook::react;
|
||||
@implementation RCTViewComponentView {
|
||||
UIColor *_backgroundColor;
|
||||
CALayer *_borderLayer;
|
||||
BOOL _needsInvalidateLayer;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
@@ -245,9 +246,7 @@ using namespace facebook::react;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (needsInvalidateLayer) {
|
||||
[self invalidateLayer];
|
||||
}
|
||||
_needsInvalidateLayer = _needsInvalidateLayer || needsInvalidateLayer;
|
||||
}
|
||||
|
||||
- (void)updateEventEmitter:(SharedEventEmitter)eventEmitter
|
||||
@@ -258,10 +257,19 @@ using namespace facebook::react;
|
||||
|
||||
- (void)updateLayoutMetrics:(LayoutMetrics)layoutMetrics oldLayoutMetrics:(LayoutMetrics)oldLayoutMetrics
|
||||
{
|
||||
_layoutMetrics = layoutMetrics;
|
||||
|
||||
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
||||
|
||||
_layoutMetrics = layoutMetrics;
|
||||
_needsInvalidateLayer = YES;
|
||||
}
|
||||
|
||||
- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask
|
||||
{
|
||||
if (!_needsInvalidateLayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
_needsInvalidateLayer = NO;
|
||||
[self invalidateLayer];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user