1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

VST3 Host: Fix growing windows due to inaccurate coordinate operations

Prior to this commit we used the integral version of localAreaToGlobal
before multiplying its result by the scale factor. This multiplied the
rounding error of localAreaToGlobal<int> by the scale factor. Now we
only round after all calculations have been carried out.
This commit is contained in:
attila 2024-09-24 17:12:44 +02:00
parent 2c9b15e52c
commit df024aaf3b

View file

@ -1637,14 +1637,17 @@ private:
/* Convert from the component's coordinate system to the hosted VST3's coordinate system. */
ViewRect componentToVST3Rect (Rectangle<int> r) const
{
const auto physical = localAreaToGlobal (r) * nativeScaleFactor * getDesktopScaleFactor();
const auto combinedScale = nativeScaleFactor * getDesktopScaleFactor();
const auto physical = (localAreaToGlobal (r.toFloat()) * combinedScale).toNearestInt();
return { 0, 0, physical.getWidth(), physical.getHeight() };
}
/* Convert from the hosted VST3's coordinate system to the component's coordinate system. */
Rectangle<int> vst3ToComponentRect (const ViewRect& vr) const
{
return getLocalArea (nullptr, Rectangle<int> { vr.right, vr.bottom } / (nativeScaleFactor * getDesktopScaleFactor()));
const auto combinedScale = nativeScaleFactor * getDesktopScaleFactor();
const auto floatRect = Rectangle { (float) vr.right, (float) vr.bottom } / combinedScale;
return getLocalArea (nullptr, floatRect).toNearestInt();
}
void componentMovedOrResized (bool, bool wasResized) override