-
-
Notifications
You must be signed in to change notification settings - Fork 390
Add setting to set the world renderer canvas scale factor automatically #16479
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 setting to set the world renderer canvas scale factor automatically #16479
Conversation
…vasScaleFactor automatically when performing #checkForNewScreenSize.
58cde82
to
77af184
Compare
…o set the world renderer canvas scale factor automatically”) to Pharo 11.
I added this to the ‘Retina display’ scaling Pharo 11 backport in the branch ‘scaling-canvas-tryout-17-pharo11’ (commit d0c1f62). |
Hi @Rinzwind ! I tested it on Mac and fonts and icons become very slick :) Now, @DurieuxPol and @estebanlm tested on windows and linux respectively, Esteban with a 4k monitor, and they did not see any change. So, two things:
G |
It depends on whether setting the scale factor to 2 manually does work for them: OSWorldRenderer autoSetCanvasScaleFactor: false; canvasScaleFactor: 2 If it does, then it’s the setting of the scale factor in World worldState worldRenderer in: [ :renderer |
{ renderer osWindowRenderer outputExtent. renderer windowExtent.
World scaleFactor. renderer windowScaleFactor } ] Leaving |
Now that there’s a new development version, I would suggest to have that one set |
@guillep, @DurieuxPol and @estebanlm: I was wondering whether you tried setting the scale factor to 2 manually? What’s the result for the second snippet (so the value for |
I juts tried: OSWorldRenderer
autoSetCanvasScaleFactor: false;
canvasScaleFactor: 2. This is the result: {(1834@1237). (1834@1237). 1.0. 1} |
In my machine, no matter what is the "canvas scale factor", with two different screens (a dell monitor and the mac retina screen) I have the following:
Now, if I change the canvas scale factor from 1 to 2, images get "neater".
Something I noticed too is that the display scale factor and the canvas scale factor have strange effects when mixed. Scenario 1: Display scale factor = 1
Scenario 2: change the Display scale factor to 2 (to zoom, for example for a demo)
Understanding the canvas vs display scale factor relation@Rinzwind may I conclude that
what is the error margin here if the division is not an exact number?
More info required?
|
Some more info here. While checking how automatic canvas scale factor is computed, I see it uses screenScaleFactor
self fetchDPIAndRaiseEvent.
^ screenScaleFactor
fetchDPIAndRaiseEvent
self fetchDPI ... The thing is, this last method fetchDPI
Smalltalk os isMacOSX ifTrue: [
diagonalDPI := verticalDPI := horizontalDPI := self screenScaleFactorBaseDPI.
screenScaleFactor := 1.0.
^ false
].
"Then code for the rest of the platforms!" EDIT: When commenting that conditional, pharo zooms up like using a 2x display scale factor :) |
I got |
There seems to be some confusion over the two snippets that I gave: the values in the array given by the second snippet do not change when the canvas scale factor is changed. It’s the other way around: those are the values used in the automatic setting of the canvas scale factor in The following simplification might help clarify some of the questions: arguments bind: [ :formExtent :canvasScale |
form := Form extent: formExtent depth: 32.
(ScalingCanvas formCanvas: form getCanvas scale: canvasScale)
fullDraw: World.
(window := OSWindow new)
extent: 300@150.
(window newFormRenderer: form) updateAll ] Using
Using That stretching is used when the World’s What may not immediately be obvious is that the Form is actually also stretched in the first window, as on a ‘Retina display’, the extent in pixels of the window is
When OSWorldRenderer’s Setting both the World’s The stretching can be avoided again by setting the World’s Note that when not using a ‘Retina display’ to view the above screenshots, you’ll presumably need to click them to zoom in to see some of the differences. PS: do not try using Erratum: for the second screenshot, the Form is described as being squished vertically, but it’s actually stretched vertically as well, just not by as much as horizontally, from 200 pixels vertically in the Form to 300 in the window. An example of the Form being squished vertically is when using |
As previously noted here, the icon pack currently lacks PNG files for the icons at scale 3 and 4. In pharo-icon-packs pull request #14, I replaced the scripts for generating the files by a new one that allows adding additional scales a bit more easily. I could open a pull request for adding PNG files at scale 3 and 4 if desired. |
I tested this on Windows, albeit through a virtual machine on macOS. I used VirtualBox v7.0.20 with the corresponding Windows 11 development environment virtual machine that Microsoft provides, with 3D acceleration disabled in the settings for the virtual machine as per a forum post suggesting that as a solution for it failing to load. When the Windows display setting ‘Scale’ is set to 200%, enabling the automatic setting of the canvas scale factor causes the scale factor to be set to 2 as I would expect: Demo.Windows.Set.Canvas.Scale.Factor.Automatically.mp4An improvement that can be made is to take into account that on Windows the output height always seems to be odd, so the height of the world’s display form is currently always off by one: actualDisplaySize
^ self actualScreenSize * self canvasScaleFactor + (0 @ -1) The following screenshots show the ‘full content’ of an inspector on a string before and after making the adjustment, the text on the first is slightly less sharp than on the second (click to zoom in): |
This pull request adds a setting to let the World’s OSWorldRenderer set the class’s #canvasScaleFactor automatically when performing #checkForNewScreenSize. On Macs with two displays, one of which is a ‘Retina display’ and one which is not, enabling the setting should make the canvas scale factor be changed automatically from 2 to 1 when moving the Pharo window from the ‘Retina display’ to the other one and vice-versa, as described in issue #16046. This, and the effect on Windows and Linux, may however need some further testing. The setting is by default disabled.