Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transforms #1035

Merged
merged 6 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions React/Views/RCTView.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
/**
* macOS Properties
*/

@property (nonatomic, assign) CATransform3D transform3D;

@property (nonatomic, copy) RCTDirectEventBlock onDoubleClick;
@property (nonatomic, copy) RCTDirectEventBlock onClick;
@property (nonatomic, copy) RCTDirectEventBlock onMouseEnter;
Expand Down
14 changes: 14 additions & 0 deletions React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ - (instancetype)initWithFrame:(CGRect)frame
_borderBottomEndRadius = -1;
_borderStyle = RCTBorderStyleSolid;
_hitTestEdgeInsets = UIEdgeInsetsZero;
#if TARGET_OS_OSX // TODO(macOS GH#774)
_transform3D = CATransform3DIdentity;
#endif // TODO(macOS GH#774)

_backgroundColor = super.backgroundColor;
}
Expand Down Expand Up @@ -1169,6 +1172,17 @@ - (void)displayLayer:(CALayer *)layer
backgroundColor = _backgroundColor.CGColor;
#endif

#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
CATransform3D transform = self.transform3D;
Saadnajmi marked this conversation as resolved.
Show resolved Hide resolved
if (layer.anchorPoint.x == 0 && layer.anchorPoint.y == 0 && !CATransform3DEqualToTransform(transform, CATransform3DIdentity)) {
// This compensates for the fact that layer.anchorPoint is {0, 0} instead of {0.5, 0.5} on macOS for some reason.
Saadnajmi marked this conversation as resolved.
Show resolved Hide resolved
CATransform3D originAdjust = CATransform3DTranslate(CATransform3DIdentity, self.frame.size.width / 2, self.frame.size.height / 2, 0);
transform = CATransform3DConcat(CATransform3DConcat(CATransform3DInvert(originAdjust), transform), originAdjust);
// Enable edge antialiasing in perspective transforms
layer.allowsEdgeAntialiasing = !(transform.m34 == 0.0f);
}
layer.transform = transform;
#endif // ]TODO(macOS ISS#2323203)
if (useIOSBorderRendering) {
layer.cornerRadius = cornerRadii.topLeft;
layer.borderColor = borderColors.left;
Expand Down
17 changes: 9 additions & 8 deletions React/Views/RCTViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,16 @@ - (RCTShadowView *)shadowView

RCT_CUSTOM_VIEW_PROPERTY(transform, CATransform3D, RCTView)
{
#if !TARGET_OS_OSX // TODO(macOS GH#774)
#if TARGET_OS_OSX // [TODO(macOS GH#460)
CATransform3D transform = json ? [RCTConvert CATransform3D:json] : defaultView.layer.transform;
view.transform3D = transform;
[view setNeedsDisplay];
#else // ]TODO(macOS GH#460)]
view.layer.transform = json ? [RCTConvert CATransform3D:json] : defaultView.layer.transform;
// Enable edge antialiasing in perspective transforms
view.layer.allowsEdgeAntialiasing = !(view.layer.transform.m34 == 0.0f);
#elif TARGET_OS_OSX // [TODO(macOS GH#774)
view.layer.sublayerTransform = json ? [RCTConvert CATransform3D:json] : defaultView.layer.sublayerTransform;
// TODO: Improve this by enabling edge antialiasing only for transforms with rotation or skewing
view.layer.edgeAntialiasingMask = !CATransform3DIsIdentity(view.layer.sublayerTransform) ? kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge : 0;
#endif // ]TODO(macOS GH#774)
// Enable edge antialiasing in rotation, skew, or perspective transforms
view.layer.allowsEdgeAntialiasing =
view.layer.transform.m12 != 0.0f || view.layer.transform.m21 != 0.0f || view.layer.transform.m34 != 0.0f;
#endif // [TODO(macOS GH#460)]
}

RCT_CUSTOM_VIEW_PROPERTY(accessibilityRole, UIAccessibilityTraits, RCTView)
Expand Down
58 changes: 29 additions & 29 deletions packages/rn-tester/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ SPEC CHECKSUMS:
boost-for-react-native: 8f7c9ecfe357664c072ffbe2432569667cbf1f1b
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: ed15e075aa758ac0e4c1f8b830bd4e4d40d669e8
FBLazyVector: c6aa9a9619d963282360abc4bb47d2712717504e
FBReactNativeSpec: 0ca7ec65c7f09ab67e221ac5f0532b8385bc2138
FBLazyVector: 054b1d12a7c6b1c2b3f0a9023add2c4759ecfb20
FBReactNativeSpec: 74dfd0339847eb7426c380dd90f0cec40b49ed92
Flipper: 30e8eeeed6abdc98edaf32af0cda2f198be4b733
Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c
Expand All @@ -558,34 +558,34 @@ SPEC CHECKSUMS:
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b
RCT-Folly: 43adc9ce880eb76792f88c011773cb5c664c1419
RCTRequired: 633fe8690af80ea0d6d1743ea0fbeee6a8de0978
RCTTypeSafety: 2a1aa8c0ffa214900ea5e96dd1ce844be196decc
React: 4f7007b4f9f59b3d935cfc415e0b3e3dd03d2021
React-callinvoker: 775c5ec2ad1d1b7f0f4a8458397bfd68aced33a7
React-Core: b1cdd30e896e76499480e4603f5cad119d238885
React-CoreModules: c6609f09932ba5fc8dae3c20f8ba294653159370
React-cxxreact: 3d44d388b2feccc0d6b2f0735cf4ac78f71c26be
React-jsi: 743b50fb3db21ad787c384fd6601c7e3e6784dec
React-jsiexecutor: cc19fe20e9f6c261c8f1eed5727f2b724f945494
React-jsinspector: 90fbbc33233c45021327ddd921f5b91622c77190
React-logger: 4f94752a4d8e071ac861865ea5f1d341650b6d70
React-perflogger: 0eaad01e3aaefb12799c39333d0b584dd5b4dae8
React-RCTActionSheet: e80fd63af2c04195f544a51f237f0bb8c999ba02
React-RCTAnimation: 5827d917ff6c716a50b0008856ffb1772578c446
React-RCTBlob: cd43b543b917d9b66eb303dc08c4058f7b3e52c4
React-RCTImage: 9d0661b1b0de30e825cadd8b94fefb6b8485b370
React-RCTLinking: 1e0f88ba8ecc3e36fe7f4ca89e3a7bb8ba9b033d
React-RCTNetwork: c9ac771311a39f42c43ad5633f090e2d01d2710d
React-RCTPushNotification: 9398208d33368b68b6afb3887c04e3f5ae1c7049
React-RCTSettings: 99d2d69f4183c6e9ef89ba589a8dc77c6465a2c8
React-RCTTest: a57ea516520309b75fc9c152847beedf26c7926e
React-RCTText: 0732843b7d073ae2dd7687b95774a534c0fae0fb
React-RCTVibration: 8a50e8ddd4402a7b123fcfe41efd1220d1b23798
React-runtimeexecutor: 8993403523caba788cd6483b26a6e67384ec2224
RCTRequired: ca094c43afd9d5e23bd5d6f6fe03dc3b05e32789
RCTTypeSafety: cf59b3fc63a51a4c5b43fda54bfd13ec67e1fe0a
React: 3f1424fcf6908c28476ca1529a470ce80db44468
React-callinvoker: c55a5c7ea308ef5408cdfd763f6a9372aca33c7b
React-Core: a174c2ab1cf7dce900e14d0f70090aff3b87a1c9
React-CoreModules: a726a0c1eebd2c4fc204d8202341d3b03e0a8f08
React-cxxreact: 54d5c362781774f7c0f209ea76fa94912a321dfe
React-jsi: 9df07fea949ad07ab09de6d1a499aba91618a476
React-jsiexecutor: 94f88b58bd75d55ee8fa9c102bb56cd4b81d9e07
React-jsinspector: c27fb20be63a3803d690bbd7ce7397b09bbf1202
React-logger: 25724cc2b94f0ed2224bcd6e4d491c2f6b22b665
React-perflogger: f0ae4e788178f3aa3cb03fdcd2de497e76f619bc
React-RCTActionSheet: 55adc5c5d31faeacb1705e7f25c234626c26138d
React-RCTAnimation: b65c7b8e3ba6af40a3a8d8cb350c15b24b6501c0
React-RCTBlob: 6217b9e8d21ab928acfefc46a1f2dbbcf1762d24
React-RCTImage: be1b911af11743c8022b9213d5afea95d9a1f7d1
React-RCTLinking: d3998f76eaf10c0b4f5e96f745b03235982dbe32
React-RCTNetwork: 5d385d162b7158a22a29d2a1b6cc8f0ee8edf295
React-RCTPushNotification: daf1e1b47a353376df853cdfc3fb52a6d251291d
React-RCTSettings: 74464a1247a3114b203f6f2d9fd55a0a5f58eb06
React-RCTTest: bddf83750a39cf959032c3abc43bf14d6a25eefc
React-RCTText: 80f4051c7b4d4acde3d013ffbebae300ee66b6bd
React-RCTVibration: c57eaf498becdea0b39512a8d42ba567c26c94a1
React-runtimeexecutor: 3be4f391623754b3b541bfb058eb532a2bd3414d
React-TurboModuleCxx-RNW: f2e32cbfced49190a61d66c993a8975de79a158a
React-TurboModuleCxx-WinRTPort: e7647958397b6cdafa0deb18f9db886d6acf6fcf
ReactCommon: 90d5510f055f513dd4f1123ef1883062903b56b8
Yoga: d7d6de52ed443bd01bfa17cb314b95e86876289b
React-TurboModuleCxx-WinRTPort: adde9db07b10a903209d90589d04162207c19436
ReactCommon: 15ba207ca06ba2a43a54cc6a803afce4ca7ba40c
Yoga: 1abf3d975376ca1e26bee987104cdd40b97050e8
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: c7a7110b242497f2bf323ba74caedb9ee61ee05e
Expand Down
4 changes: 2 additions & 2 deletions packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
Saadnajmi marked this conversation as resolved.
Show resolved Hide resolved
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -1953,7 +1953,7 @@
ENABLE_BITCODE = NO;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
Expand Down