Selkies
Developer ReferenceWeb client coreLib

lib/stream-density

Variables

DPI_STOPS

const DPI_STOPS: number[];

Defined in: lib/stream-density.js:44

scaling_dpi stops in 25% steps from 96; densities between them snap to the nearest.


DPI_UNITY_ROWS

const DPI_UNITY_ROWS: 1080 = 1080;

Defined in: lib/stream-density.js:46

The rows a 96 DPI desktop is for, which a resolution is read against.

Functions

streamDensity()

function streamDensity(page): number;

Defined in: lib/stream-density.js:31

The density a display page streams at: stream pixels per CSS pixel.

A page asks for its CSS size at the density of the screen it is on, so the stream is one pixel per device pixel there. The primary streams at the device pixel ratio, or under CSS scaling at the ratio divided by the UI-scaling pick, which the desktop then does not apply as a DPI: windows keep the same proportion of the screen either way. A manual resolution is the exception both ways round: it is the framebuffer the operator asked for, so there is nothing for the pick to divide and it governs the desktop DPI instead, and a page dividing here as well would apply it twice -- publishing a density its own box does not draw at. On Wayland each screen takes its own page's DPI. On X11 the desktop has one, the primary's, so a secondary streams no denser than the primary's published scale: denser would only draw that UI smaller, so it asks for the primary's density and the browser stretches the stream, which keeps the UI one size across the screens; a screen less dense than the primary keeps its own density, since the primary's would ask for a buffer beyond the screen's pixels, and shows the UI larger. The primary's scale arrives with the layout, and a secondary streams at its own until it does; a shared viewer keeps its own.

Parameters

ParameterTypeDescription
page{ useCssScaling: boolean; localScale: number; manual: boolean; displayId: string; layouts: any; shared: boolean; wayland: boolean; }localScale is the UI-scaling pick as a factor (1 is 100%); manual is whether this page's resolution is the operator's own; layouts is the last display-config update's, whose primary.scale is the primary's published scale, and wayland the backend that update names.
page.useCssScalingboolean-
page.localScalenumber-
page.manualboolean-
page.displayIdstring-
page.layoutsany-
page.sharedboolean-
page.waylandboolean-

Returns

number


snapDpi()

function snapDpi(target): number;

Defined in: lib/stream-density.js:49

The stop nearest a density, clamped at both ends.

Parameters

ParameterType
targetany

Returns

number


autoScalingDpi()

function autoScalingDpi(): number;

Defined in: lib/stream-density.js:60

The default scaling_dpi: the local display scaling as a desktop DPI, so the remote UI comes out the size of the local one — 1.5 is 144, 2 is 192, snapped to the nearest stop and clamped at both ends.

Returns

number

One of DPI_STOPS.


resolutionScalingDpi()

function resolutionScalingDpi(width, height): number;

Defined in: lib/stream-density.js:79

The default scaling_dpi for a resolution the operator set: that framebuffer read as a desktop DPI, so one asked for in 4K is not drawn with the UI of a 1080p desktop, nor a small one with a dense laptop's.

Read off the shorter side, against the rows 96 DPI is for: an ultrawide is wide rather than dense, and a screen turned portrait is the same screen. The local display scaling says nothing about it — the operator's number is the framebuffer whatever screen shows it — so it stands in only for a size not yet known.

Parameters

ParameterTypeDescription
widthnumberPixels the operator asked for.
heightnumber-

Returns

number

One of DPI_STOPS.


publishedScale()

function publishedScale(box): number;

Defined in: lib/stream-density.js:100

The scale a page publishes with the layout: the remote pixels per CSS pixel of the stream box it presents.

Measured off that box, since a manual resolution or the pixel cap makes the ratio something other than the density. Only while the box is showing the stream the server realized, though: a box still holding the stream from before a resize measures that one's ratio instead, and a neighboring display would take the answer for this page's density and stream at it. The density the request was built with stands in until the two agree.

Parameters

ParameterTypeDescription
box{ stream: number[]; css: number[]; realized: number[]; density: number; }Sink pixels, the CSS box drawing them, the size the server realized, and the density.
box.streamnumber[]-
box.cssnumber[]-
box.realizednumber[]-
box.densitynumber-

Returns

number

On this page

Edit on GitHub