From 263615fd37a9f0210710d5b6963b20f53a9779b6 Mon Sep 17 00:00:00 2001 From: routersys Date: Tue, 22 Sep 2026 15:41:01 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BE=8B=E5=A4=96=E3=81=AE=E5=A0=B1=E5=91=8A?= =?UTF-8?q?=E3=82=92=E3=83=9B=E3=82=B9=E3=83=88=E3=81=A8=E3=81=AE=E5=A2=83?= =?UTF-8?q?=E7=95=8C=E3=81=AB=E9=99=90=E3=82=8A=E8=B3=87=E6=BA=90=E7=A2=BA?= =?UTF-8?q?=E4=BF=9D=E3=81=AE=E5=A4=B1=E6=95=97=E3=81=AF=E7=B4=A0=E9=80=9A?= =?UTF-8?q?=E3=81=97=E3=81=B8=E6=88=BB=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- InkDispersion/InkDispersionEffectProcessor.cs | 35 ++++++++++++------- InkDispersion/InkDispersionPipeline.cs | 12 +++++-- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/InkDispersion/InkDispersionEffectProcessor.cs b/InkDispersion/InkDispersionEffectProcessor.cs index 2e8c3ee..7f9db54 100644 --- a/InkDispersion/InkDispersionEffectProcessor.cs +++ b/InkDispersion/InkDispersionEffectProcessor.cs @@ -1,3 +1,4 @@ +using System.ComponentModel; using System.Numerics; using ComputeWeave; using Vortice.Direct2D1; @@ -303,9 +304,13 @@ internal sealed class InkDispersionEffectProcessor : VideoEffectProcessorBase _resourceSet = InkDispersionResourceSet.Create(interopDevice, _interopDomain); _pipeline = InkDispersionPipeline.TryCreate(interopDevice); } - catch (Exception exception) + catch (Win32Exception) + { + ReleaseInterop(); + return null; + } + catch { - InkDispersionTelemetry.Report(exception); ReleaseInterop(); throw; } @@ -353,9 +358,8 @@ internal sealed class InkDispersionEffectProcessor : VideoEffectProcessorBase disposer.Collect(output); return output; } - catch (Exception exception) + catch { - InkDispersionTelemetry.Report(exception); output?.Dispose(); outputTransformOutput?.Dispose(); outputTransform?.Dispose(); @@ -368,17 +372,10 @@ internal sealed class InkDispersionEffectProcessor : VideoEffectProcessorBase } protected override void setInput(ID2D1Image? inputImage) - { - _effect?.SetInput(0, inputImage, true); - if (!_hasOutput) - _effect?.SetInput(1, inputImage, true); - } - - protected override void ClearEffectChain() { try { - ClearEffectChainCore(); + SetInputCore(inputImage); } catch (Exception exception) { @@ -387,7 +384,14 @@ internal sealed class InkDispersionEffectProcessor : VideoEffectProcessorBase } } - private void ClearEffectChainCore() + private void SetInputCore(ID2D1Image? inputImage) + { + _effect?.SetInput(0, inputImage, true); + if (!_hasOutput) + _effect?.SetInput(1, inputImage, true); + } + + protected override void ClearEffectChain() { _effect?.SetInput(0, null, true); _effect?.SetInput(1, null, true); @@ -409,6 +413,11 @@ internal sealed class InkDispersionEffectProcessor : VideoEffectProcessorBase ReleaseInterop(); } } + catch (Exception exception) + { + InkDispersionTelemetry.Report(exception); + throw; + } finally { base.Dispose(disposing); diff --git a/InkDispersion/InkDispersionPipeline.cs b/InkDispersion/InkDispersionPipeline.cs index 6f2f3f2..b14c23c 100644 --- a/InkDispersion/InkDispersionPipeline.cs +++ b/InkDispersion/InkDispersionPipeline.cs @@ -1,3 +1,4 @@ +using System.ComponentModel; using System.Runtime.InteropServices; using ComputeWeave; @@ -56,13 +57,18 @@ internal sealed class InkDispersionPipeline : IDisposable try { host = InkDispersionPipelineHost.Create(device, InkDispersionSettings.MaximumPendingSubmissions); - return new InkDispersionPipeline(device, host); + var pipeline = new InkDispersionPipeline(device, host); + host = null; + return pipeline; } - catch + catch (Win32Exception) + { + return null; + } + finally { host?.Dispose(); host?.WaitForDisposal(); - return null; } }