Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions desktop/src/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ mod thumb {
}

/// The widths a copy is made at, so a few variants exist per picture.
const WIDTHS: [u32; 7] = [160, 240, 360, 540, 800, 1200, 1600];
const WIDTHS: [u32; 8] = [160, 240, 360, 540, 800, 1200, 1600, 2560];
/// What the copies may hold on disk before the oldest go.
const CACHE_BYTES: u64 = 96 * 1024 * 1024;

Expand Down Expand Up @@ -664,7 +664,9 @@ mod thumb {
assert_eq!(width(Some("w=100")), Some(160));
assert_eq!(width(Some("x=1&w=300")), Some(360));
assert_eq!(width(Some("w=1600")), Some(1600));
assert_eq!(width(Some("w=2000")), None);
assert_eq!(width(Some("w=2000")), Some(2560));
assert_eq!(width(Some("w=2560")), Some(2560));
assert_eq!(width(Some("w=2561")), None);
assert_eq!(width(Some("w=abc")), None);
assert_eq!(width(None), None);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ test("a custom background uses one sized local image, no sky decode or frost, an
await expect.poll(() => ntp.container.querySelector("img")?.naturalWidth ?? 0).toBeGreaterThan(0);
expect(native.decode).not.toHaveBeenCalled();
expect(native.media).toHaveBeenCalledTimes(1);
expect(native.media.mock.calls[0]).toEqual([native.profile, digest, 1600]);
expect(native.media.mock.calls[0]).toEqual([native.profile, digest, 2400]);
expect(ntp.container.querySelector(".sky")).toBeNull();
expect(
ntp.container.querySelector<HTMLElement>(".newtab")!.style.getPropertyValue("--sky-frost"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
onfailure: () => void;
} = $props();
// One image element and one bounded decode, with no resize observer or
// preloading image. Reopening reuses the protocol/browser cache. Never ask
// beyond the pipeline's largest thumbnail (larger asks serve the original).
// preloading image. Reopening reuses the protocol/browser cache. Ask for the
// physical pixels the picture covers, up to the pipeline's largest thumbnail
// (larger asks serve the original): 2560 px decodes to about 15 MB at 16:9.
const src = untrack(() =>
mediaUrl(
profile,
digest,
Math.min(1600, Math.max(1, Math.ceil(Math.max(width, height) * window.devicePixelRatio))),
Math.min(2560, Math.max(1, Math.ceil(Math.max(width, height) * window.devicePixelRatio))),
),
);
</script>
Expand Down
Loading