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

[ios] : Add allowsEdgeAntialiasing on views with rotations or skew tr… #32920

Conversation

Arkolos
Copy link

@Arkolos Arkolos commented Jan 19, 2022

…ansforms

Summary

On iOS, if a View is rotated with the a transform (e.g. <View style={{transform: {rotationZ: 5}}} />), the view has aliasing (see screenshot). Same for a skew transformation. We don't have the issue on Android

This behavior had originally being fixed by this PR #1999

However a new PR was merge ( #19360 ) that broke this. I think it was made to add antialiasing during perspective transforms but seems to have broken the antialiasing when rotationZ transforms

This PR adds back the antialising during rotation transform , while keeping it during perspective transform.

Changelog

I changed the allowsEdgeAntialiasing condition, making it "true" when the m12 or m21 is not 0. From this article https://medium.com/swlh/understanding-3d-matrix-transforms-with-pixijs-c76da3f8bd8 , I've understood that in all rotation or skew transformations, m12 or m21 is different than 0 . In the other transformation (e.g. scale or translate) it stays at 0.

Although, I'm not a matrix transformation expert so I may be mistaken

Test Plan

I've written several views with all rotateX/Y/Z , skewX,Y and perpective transformation. Before the PR some transformation was showing aliasing on iOS (e.g. top-left view in the screenshot, don't hesitate to zoom in the image if you don't see it) and with this PR it does not have anymore

Before

Simulator Screen Shot - iPhone 13 - 2022-01-19 at 10 09 35

After
Simulator Screen Shot - iPhone 13 - 2022-01-19 at 10 10 39

Code I used to test

const commonStyle = {
  width: 150,
  height: 100,
  backgroundColor: "red",
  margin: 10,
}

const Test = () => (
  <View style={{ flexDirection: "row" }}>
    <View>
      <View
        style={[
          commonStyle,
          {
            transform: [{ rotateZ: "4deg" }],
          },
        ]}
      />

      <View
        style={[
          commonStyle,
          {
            transform: [{ rotateX: "30deg" }],
          },
        ]}
      />

      <View
        style={[
          commonStyle,
          {
            transform: [{ rotateY: "30deg" }],
          },
        ]}
      />
      <View
        style={[
          commonStyle,
          {
            transform: [{ rotateX: "30deg" }, { rotateY: "30deg" }, { rotateZ: "3deg" }],
          },
        ]}
      />
    </View>

    <View>
      <View
        style={[
          commonStyle,
          {
            transform: [{ skewX: "4deg" }],
          },
        ]}
      />

      <View
        style={[
          commonStyle,
          {
            transform: [{ skewY: "4deg" }],
          },
        ]}
      />

      <View
        style={[
          commonStyle,
          {
            transform: [{ skewY: "4deg" }, { rotateZ: "3deg" }],
          },
        ]}
      />

      <View
        style={[
          commonStyle,
          {
            transform: [{ perspective: 1000 }],
          },
        ]}
      />
    </View>
  </View>
)

@facebook-github-bot
Copy link
Contributor

Hi @Arkolos!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@pull-bot
Copy link

Messages
📖

📋 Verify Changelog Format - A changelog entry has the following format: [CATEGORY] [TYPE] - Message.

CATEGORY may be:
  • General
  • iOS
  • Android
  • JavaScript
  • Internal (for changes that do not need to be called out in the release notes)

TYPE may be:

  • Added, for new features.
  • Changed, for changes in existing functionality.
  • Deprecated, for soon-to-be removed features.
  • Removed, for now removed features.
  • Fixed, for any bug fixes.
  • Security, in case of vulnerabilities.

MESSAGE may answer "what and why" on a feature level. Use this to briefly tell React Native users about notable changes.

Generated by 🚫 dangerJS against 711c29d

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: a46a99e
Branch: main

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,291,740 +39
android hermes armeabi-v7a 7,628,853 +17
android hermes x86 8,764,465 +22
android hermes x86_64 8,701,385 +33
android jsc arm64-v8a 9,678,788 -59
android jsc armeabi-v7a 8,672,595 -68
android jsc x86 9,637,021 -69
android jsc x86_64 10,231,535 -64

Base commit: a46a99e
Branch: main

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 19, 2022
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jan 19, 2022
@facebook-github-bot
Copy link
Contributor

@sshic has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@RomualdPercereau
Copy link

Any news on this?

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by Mattéo Martin in e6a3410.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Jan 24, 2022
javache added a commit to javache/react-native that referenced this pull request Oct 13, 2023
Summary:
We should enable antialiasing when it's necessary, as it's an expensive property. Scale and Translate transforms shouldn't enable it.

Source: facebook#32920

Changelog: [iOS][Changed] Matched behaviour for allowsEdgeAntialiasing to old architecture.

Differential Revision: D50270444
javache added a commit to javache/react-native that referenced this pull request Oct 16, 2023
Summary:

We should enable antialiasing when it's necessary, as it's an expensive property. Scale and Translate transforms shouldn't enable it.

Source: facebook#32920

Changelog: [iOS][Changed] Matched behaviour for allowsEdgeAntialiasing to old architecture.

Reviewed By: sammy-SC

Differential Revision: D50270444
javache added a commit to javache/react-native that referenced this pull request Oct 16, 2023
Summary:

We should enable antialiasing when it's necessary, as it's an expensive property. Scale and Translate transforms shouldn't enable it.

Source: facebook#32920

Changelog: [iOS][Changed] Matched behaviour for allowsEdgeAntialiasing to old architecture.

Reviewed By: sammy-SC

Differential Revision: D50270444
javache added a commit to javache/react-native that referenced this pull request Oct 16, 2023
Summary:

We should enable antialiasing when it's necessary, as it's an expensive property. Scale and Translate transforms shouldn't enable it.

Source: facebook#32920

Changelog: [iOS][Changed] Matched behaviour for allowsEdgeAntialiasing to old architecture.

Reviewed By: sammy-SC

Differential Revision: D50270444
facebook-github-bot pushed a commit that referenced this pull request Oct 16, 2023
Summary:
Pull Request resolved: #40943

We should enable antialiasing when it's necessary, as it's an expensive property. Scale and Translate transforms shouldn't enable it.

Source: #32920

Changelog: [iOS][Changed] Matched behaviour for allowsEdgeAntialiasing to old architecture.

Reviewed By: sammy-SC

Differential Revision: D50270444

fbshipit-source-id: 8a08039c42f8fb855db2ace140124c33f18dc3bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants