diff options
author | crupest <crupest@outlook.com> | 2022-05-07 18:39:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-05-07 18:39:51 +0800 |
commit | a465e2c410c1ae5098d2e073442219bb07a31b9d (patch) | |
tree | d60e6692e8dad6d4df2b9709819bf65f0f797422 /src/win/graphics/direct/Painter.cpp | |
parent | 23e68dc785d274327efeecb22cfc712c71cfbfc0 (diff) | |
download | cru-a465e2c410c1ae5098d2e073442219bb07a31b9d.tar.gz cru-a465e2c410c1ae5098d2e073442219bb07a31b9d.tar.bz2 cru-a465e2c410c1ae5098d2e073442219bb07a31b9d.zip |
...
Diffstat (limited to 'src/win/graphics/direct/Painter.cpp')
-rw-r--r-- | src/win/graphics/direct/Painter.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/win/graphics/direct/Painter.cpp b/src/win/graphics/direct/Painter.cpp index 32386877..3e8bd5c1 100644 --- a/src/win/graphics/direct/Painter.cpp +++ b/src/win/graphics/direct/Painter.cpp @@ -1,5 +1,6 @@ #include "cru/win/graphics/direct/Painter.h" +#include "cru/common/log/Logger.h" #include "cru/platform/Check.h" #include "cru/win/graphics/direct/Brush.h" #include "cru/win/graphics/direct/ConvertUtil.h" @@ -12,9 +13,22 @@ namespace cru::platform::graphics::win::direct { D2DDeviceContextPainter::D2DDeviceContextPainter( - ID2D1DeviceContext1* device_context) { + ID2D1DeviceContext1* device_context, bool release) { Expects(device_context); device_context_ = device_context; + release_ = release; + device_context->BeginDraw(); +} + +D2DDeviceContextPainter::~D2DDeviceContextPainter() { + if (is_drawing_) { + CRU_LOG_INFO(u"You may forget to call EndDraw before destroying painter."); + } + + if (release_) { + device_context_->Release(); + device_context_ = nullptr; + } } platform::Matrix D2DDeviceContextPainter::GetTransform() { @@ -155,6 +169,7 @@ void D2DDeviceContextPainter::PopState() { void D2DDeviceContextPainter::EndDraw() { if (is_drawing_) { is_drawing_ = false; + ThrowIfFailed(device_context_->EndDraw()); DoEndDraw(); } } |