From d42d8a676449bea8fadc988c77a8b7b5e08f4184 Mon Sep 17 00:00:00 2001 From: routersys Date: Thu, 2 Jul 2026 13:18:17 +0900 Subject: [PATCH] =?UTF-8?q?DrawCompositor=E3=81=A7placement=E3=81=AEOutput?= =?UTF-8?q?=E3=82=92=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5=E3=81=97?= =?UTF-8?q?=E5=8F=96=E5=BE=97=E3=81=97=E3=81=9FTarget=E3=82=92=E7=A0=B4?= =?UTF-8?q?=E6=A3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaScript/DrawCompositor.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/LuaScript/DrawCompositor.cs b/LuaScript/DrawCompositor.cs index 49cde06..de4b0b6 100644 --- a/LuaScript/DrawCompositor.cs +++ b/LuaScript/DrawCompositor.cs @@ -18,6 +18,7 @@ namespace LuaScript private ID2D1Bitmap1? _source; private ID2D1Bitmap1? _target; private AffineTransform2D? _placement; + private ID2D1Image? _placementOutput; private Opacity? _opacityEffect; private ID2D1Image? _opacityOutput; private int _sourceWidth; @@ -70,7 +71,7 @@ namespace LuaScript var dc = _ctx.DeviceContext; var rt = (ID2D1RenderTarget)dc; - var savedTarget = dc.Target; + using var savedTarget = dc.Target; dc.Target = _target; dc.BeginDraw(); @@ -95,7 +96,7 @@ namespace LuaScript dc.Target = savedTarget; _placement!.TransformMatrix = Matrix3x2.CreateTranslation(originX, originY); - return _placement.Output; + return _placementOutput!; } private void DrawSource(ID2D1RenderTarget rt, float opacity, BitmapInterpolationMode interpolation, Blend blend) @@ -140,8 +141,10 @@ namespace LuaScript if (_target is not null && _targetWidth == width && _targetHeight == height) return; + _placementOutput?.Dispose(); _placement?.Dispose(); _target?.Dispose(); + _placementOutput = null; _placement = null; _target = _ctx.DeviceContext.CreateEmptyBitmap(width, height, BitmapOptions.Target); @@ -150,15 +153,18 @@ namespace LuaScript _placement = new AffineTransform2D(_ctx.DeviceContext); _placement.SetInput(0, _target, true); + _placementOutput = _placement.Output; } public void Dispose() { + _placementOutput?.Dispose(); _placement?.Dispose(); _opacityOutput?.Dispose(); _opacityEffect?.Dispose(); _source?.Dispose(); _target?.Dispose(); + _placementOutput = null; _placement = null; _opacityOutput = null; _opacityEffect = null;