Static SCALE_FACTOR

Source
pub static SCALE_FACTOR: OnceLock<RwLock<f64>>
Expand description

Global scale factor for converting between density-independent pixels and physical pixels.

This static variable holds the current scale factor used for dp-to-pixel conversions. It’s typically initialized once during application startup based on the device’s screen density and user scaling preferences.

The scale factor represents how many physical pixels correspond to one dp unit. For example:

  • Scale factor of 1.0: 1 dp = 1 pixel (standard density)
  • Scale factor of 2.0: 1 dp = 2 pixels (high density)
  • Scale factor of 0.75: 1 dp = 0.75 pixels (low density)

§Thread Safety

This variable uses OnceLock<RwLock<f64>> to ensure thread-safe access while allowing the scale factor to be updated during runtime if needed.