From e9f586071a83b2551dbc7c98ccfaa8e6b3189f01 Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 16 Oct 2021 22:30:29 +0800 Subject: ... --- src/osx/graphics/quartz/Painter.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/osx/graphics') diff --git a/src/osx/graphics/quartz/Painter.cpp b/src/osx/graphics/quartz/Painter.cpp index 6effe9f9..4771ca47 100644 --- a/src/osx/graphics/quartz/Painter.cpp +++ b/src/osx/graphics/quartz/Painter.cpp @@ -7,6 +7,13 @@ #include "cru/platform/Exception.hpp" namespace cru::platform::graphics::osx::quartz { +QuartzCGContextPainter::~QuartzCGContextPainter() { + if (auto_release_) { + CGContextRelease(cg_context_); + cg_context_ = nullptr; + } +} + Matrix QuartzCGContextPainter::GetTransform() { return Convert(CGContextGetCTM(cg_context_)); } @@ -101,11 +108,7 @@ void QuartzCGContextPainter::PopLayer() { // TODO: Implement this. } -void QuartzCGContextPainter::EndDraw() { - CGContextRelease(cg_context_); - CGContextFlush(cg_context_); - cg_context_ = nullptr; -} +void QuartzCGContextPainter::EndDraw() { CGContextFlush(cg_context_); } void QuartzCGContextPainter::Validate() { if (cg_context_ == nullptr) -- cgit v1.2.3