From f12d29899c80551ce7cbff524ffc5901301bb9f7 Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 20 Jan 2025 12:56:28 +0000 Subject: [PATCH] Direct2D: Remove SetDpi call in startFrame Previously, plugins and standalone apps could produce slightly different visual results, particularly anti-aliasing, when displaying on a display with native scaling applied. The discrepancy was caused by SetDpi being called with a larger-than-default value (e.g. 192 DPI on a 200% scaled display) in a standalone app, whereas SetDpi would always be called with the default value of 96 in a plugin. Keeping the default value seems to produce better results, so standalone apps will now retain the default DPI. --- .../native/juce_Direct2DGraphicsContext_windows.cpp | 7 ++----- .../native/juce_Direct2DHwndContext_windows.cpp | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp b/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp index 1417c64cd3..e0cc632802 100644 --- a/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp +++ b/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp @@ -610,7 +610,7 @@ public: popAllSavedStates(); } - virtual SavedState* startFrame (float dpiScale) + virtual SavedState* startFrame() { prepare(); @@ -636,9 +636,6 @@ public: // Init device context transform resetTransform (deviceContext); - const auto effectiveDpi = USER_DEFAULT_SCREEN_DPI * dpiScale; - deviceContext->SetDpi (effectiveDpi, effectiveDpi); - // Start drawing deviceContext->SetTarget (getDeviceContextTarget()); deviceContext->BeginDraw(); @@ -899,7 +896,7 @@ bool Direct2DGraphicsContext::startFrame (float dpiScale) { const auto pimpl = getPimpl(); const auto paintAreas = pimpl->getPaintAreas(); - currentState = pimpl->startFrame (dpiScale); + currentState = pimpl->startFrame(); if (currentState == nullptr) return false; diff --git a/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp b/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp index 0e1c7b356d..afea108853 100644 --- a/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp +++ b/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp @@ -258,11 +258,11 @@ public: JUCE_TRACE_EVENT_INT_RECT (etw::repaint, etw::paintKeyword, snappedRectangle); } - SavedState* startFrame (float dpiScale) override + SavedState* startFrame() override { setSize (getClientRect()); - auto* savedState = Pimpl::startFrame (dpiScale); + auto* savedState = Pimpl::startFrame(); if (savedState == nullptr) return nullptr;