1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-27 02:20:05 +00:00

D2D: Avoid calling setPhysicalPixelScaleFactor

This commit is contained in:
reuk 2024-04-22 18:07:17 +01:00
parent e005a41d6b
commit c2d86693ff
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
5 changed files with 10 additions and 12 deletions

View file

@ -471,7 +471,7 @@ public:
deviceResources.deviceContext.context->Clear (backgroundColor);
}
virtual SavedState* startFrame()
virtual SavedState* startFrame (float dpiScale)
{
prepare();
@ -495,7 +495,7 @@ public:
// Init device context transform
deviceResources.deviceContext.resetTransform();
const auto effectiveDpi = USER_DEFAULT_SCREEN_DPI * owner.getPhysicalPixelScaleFactor();
const auto effectiveDpi = USER_DEFAULT_SCREEN_DPI * dpiScale;
deviceResources.deviceContext.context->SetDpi (effectiveDpi, effectiveDpi);
// Start drawing
@ -760,10 +760,10 @@ private:
Direct2DGraphicsContext::Direct2DGraphicsContext() = default;
Direct2DGraphicsContext::~Direct2DGraphicsContext() = default;
bool Direct2DGraphicsContext::startFrame()
bool Direct2DGraphicsContext::startFrame (float dpiScale)
{
auto pimpl = getPimpl();
currentState = pimpl->startFrame();
currentState = pimpl->startFrame (dpiScale);
if (currentState == nullptr)
return false;
@ -781,7 +781,7 @@ bool Direct2DGraphicsContext::startFrame()
setFont (currentState->font);
currentState->updateCurrentBrush();
addTransform (AffineTransform::scale ((float) getPhysicalPixelScaleFactor()));
addTransform (AffineTransform::scale (dpiScale));
}
return true;

View file

@ -99,7 +99,7 @@ public:
void fillRoundedRectangle (const Rectangle<float>& area, float cornerSize) override;
//==============================================================================
bool startFrame();
bool startFrame (float dpiScale);
void endFrame();
virtual Image createSnapshot() const { return {}; }

View file

@ -486,7 +486,7 @@ public:
}
}
SavedState* startFrame() override
SavedState* startFrame (float dpiScale) override
{
if (resizing)
{
@ -494,7 +494,7 @@ public:
setSize (getClientRect());
}
auto savedState = Pimpl::startFrame();
auto savedState = Pimpl::startFrame (dpiScale);
// If a new frame is starting, clear deferredAreas in case repaint is called
// while the frame is being painted to ensure the new areas are painted on the

View file

@ -103,7 +103,7 @@ Direct2DImageContext::Direct2DImageContext (Direct2DPixelData::Ptr targetIn)
metrics = Direct2DMetricsHub::getInstance()->imageContextMetrics;
#endif
startFrame();
startFrame (1.0f);
}
Direct2DImageContext::~Direct2DImageContext()

View file

@ -4774,9 +4774,7 @@ private:
//
// Direct2DLowLevelGraphicsContext::endFrame calls ID2D1DeviceContext::EndDraw to finish painting
// and then tells the swap chain to present the next swap chain back buffer.
direct2DContext->setPhysicalPixelScaleFactor ((float) peer.getPlatformScaleFactor());
if (! direct2DContext->startFrame())
if (! direct2DContext->startFrame ((float) peer.getPlatformScaleFactor()))
return;
peer.handlePaint (*direct2DContext);