Every image kind draws on the Cesium port, atlas slots wherever an image is taken

Icons on billboards and on the GPU, line patterns, shape fills, quads and
raster shells take a URL, SVG, a blob (one object URL per blob), a keyed
canvas (packed into the GPU icon atlas as it is, by its key) and an atlas
slot as the image it holds. Blobs and canvases were refused on the GPU
path, blobs on billboards, and atlas slots everywhere but billboards. The
new conformance check draw.icons.images draws each kind on still and
receding icons; Cesium runs it.
This commit is contained in:
Sameh Khamis committed 2026-11-11 15:55:27 -08:00
1 parent 0e8be0fb78
commit 71f0945635
10 files changed
+229 -45

No files matched your search

+27 -14
View File
@@ -81,12 +81,15 @@ function createAtlas() {
},
/**
* The slot for `url` rasterised at `sizePx` square.
* The slot for `url` rasterised at `sizePx` square. Given a `source` (a
* canvas, or anything else `drawImage` takes), `url` is only its key:
* the source is packed at once, as it is now, and never loaded.
* @param {string} url
* @param {number} sizePx
* @param {CanvasImageSource} [source]
* @returns {number}
*/
slot(url, sizePx) {
slot(url, sizePx, source) {
const key = `${sizePx}|${url}`;
const known = slotOfKey.get(key);
if (known !== undefined) return known;
@@ -98,7 +101,8 @@ function createAtlas() {
const entry = { url, sizePx, image: null, x: 0, y: 0 };
entries.push(entry);
slotOfKey.set(key, slot);
load(entry);
if (source) placeLoaded(entry, source);
else load(entry);
return slot;
},
@@ -129,23 +133,32 @@ function createAtlas() {
},
};
/** Pack an entry's loaded image, or leave its slot empty when it does not fit. */
function placeLoaded(entry, image) {
entry.image = image;
// Node: nothing to pack into.
if (
typeof document === 'undefined' &&
typeof OffscreenCanvas === 'undefined'
)
return;
if (!pack()) {
entry.image = null; // does not fit: leave its slot empty, keep the rest
entry.failed = true;
console.warn(
`[iconAtlas] No room for ${entry.sizePx} px icon; slot stays empty`,
);
pack();
}
}
function load(entry) {
if (typeof Image === 'undefined') return; // Node: slots only
const image = new Image(entry.sizePx, entry.sizePx);
image.decoding = 'async';
// A cross-origin image would taint the canvas and every texture upload.
image.crossOrigin = 'anonymous';
image.onload = () => {
entry.image = image;
if (!pack()) {
entry.image = null; // does not fit: leave its slot empty, keep the rest
entry.failed = true;
console.warn(
`[iconAtlas] No room for ${entry.sizePx} px icon; slot stays empty`,
);
pack();
}
};
image.onload = () => placeLoaded(entry, image);
image.onerror = () => {
entry.failed = true;
console.warn(