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

[Fabric] Point scale factor update support #1844

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lenaic
Copy link

@lenaic lenaic commented Jun 8, 2023

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 👍
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 👍
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

Update the layout context to the right point scale factor when moving the window to a display with a different backing scale factor.

This is achieved by committing a cloned shadow tree and forcing yoga to re-evaluate the layout on all nodes so that the updated layout context would be assigned to all layoutable nodes through the updated layout metrics holding the point scale factor.

Changelog

[macOS] [ADDED] - Add support for point scale factor updates.

Test Plan

Tested by running RNTester on macOS with fabric (RCT_NEW_ARCH_ENABLED=1) and launching the API Border example.

Setup one screen with a 1x scale factor and another screen with a 2x scale factor. Drag the window from one screen to the other and observe the re-render of the borders to the right resolution of the screen.

Nick added 2 commits June 8, 2023 19:58
…king the full tree dirty.

Without this the setHasNewLayout function won't be called, which makes the differ not detect a change because the updated layout metrics were not assigned to the LayoutableShadowNode.
Comment on lines +251 to +255
- (void)viewDidChangeBackingProperties
{
[_surface updateLayoutContextWithPointScaleFactor:self.window.backingScaleFactor];
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this also work in didMoveToWindow? Asking since this method isn't in uiview whereas the latter is in both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants