diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h index bcf1be28f3..55cbecb43e 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h @@ -23,7 +23,7 @@ namespace juce class CoreGraphicsContext : public LowLevelGraphicsContext { public: - CoreGraphicsContext (CGContextRef context, float flipHeight, float targetScale); + CoreGraphicsContext (CGContextRef context, float flipHeight); ~CoreGraphicsContext() override; //============================================================================== @@ -69,7 +69,6 @@ public: private: CGContextRef context; const CGFloat flipHeight; - float targetScale; CGColorSpaceRef rgbColourSpace, greyColourSpace; mutable Rectangle lastClipRect; mutable bool lastClipRectIsValid = false; diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm index bb03fbe243..98ae35ec69 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm @@ -62,7 +62,7 @@ public: { freeCachedImageRef(); sendDataChangeMessage(); - return std::make_unique (context, height, 1.0f); + return std::make_unique (context, height); } void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override @@ -187,10 +187,9 @@ ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int widt } //============================================================================== -CoreGraphicsContext::CoreGraphicsContext (CGContextRef c, float h, float scale) +CoreGraphicsContext::CoreGraphicsContext (CGContextRef c, float h) : context (c), flipHeight (h), - targetScale (scale), state (new SavedState()) { CGContextRetain (context); @@ -238,14 +237,14 @@ void CoreGraphicsContext::addTransform (const AffineTransform& transform) lastClipRectIsValid = false; jassert (getPhysicalPixelScaleFactor() > 0.0f); - jassert (getPhysicalPixelScaleFactor() > 0.0f); } float CoreGraphicsContext::getPhysicalPixelScaleFactor() { - auto t = CGContextGetCTM (context); + auto t = CGContextGetUserSpaceToDeviceSpaceTransform (context); + auto determinant = (t.a * t.d) - (t.c * t.b); - return targetScale * (float) (juce_hypot (t.a, t.c) + juce_hypot (t.b, t.d)) / 2.0f; + return (float) std::sqrt (std::abs (determinant)); } bool CoreGraphicsContext::clipToRectangle (const Rectangle& r) diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index 96a4078612..091a576015 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -1087,7 +1087,7 @@ void UIViewComponentPeer::drawRect (CGRect r) // NB the CTM on iOS already includes a factor for the display scale, so // we'll tell the context that the scale is 1.0 to avoid it using it twice - CoreGraphicsContext g (cg, getComponent().getHeight(), 1.0f); + CoreGraphicsContext g (cg, getComponent().getHeight()); insideDrawRect = true; handlePaint (g); diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 246b050ad3..fab1f024ec 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -873,7 +873,7 @@ public: #if USE_COREGRAPHICS_RENDERING if (usingCoreGraphics) { - CoreGraphicsContext context (cg, (float) [view frame].size.height, displayScale); + CoreGraphicsContext context (cg, (float) [view frame].size.height); invokePaint (context); } else