Description
I am currently experimenting with WebRender, and I am following the examples. Specifically, I replicated the logic in examples/boilerplate.rs
and had some problems with the following line:
webrender/examples/common/boilerplate.rs
Line 195 in d451d22
Since methods like
DisplayListBuilder::push_rect
accepts LayoutSize
as well, I presume that they should also be scaled in the same manner. Here is what my toy example looks like (on Windows 11):
scale = 1.5 | scale = 1.0 |
---|---|
![]() |
![]() |
Note: 1.5 is the system scale factor. The two versions differ in the way DeviceSize
is transformed into LayoutSize
. The left one uses Scale::new(window.scale_factor() as f32)
, and the right one uses Scale::identity()
.
The reddish rectangle has bounds LayoutRect::from_size(layout_size)
, and the text is laid out with the same bounds. It should be clear from the screenshot that in the scale = 1.0
version the rectangle is correctly covering the whole window, while the scale = 1.5
version is incorrectly scaled down.
Searching in this repository I found 25f674b, where the device_pixel_ratio
option is removed from WebRenderOptions
, and uses of such value is replaced by a hardcoded 1.0
.
Now I wonder, is the examples doing the correct thing? To add to the point, I see an extremely large window (larger than my screen so I cannot take a screenshot) when I cargo run --bin basic
. Could someone please educate me on this LayoutSize
/DeviceSize
/Scale
situation? Thanks in advance!