From 122b75909e6134728d4edae7219954682eb6181f Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 22 Apr 2024 16:54:25 +0100 Subject: [PATCH] D2D: Avoid setting DPI when resizing context, as it is already set per-frame --- .../native/juce_Direct2DHwndContext_windows.cpp | 2 +- .../native/juce_Direct2DResources_windows.cpp | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp b/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp index cede792977..9c62d2b6c0 100644 --- a/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp +++ b/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp @@ -436,7 +436,7 @@ public: { ScopedMultithread scopedMultithread { directX->getD2DMultithread() }; - auto hr = swap.resize (size, (float) owner.getPhysicalPixelScaleFactor(), deviceContext); + auto hr = swap.resize (size * (float) owner.getPhysicalPixelScaleFactor(), deviceContext); jassert (SUCCEEDED (hr)); if (FAILED (hr)) teardown(); diff --git a/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp b/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp index 414f72022a..f298a33fa4 100644 --- a/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp +++ b/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp @@ -551,21 +551,17 @@ public: return chain != nullptr && buffer != nullptr && state >= State::bufferAllocated; } - HRESULT resize (Rectangle newSize, float dpiScalingFactor, ComSmartPtr deviceContext) + HRESULT resize (Rectangle newSize, ComSmartPtr deviceContext) { if (chain == nullptr) return E_FAIL; - auto scaledSize = newSize * dpiScalingFactor; - scaledSize = scaledSize.getUnion ({ Direct2DGraphicsContext::minFrameSize, Direct2DGraphicsContext::minFrameSize }) - .getIntersection ({ Direct2DGraphicsContext::maxFrameSize, Direct2DGraphicsContext::maxFrameSize }); + auto scaledSize = newSize.getUnion ({ Direct2DGraphicsContext::minFrameSize, Direct2DGraphicsContext::minFrameSize }) + .getIntersection ({ Direct2DGraphicsContext::maxFrameSize, Direct2DGraphicsContext::maxFrameSize }); buffer = nullptr; state = State::chainAllocated; - auto dpi = USER_DEFAULT_SCREEN_DPI * dpiScalingFactor; - deviceContext->SetDpi (dpi, dpi); - if (const auto hr = chain->ResizeBuffers (0, (UINT) scaledSize.getWidth(), (UINT) scaledSize.getHeight(), DXGI_FORMAT_B8G8R8A8_UNORM, swapChainFlags); FAILED (hr)) return hr;