CachedImageAtSize.refresh converts the requested draw size to pixels:
int scaledWidth = DPIUtil.pointToPixel(destWidth, DPIUtil.getDeviceZoom());
and hands it to isReusable, which compares it against the cached image's width.
That field is in points: loadImageAtSize builds the cached image with
new Image(device, imageData, getDeviceZoom()), and Image.init(ImageData, zoom)
sets this.width = round(imageDataWidth / scaleFactor).
At zoom 200 the comparison is scaledWidth/2 == scaledWidth, never true. The
single-entry size cache therefore never hits at any zoom other than 100, so every
scaled GC.drawImage misses and reloads the image.
Measured with strace -f -e trace=openat, 100 draws of one Image at a stable draw
size through the 5-arg overload, SVG:
| Device zoom |
Opens per draw |
Total over 100 draws |
| 100 |
0.02 |
2 (one miss, then hits) |
| 200 |
2.00 |
200 (a miss every draw) |
#3506 makes each miss cheaper but not rarer, and #3510 removes a different zoom-200
open; neither corrects the units.
Cocoa and win32 are unaffected: cocoa's cached image keeps pixels (init gets zoom
100), and win32's HandleAtSize compares the requested size against the requested size.
CachedImageAtSize.refreshconverts the requested draw size to pixels:and hands it to
isReusable, which compares it against the cached image'swidth.That field is in points:
loadImageAtSizebuilds the cached image withnew Image(device, imageData, getDeviceZoom()), andImage.init(ImageData, zoom)sets
this.width = round(imageDataWidth / scaleFactor).At zoom 200 the comparison is
scaledWidth/2 == scaledWidth, never true. Thesingle-entry size cache therefore never hits at any zoom other than 100, so every
scaled
GC.drawImagemisses and reloads the image.Measured with
strace -f -e trace=openat, 100 draws of one Image at a stable drawsize through the 5-arg overload, SVG:
#3506 makes each miss cheaper but not rarer, and #3510 removes a different zoom-200
open; neither corrects the units.
Cocoa and win32 are unaffected: cocoa's cached image keeps pixels (
initgets zoom100), and win32's
HandleAtSizecompares the requested size against the requested size.