Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Fix scaling of the buffer on macOS #6

Merged
merged 2 commits into from
Dec 21, 2022
Merged

Fix scaling of the buffer on macOS #6

merged 2 commits into from
Dec 21, 2022

Conversation

tronical
Copy link
Contributor

Currently the size of the buffer on macOS is interpreted in logical pixels, which
is inconsistent with the other platforms. Instead,
we should apply the same scale factor that applies to regular rendering.

…tches

Resize the window to the physical size of the image.
If softbuffer scales the contents incorrectly, only parts
of the fruit basket will be visible.
Currently the size of the buffer on macOS is interpreted in logical pixels, which
is inconsistent with the other platforms. Instead,
we should apply the same scale factor that applies to regular rendering.
@tronical
Copy link
Contributor Author

Continuation of rust-windowing/softbuffer#32 here :)

Copy link
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

I can attest that this change improves the current situation

layer.set_contents_gravity(ContentsGravity::TopLeft);
layer.set_needs_display_on_bounds_change(false);
layer.set_contents_scale(window.backingScaleFactor());
Copy link
Member

Choose a reason for hiding this comment

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

I'm unsure if this will always be correct, e.g. if the view is moved to another monitor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this won't update automatically if the window's backing scale factor changes dynamically :(. I haven't looked into doing that, but agree that it would make sense to do, generally. I'd prefer it separate from this PR, as the lack of any scaling right now is pretty bad as-is :)

@tronical
Copy link
Contributor Author

I can attest that this change improves the current situation

Thanks for checking and reviewing - much appreciated.

@madsmtm madsmtm merged commit 25afc6e into rust-windowing:main Dec 21, 2022
@madsmtm
Copy link
Member

madsmtm commented Dec 21, 2022

No problem - thank you! ;)

@tronical
Copy link
Contributor Author

BTW, do you folks have any plans on making a new release in the near future? I'd like to switch Slint over to use swbuf instead of softbuffer.

@madsmtm
Copy link
Member

madsmtm commented Dec 22, 2022

I think we'll first want to make a proper CI setup (@notgull alluded to wanting to do this on Matrix, but they probably haven't found the time yet). Edit: Never mind, that's already done in #20.

So yeah, probably a new release soon, if nothing else I'd except it some time in the start of the new year.

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

Successfully merging this pull request may close these issues.

2 participants