-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Add backface-visibility support on Android #15970
Conversation
@facebook-github-bot label Core Team Generated by 🚫 dangerJS |
I could imagine this would be a good thing to have screenshot tests for on both ios and android to ensure it doesn't break in the future. |
i think there is an example for ios in RNTester. @charpeni would be nice to get that in for android too |
setBackfaceVisibilityDependantOpacity(); | ||
} | ||
|
||
public void decomposeMatrix(ReadableArray matrix) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just use View#getRotationX and View#getRotationY instead of keeping our own transform info here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
float rotationX = (float) sMatrixDecompositionContext.rotationDegrees[0]; | ||
float rotationY = (float) sMatrixDecompositionContext.rotationDegrees[1]; | ||
|
||
boolean isFrontfaceVisible = (rotationX >= -90.f && rotationX < 90.f) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could a negative scale affect the backface visibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Negative degrees are handled.
flipAnimation.interpolate({
inputRange: [0, 180],
outputRange: ['0deg', '180deg'],
});
flipAnimation.interpolate({
inputRange: [0, 180],
outputRange: ['0deg', '-180deg'],
});
Yea screenshot test for this would amazing |
@charpeni I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
I'll do the requested changes. |
25a89c9
to
54709a4
Compare
@chirag04 The example was already there for both platforms, I've updated the PR with RNTester screenshots. @TheSavior @janicduplessis I can find snapshot tests, but I can't find anything related to screenshot tests, is this setup internally? |
I think this link might be the right thing: https://facebook.github.io/react-native/docs/testing.html#screenshot-snapshot-tests |
Oh I see, they're the same/bundle that's why screenshots were referring to snapshots. Thanks Eli! |
any update on this issue? |
Please, would be awesome to get backfaceVisibility working on Android. |
It looks like the added screenshots include a screenshot for front, but not for back. Support for the back surface is the main thing being added in this diff, right? We should probably have a screenshot for that. |
367bba1
to
5bbb738
Compare
Actually, the initial issue with backface visibility is that the second view (back) was always drawn on the first view (front). So, the front view was showing the backface with a rotation as shown here: So, if we can see the front view, it means the backface visibility should work or you don't have a backface. Anyway, just to be sure have add both cases in RNTester, updated screenshots, and rebase on master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hramos is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
5bbb738
to
526f509
Compare
@hramos Any chance you can take another look at this? Much appreciated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hramos is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@charpeni merged commit 0cce0a6 into Once this commit is added to a release, you will see the corresponding version tag below the description at 0cce0a6. If the commit has a single |
Summary: `backfaceVisibility` was only available on iOS and 3D transformations were lacking on Android. Backface Visibility is computed from ~the decomposed matrix of transform prop~ the view with their rotation degree values. ~`MatrixDecompositionContext` properties have been made public so we can access to decomposed matrix values from outside (`ReactViewGroup`).~ I'm not sure if this is the best implementation, so if it's not let's discuss it. cc janicduplessis foghina Tested in https://github.com/charpeni/react-native-backface-visibility. | Before | Now | | - | - | | <img src="https://user-images.githubusercontent.com/7189823/30123717-e5361598-9300-11e7-8e2e-a87a7a8d896a.gif" width="260" /> | <img src="https://user-images.githubusercontent.com/7189823/30514997-4d203572-9aee-11e7-8542-bfde41678eb6.gif" width="244" /> | | iOS | Android | | - | - | | <img src="https://user-images.githubusercontent.com/7189823/36995899-609513b4-2083-11e8-9834-ee44c1a292e1.gif" width="300" /> | <img src="https://user-images.githubusercontent.com/7189823/36995978-9ed3b158-2083-11e8-841e-b9e3357d2509.gif" width="240" /> | [ANDROID] [FEATURE] [ReactViewGroup] - Add backface-visibility support on Android Pull Request resolved: facebook#15970 Differential Revision: D9411130 Pulled By: hramos fbshipit-source-id: 62f646a4de37d83922286cb98893a95b55fa889e
Summary: `backfaceVisibility` was only available on iOS and 3D transformations were lacking on Android. Backface Visibility is computed from ~the decomposed matrix of transform prop~ the view with their rotation degree values. ~`MatrixDecompositionContext` properties have been made public so we can access to decomposed matrix values from outside (`ReactViewGroup`).~ I'm not sure if this is the best implementation, so if it's not let's discuss it. cc janicduplessis foghina Tested in https://github.com/charpeni/react-native-backface-visibility. | Before | Now | | - | - | | <img src="https://user-images.githubusercontent.com/7189823/30123717-e5361598-9300-11e7-8e2e-a87a7a8d896a.gif" width="260" /> | <img src="https://user-images.githubusercontent.com/7189823/30514997-4d203572-9aee-11e7-8542-bfde41678eb6.gif" width="244" /> | | iOS | Android | | - | - | | <img src="https://user-images.githubusercontent.com/7189823/36995899-609513b4-2083-11e8-9834-ee44c1a292e1.gif" width="300" /> | <img src="https://user-images.githubusercontent.com/7189823/36995978-9ed3b158-2083-11e8-841e-b9e3357d2509.gif" width="240" /> | [ANDROID] [FEATURE] [ReactViewGroup] - Add backface-visibility support on Android Pull Request resolved: facebook#15970 Differential Revision: D9411130 Pulled By: hramos fbshipit-source-id: 62f646a4de37d83922286cb98893a95b55fa889e
Summary: `backfaceVisibility` was only available on iOS and 3D transformations were lacking on Android. Backface Visibility is computed from ~the decomposed matrix of transform prop~ the view with their rotation degree values. ~`MatrixDecompositionContext` properties have been made public so we can access to decomposed matrix values from outside (`ReactViewGroup`).~ I'm not sure if this is the best implementation, so if it's not let's discuss it. cc janicduplessis foghina Tested in https://github.com/charpeni/react-native-backface-visibility. | Before | Now | | - | - | | <img src="https://user-images.githubusercontent.com/7189823/30123717-e5361598-9300-11e7-8e2e-a87a7a8d896a.gif" width="260" /> | <img src="https://user-images.githubusercontent.com/7189823/30514997-4d203572-9aee-11e7-8542-bfde41678eb6.gif" width="244" /> | | iOS | Android | | - | - | | <img src="https://user-images.githubusercontent.com/7189823/36995899-609513b4-2083-11e8-9834-ee44c1a292e1.gif" width="300" /> | <img src="https://user-images.githubusercontent.com/7189823/36995978-9ed3b158-2083-11e8-841e-b9e3357d2509.gif" width="240" /> | [ANDROID] [FEATURE] [ReactViewGroup] - Add backface-visibility support on Android Pull Request resolved: facebook/react-native#15970 Differential Revision: D9411130 Pulled By: hramos fbshipit-source-id: 62f646a4de37d83922286cb98893a95b55fa889e
Summary: `backfaceVisibility` was only available on iOS and 3D transformations were lacking on Android. Backface Visibility is computed from ~the decomposed matrix of transform prop~ the view with their rotation degree values. ~`MatrixDecompositionContext` properties have been made public so we can access to decomposed matrix values from outside (`ReactViewGroup`).~ I'm not sure if this is the best implementation, so if it's not let's discuss it. cc janicduplessis foghina Tested in https://github.com/charpeni/react-native-backface-visibility. | Before | Now | | - | - | | <img src="https://user-images.githubusercontent.com/7189823/30123717-e5361598-9300-11e7-8e2e-a87a7a8d896a.gif" width="260" /> | <img src="https://user-images.githubusercontent.com/7189823/30514997-4d203572-9aee-11e7-8542-bfde41678eb6.gif" width="244" /> | | iOS | Android | | - | - | | <img src="https://user-images.githubusercontent.com/7189823/36995899-609513b4-2083-11e8-9834-ee44c1a292e1.gif" width="300" /> | <img src="https://user-images.githubusercontent.com/7189823/36995978-9ed3b158-2083-11e8-841e-b9e3357d2509.gif" width="240" /> | [ANDROID] [FEATURE] [ReactViewGroup] - Add backface-visibility support on Android Pull Request resolved: facebook#15970 Differential Revision: D9411130 Pulled By: hramos fbshipit-source-id: 62f646a4de37d83922286cb98893a95b55fa889e
backfaceVisibility
was only available on iOS and 3D transformations were lacking on Android.Backface Visibility is computed from
the decomposed matrix of transform propthe view with their rotation degree values.MatrixDecompositionContext
properties have been made public so we can access to decomposed matrix values from outside (ReactViewGroup
).I'm not sure if this is the best implementation, so if it's not let's discuss it.
cc @janicduplessis @foghina
Test Plan
Tested in https://github.com/charpeni/react-native-backface-visibility.
RNTester
Release Notes
[ANDROID] [FEATURE] [ReactViewGroup] - Add backface-visibility support on Android