CoreGraphicsContext::getPhysicalPixelScaleFactor returns incorrect value (standalone app)

On Mac g.getInternalContext().getPhysicalPixelScaleFactor() seems to return 4.0 in a standalone application (I saw there was another thread from 2017 that had to do with VST, but this is not even running inside a plugin).

Inside CoreGraphicsContext targetScale is 2.0, which is then further multiplied by the CoreGraphics context scale factor, resulting in 4.0.

When USE_COREGRAPHICS_RENDERING is set to 0, the returned value is correct and is 2.0.

Thanks,
George.

1 Like

Waw , I have been wondering for so long why JUCE was incredibly slow on retina displays, it seems you just found why.

Returning targetScale instead of targetScale * (float) (juce_hypot (t.a, t.c) + juce_hypot (t.b, t.d)) / 2.0f in CoreGraphicsContext::getPhysicalPixelScaleFactor makes a huge difference !

I believe, a better fix would be not to return targetScale, but to change juce_mac_NSViewComponentPeer.mm to pass 1.0f for the targetScale when the context is created (right now it passes displayScale). Then again, probably it’s best to let JUCE guys fix it.

related ?