From d00177ffa08c298c3b70b772bbe9a115dfeec7c7 Mon Sep 17 00:00:00 2001 From: rwpramono-mamiteam <71632868+rwpramono-mamiteam@users.noreply.github.com> Date: Mon, 21 Sep 2020 15:59:27 +0700 Subject: [PATCH 1/2] Change scaling to default value (0.0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The scale factor is set to the scale factor of the device’s main screen. https://developer.apple.com/documentation/uikit/1623912-uigraphicsbeginimagecontextwitho --- Source/utils/CGMappings.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/utils/CGMappings.swift b/Source/utils/CGMappings.swift index 6fe5042e..c67d2ca0 100644 --- a/Source/utils/CGMappings.swift +++ b/Source/utils/CGMappings.swift @@ -139,7 +139,7 @@ public extension Node { let renderer = RenderUtils.createNodeRenderer(self, view: nil) let rect = size.rect() - MGraphicsBeginImageContextWithOptions(size.toCG(), false, 1) + MGraphicsBeginImageContextWithOptions(size.toCG(), false, 0.0) let ctx = MGraphicsGetCurrentContext()! ctx.clear(rect.toCG()) From bcb3f9357e089c454eec40c972bc9119f5368111 Mon Sep 17 00:00:00 2001 From: Rachmat Wahyu Pramono <> Date: Thu, 16 Dec 2021 22:32:51 +0700 Subject: [PATCH 2/2] optimize memory --- Source/utils/CGMappings.swift | 1 + Source/views/MacawView.swift | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Source/utils/CGMappings.swift b/Source/utils/CGMappings.swift index 99d2a87f..7eced04e 100644 --- a/Source/utils/CGMappings.swift +++ b/Source/utils/CGMappings.swift @@ -149,6 +149,7 @@ public extension Node { defer { MGraphicsEndImageContext() + renderer.dispose() } guard let img = MGraphicsGetImageFromCurrentImageContext() else { diff --git a/Source/views/MacawView.swift b/Source/views/MacawView.swift index cb1ae1e1..bea76341 100644 --- a/Source/views/MacawView.swift +++ b/Source/views/MacawView.swift @@ -671,6 +671,11 @@ internal class DrawingView: MView { recognizersMap.removeValue(forKey: recognizer) } } + + // MARK: - Cleanup + deinit { + renderer?.dispose() + } } class LayoutHelper {