From 3bbd411d86bb2ec1a548741a9e86aaacbcf4db06 Mon Sep 17 00:00:00 2001 From: routersys Date: Wed, 1 Jul 2026 17:52:34 +0900 Subject: [PATCH] =?UTF-8?q?LuaJIT=E3=83=AC=E3=83=BC=E3=83=B3=E3=81=A7setan?= =?UTF-8?q?chor=E3=82=B3=E3=83=BC=E3=83=AB=E3=83=90=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=92=E4=BB=B2=E4=BB=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaScript/Engine/LuaJitWorker.cs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/LuaScript/Engine/LuaJitWorker.cs b/LuaScript/Engine/LuaJitWorker.cs index d67104d..74d80eb 100644 --- a/LuaScript/Engine/LuaJitWorker.cs +++ b/LuaScript/Engine/LuaJitWorker.cs @@ -27,6 +27,7 @@ namespace LuaScript.Engine private readonly byte[] _callbackTag = new byte[NativeProtocol.CallbackTagMax]; private readonly byte[] _lastCallbackTag = new byte[NativeProtocol.CallbackTagMax]; + private readonly double[] _anchorBuffer = new double[Anchor.AnchorSupport.MaxAnchors * 3]; private int _lastCallbackTagLength = -1; private string _lastCallbackTagText = string.Empty; private byte[]? _resultBuffer; @@ -59,6 +60,7 @@ namespace LuaScript.Engine Func loadMovie, Action>> addEffect, Action addDraw, + Action setAnchor, out bool pixelsDirty, out bool bufferReplaced, out byte[]? newPixels, @@ -114,7 +116,7 @@ namespace LuaScript.Engine if (status != NativeProtocol.StatusCallback) break; - DispatchCallback(view, resolveObject, loadFigure, loadText, loadImage, loadMovie, addEffect, addDraw); + DispatchCallback(view, resolveObject, loadFigure, loadText, loadImage, loadMovie, addEffect, addDraw, setAnchor); _workEvent.Set(); } @@ -219,7 +221,8 @@ namespace LuaScript.Engine Func loadImage, Func loadMovie, Action>> addEffect, - Action addDraw) + Action addDraw, + Action setAnchor) { int kind = view.ReadInt32(NativeProtocol.OffCallbackKind); switch (kind) @@ -248,9 +251,33 @@ namespace LuaScript.Engine case NativeProtocol.CbKindDrawPoly: ResolveDrawPolyCallback(view, addDraw); break; + case NativeProtocol.CbKindSetAnchor: + ResolveSetAnchorCallback(view, setAnchor); + break; } } + private void ResolveSetAnchorCallback(MemoryMappedViewAccessor view, Action setAnchor) + { + int tagLen = Math.Clamp(view.ReadInt32(NativeProtocol.OffCallbackTagLen), 0, NativeProtocol.CallbackTagMax); + view.ReadArray(NativeProtocol.CallbackTagOffset, _callbackTag, 0, tagLen); + string group = Encoding.UTF8.GetString(_callbackTag, 0, tagLen); + + long rOff = NativeProtocol.CallbackResultOffset; + int count = Math.Clamp((int)view.ReadDouble(rOff + 0 * 8), 0, Anchor.AnchorSupport.MaxAnchors); + bool is3D = view.ReadDouble(rOff + 1 * 8) != 0d; + int connection = (int)view.ReadDouble(rOff + 2 * 8); + + Array.Clear(_anchorBuffer, 0, _anchorBuffer.Length); + try { setAnchor(group, count, is3D, connection, _anchorBuffer); } + catch { } + + int stride = is3D ? 3 : 2; + for (int i = 0; i < count * stride; i++) + view.Write(NativeProtocol.CallbackTagOffset + i * 8, _anchorBuffer[i]); + view.Write(NativeProtocol.OffCallbackFound, 1); + } + private static void ResolveDrawCallback(MemoryMappedViewAccessor view, Action addDraw) { long rOff = NativeProtocol.CallbackResultOffset;