mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-28 04:17:06 -06:00
pixmap_for offered every decode to the media cache, and the cache refuses an entry larger than its whole budget (128 MB, source bytes included). A picture between that and the 512 MB decode budget (about 34 to 67 M pixels, which can be a small PNG) was decoded, thrown away and decoded again each time a page holding it was drawn: while typing, scrolling or zooming. Such a picture is now averaged over square blocks of whole pixels down to half the cache before it is stored. The pixels are premultiplied, so edges keep their colour. Pictures the cache already held keep their full size. Pages draw a picture scaled to its frame, so it lands in the same place; a tiled page background now takes its tile size from the picture's natural size instead of the pixmap's. Measured with a 7000 x 7000 PNG on a page, dev profile (workspace opt-level 1): every render took 0.27 to 0.28 s before. Now the first takes 0.43 s and the next ones 0.3 to 0.5 ms. Peak RSS stays 399 MB, the decode's own.