From a9eb57f644673f58064e19f1a98b6ea9f6cef943 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Mon, 16 Oct 2023 04:18:41 -0700 Subject: [PATCH] Enable edgeAntiAliasing only for specific transforms (#40943) Summary: We should enable antialiasing when it's necessary, as it's an expensive property. Scale and Translate transforms shouldn't enable it. Source: https://github.com/facebook/react-native/pull/32920 Changelog: [iOS][Changed] Matched behaviour for allowsEdgeAntialiasing to old architecture. Reviewed By: sammy-SC Differential Revision: D50270444 --- .../Mounting/ComponentViews/View/RCTViewComponentView.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index 6f250cab92921b..bab5f1ee526ec3 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -265,8 +265,11 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & oldViewProps.transformOrigin != newViewProps.transformOrigin) && ![_propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN containsObject:@"transform"]) { auto newTransform = newViewProps.resolveTransform(_layoutMetrics); - self.layer.transform = RCTCATransform3DFromTransformMatrix(newTransform); - self.layer.allowsEdgeAntialiasing = newViewProps.transform != Transform::Identity(); + CATransform3D caTransform = RCTCATransform3DFromTransformMatrix(newTransform); + + self.layer.transform = caTransform; + // Enable edge antialiasing in rotation, skew, or perspective transforms + self.layer.allowsEdgeAntialiasing = caTransform.m12 != 0.0f || caTransform.m21 != 0.0f || caTransform.m34 != 0.0f; } // `hitSlop`