News country badges are painted at the scene's pixel ratio

A badge's count image is sized by the renderer's own resolution scale
(its quality port's pixelRatio, 1 while that is browser recommended), as
the other icon sets are, not by the device pixel ratio.
This commit is contained in:
Sameh Khamis committed 2026-11-11 08:07:36 -08:00
1 parent 3143d106ce
commit 46c98796de
2 files changed
+81 -5

No files matched your search

+19 -5
View File
@@ -2,7 +2,12 @@ import { isPointerFree } from '../../data/inputOwnership.js';
import { inputFor as defaultInputFor } from '../../input/dispatcher.js';
import { fromDegrees } from '../../geo/ellipsoid.js';
import { cssColor } from '../../render/color.js';
import { findCamera, findDraw, findFrame } from '../../render/rendererOf.js';
import {
findCamera,
findDraw,
findFrame,
rendererOf,
} from '../../render/rendererOf.js';
import { hitTestWorldOverlay } from '../../overlays/worldOverlay.js';
import {
isOwnedByOtherLayer,
@@ -610,6 +615,18 @@ export function createNewsLayer({
}
}
/**
* Drawing-buffer pixels per CSS pixel: the renderer's own resolution
* scale (its quality port's `pixelRatio`, 1 while that is 0, browser
* recommended), not the device's.
*/
function scenePixelRatio() {
const ratio = viewer
? rendererOf(viewer)?.quality?.get?.()?.pixelRatio
: undefined;
return Number.isFinite(ratio) && ratio > 0 ? ratio : 1;
}
// News placed no closer than a country: one badge at its centre with the
// number of reports, in place of that many markers piled there.
function renderCountryBadges(list, drawn, labels) {
@@ -621,10 +638,7 @@ export function createNewsLayer({
countryBadges.set(group.key, group);
const position = fromDegrees(group.lon, group.lat);
const size = COUNTRY_BADGE_PX;
const sprite = countSprite(
group.count,
size * (globalThis.devicePixelRatio || 1),
);
const sprite = countSprite(group.count, size * scenePixelRatio());
const id = `${COUNTRY_PREFIX}${group.key}`;
if (sprite)
list.place('icons', {