mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-14 14:22:39 +00:00
The image cache kept the full-resolution level 0 of every TIFF, PNG, PSD and CMYK JPEG, and of any image shown at High Quality: about 48 MB for a 12 MP photo, so after a dozen photos every edit evicted and decoded them again on the render thread. - mip keeps only the level drawn. It remembers each asset's full size (from its header, then from a decode), builds a coarser level from a finer cached one, and tries the reduced JPEG decode before a full one. When an image is zoomed into (a finer level asked for while a coarser one is cached) it keeps the full decode too, up to 96 MB, so the following steps halve it instead of decoding again. - With RenderOptions::defer_images (the canvas) the image draw uses mip_now: a level that isn't cached is decoded on one of three background threads, newest request first, and a coarser cached level or a light box is drawn meanwhile. images::generation advances and the waker runs when a decode finishes. A decoder panic marks the image bad. Background decodes reserve their peak bytes at the same gate as warm, so they wait while decodes in flight hold half the budget. - An image asked for again within 2 s of its decode (evicted at once: the view holds more than the cache) isn't decoded again until then, in place or in the background, so the canvas never decodes on its own thread. - warm counts an asset as cached when the level each drawing takes, or a finer one, is cached, and sizes a job by the levels it keeps. It leaves a decode larger than the whole budget to the render, and the canvas skips it. - A render that deferred an image isn't kept as the CMYK view snapshot. Based on #2051 by texjer.