From a291d665677f64e033f47fab71f2be24485ad924 Mon Sep 17 00:00:00 2001 From: routersys Date: Sun, 5 Jul 2026 10:11:26 +0900 Subject: [PATCH] =?UTF-8?q?=E7=94=BB=E5=83=8F=E5=87=A6=E7=90=86=E3=81=AEGP?= =?UTF-8?q?U=E5=A7=94=E8=AD=B2=E5=A5=91=E7=B4=84=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 --- .../Engine/AviUtlScriptContext.cs | 20 +++++++++++++++++++ .../Engine/IPixelBufferProcessor.cs | 11 ++++++++++ 2 files changed, 31 insertions(+) create mode 100644 LuaScript.Runtime/Engine/IPixelBufferProcessor.cs diff --git a/LuaScript.Runtime/Engine/AviUtlScriptContext.cs b/LuaScript.Runtime/Engine/AviUtlScriptContext.cs index d47d7dd..3a8d3b3 100644 --- a/LuaScript.Runtime/Engine/AviUtlScriptContext.cs +++ b/LuaScript.Runtime/Engine/AviUtlScriptContext.cs @@ -169,6 +169,8 @@ namespace LuaScript internal IPixelShaderRunner? ShaderRunner { get; set; } + internal IPixelBufferProcessor? PixelProcessor { get; set; } + internal AviUtlPixelShaderLibrary PixelShaders { get; set; } = AviUtlPixelShaderLibrary.Empty; internal bool TryGetShaderResource(string id, out byte[] data, out int width, out int height) => @@ -524,6 +526,12 @@ namespace LuaScript if (x1 <= x0 || y1 <= y0) return; + if (PixelProcessor?.TryFill(_pixelBuffer, cw, ch, r, g, b, a, x0, y0, x1 - x0, y1 - y0) == true) + { + _isPixelsDirty = true; + return; + } + _isPixelsDirty = true; double aK = Math.Clamp(a, 0d, 255d) / 255d; byte pb = (byte)Math.Clamp(b * aK, 0d, 255d); @@ -641,6 +649,12 @@ namespace LuaScript int cw = ImageWidth; int ch = ImageHeight; + if (PixelProcessor?.TryConvolve(_pixelBuffer, cw, ch, kernel, size, divisor, offset) == true) + { + _isPixelsDirty = true; + return; + } + int count = cw * ch * 4; if (_convolveSource is null || _convolveSource.Length < count) _convolveSource = new double[count]; @@ -720,6 +734,12 @@ namespace LuaScript int cw = ImageWidth; int ch = ImageHeight; + if (PixelProcessor?.TryResize(_pixelBuffer, cw, ch, newWidth, newHeight, linear, out var processed) == true && processed is not null) + { + ReplaceBuffer(processed, newWidth, newHeight); + return; + } + int srcCount = cw * ch * 4; if (_resizeSource is null || _resizeSource.Length < srcCount) _resizeSource = new byte[srcCount]; diff --git a/LuaScript.Runtime/Engine/IPixelBufferProcessor.cs b/LuaScript.Runtime/Engine/IPixelBufferProcessor.cs new file mode 100644 index 0000000..215f5d9 --- /dev/null +++ b/LuaScript.Runtime/Engine/IPixelBufferProcessor.cs @@ -0,0 +1,11 @@ +namespace LuaScript +{ + internal interface IPixelBufferProcessor + { + bool TryFill(byte[] target, int width, int height, double r, double g, double b, double a, int x, int y, int fillWidth, int fillHeight); + + bool TryConvolve(byte[] target, int width, int height, double[] kernel, int size, double divisor, double offset); + + bool TryResize(byte[] source, int sourceWidth, int sourceHeight, int targetWidth, int targetHeight, bool linear, out byte[]? target); + } +}