Window.BitmapForCaching

I’m curious my on HiDPI monitors I get such better performance using BitmapForCaching than with plain New Picture. I vaguely remember a PDF when it first came out but I’m not finding it now. I’m sure if I go digging I can find it but thought I’d ask the group.

If I do some simple drawing of objects in each picture on a HiDPI monitor I go from 1.5 seconds (per draw cycle) down to 0.12 seconds. And I’m just trying to understand the why of it.

For optimal drawing performance (across various Apple technologies), they recommend using pixel perfect images, where 1 pixel on the image is drawn to 1 pixel on the screen.

By default the macOS upscales 1x pictures to draw onto a 2x screen. I can’t recall which, but it could be bilinear or bicubic, either way, upscaling using these methods is SLOW. You can use declares to switch the scaling function and get a performance boost, but the image will be drawn with big pixels.

When you draw a 2x image to a 2x screen, no upscaling is required. BitmapForCaching creates an image at the optimal size for the current screen.

Now the macOS caches images (quite aggressively in modern times) and so I was also unsure if it would cache the image at the up-scaled resolution, but I don’t think that it does.

Same performance gain in Windows HiDPI?

Windows is even worse because they allow fractional scaling.

I can’t say because I don’t do any work with Windows, I would imagine either it’s a yes or Windows doesn’t do high quality up-scaling.

If the scaling say 200% or 300% is that ‘better’ than something in the middle?

Well… it’s easier. Less math involved.