From 3c63ba0729c78ea5aa45839f8baa69571d6236d2 Mon Sep 17 00:00:00 2001 From: routersys Date: Wed, 1 Jul 2026 14:01:28 +0900 Subject: [PATCH] =?UTF-8?q?drawtarget=E3=81=AE=E6=8F=8F=E7=94=BB=E5=85=88?= =?UTF-8?q?=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88=E3=81=A8tmp=E3=81=B8?= =?UTF-8?q?=E3=81=AE=E5=8D=B3=E6=99=82=E5=90=88=E6=88=90=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaScript/AviUtlScriptContext.cs | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/LuaScript/AviUtlScriptContext.cs b/LuaScript/AviUtlScriptContext.cs index 079104d..fb7a82e 100644 --- a/LuaScript/AviUtlScriptContext.cs +++ b/LuaScript/AviUtlScriptContext.cs @@ -87,6 +87,53 @@ namespace LuaScript internal void ClearDraws() => _drawCommands.Clear(); + private bool _drawTargetTemp; + + internal void ResetDrawTarget() => _drawTargetTemp = false; + + internal void SetDrawTarget(bool temp, int width, int height, bool hasSize) + { + _drawTargetTemp = temp; + if (temp && hasSize) + { + int w = Math.Max(1, width); + int h = Math.Max(1, height); + _buffers["t"] = (new byte[w * h * 4], w, h); + } + } + + internal void SubmitDraw(DrawCommand command) + { + if (!_drawTargetTemp) + { + _drawCommands.Add(command); + return; + } + CompositeToTemp(command); + } + + private void CompositeToTemp(DrawCommand command) + { + EnsurePixelBuffer(); + var src = _pixelBuffer; + if (src is null) + return; + + if (!_buffers.TryGetValue("t", out var temp)) + { + int w = Math.Max(1, ImageWidth); + int h = Math.Max(1, ImageHeight); + temp = (new byte[w * h * 4], w, h); + _buffers["t"] = temp; + } + + bool linear = command.Antialias != 0d; + if (command.Poly is { } poly) + SoftwareCompositor.DrawPolyInto(temp.Data, temp.Width, temp.Height, src, ImageWidth, ImageHeight, poly, command.Alpha, linear); + else + SoftwareCompositor.DrawInto(temp.Data, temp.Width, temp.Height, src, ImageWidth, ImageHeight, command.Ox, command.Oy, command.Zoom, command.Aspect, command.Alpha, linear); + } + private readonly Dictionary _buffers = new(StringComparer.Ordinal); internal bool CopyBuffer(string dst, string src)