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

D2D: Avoid setting DPI when resizing context, as it is already set per-frame

This commit is contained in:
reuk 2024-04-22 16:54:25 +01:00
parent 83ba2cba5d
commit 122b75909e
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
2 changed files with 4 additions and 8 deletions

View file

@ -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();

View file

@ -551,21 +551,17 @@ public:
return chain != nullptr && buffer != nullptr && state >= State::bufferAllocated;
}
HRESULT resize (Rectangle<int> newSize, float dpiScalingFactor, ComSmartPtr<ID2D1DeviceContext> deviceContext)
HRESULT resize (Rectangle<int> newSize, ComSmartPtr<ID2D1DeviceContext> 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;