protected Dictionary <string, byte[]> Process(FlScriptExecutionContext context) { MemoryBuffer buf = CLAPI.CreateBuffer(Instance, context.Input, MemoryFlag.ReadWrite); FLInterpreter ret = new FLInterpreter(Instance, context.Filename, buf, context.Width, context.Height, 1, 4, Db, true); do { ret.Step(); } while (!ret.Terminated); byte[] buffer = ret.GetResult <byte>(); Dictionary <string, byte[]> result = new Dictionary <string, byte[]> { { "result", buffer } }; foreach (KeyValuePair <string, Bitmap> keyValuePair in context.TextureMap) { CLBufferInfo mbuf = ret.GetBuffer(keyValuePair.Key); if (mbuf == null) { continue; } byte[] spec = CLAPI.ReadBuffer <byte>(Instance, mbuf.Buffer, (int)mbuf.Buffer.Size); result.Add(keyValuePair.Key, spec); mbuf.Buffer.Dispose(); } return(result); }
private Dictionary <FlScriptExecutionContext, Dictionary <Bitmap, byte[]> > _proc(Action onFinish = null) { //window = new GameWindow(100, 100, GraphicsMode.Default, "FLRunner"); //window.MakeCurrent(); Dictionary <FlScriptExecutionContext, Dictionary <Bitmap, byte[]> > ret = new Dictionary <FlScriptExecutionContext, Dictionary <Bitmap, byte[]> >(); while (ProcessQueue.Count != 0) { FlScriptExecutionContext fle = ProcessQueue.Dequeue(); Dictionary <string, byte[]> texUpdate = Process(fle); Dictionary <Bitmap, byte[]> texMap = new Dictionary <Bitmap, byte[]>(); foreach (KeyValuePair <string, byte[]> bytese in texUpdate) { if (fle.TextureMap.ContainsKey(bytese.Key)) { texMap.Add(fle.TextureMap[bytese.Key], bytese.Value); } } ret.Add(fle, texMap); } //window.Dispose(); onFinish?.Invoke(); return(ret); }
public virtual void Process(Action onFinish = null) { while (ProcessQueue.Count != 0) { FlScriptExecutionContext fle = ProcessQueue.Dequeue(); Dictionary <string, byte[]> ret = Process(fle); Dictionary <Bitmap, byte[]> texMap = new Dictionary <Bitmap, byte[]>(); foreach (KeyValuePair <string, byte[]> bytese in ret) { if (fle.TextureMap.ContainsKey(bytese.Key)) { texMap.Add(fle.TextureMap[bytese.Key], bytese.Value); } } foreach (KeyValuePair <Bitmap, byte[]> textureUpdate in texMap) { CLAPI.UpdateBitmap(CLAPI.MainThread, textureUpdate.Key, textureUpdate.Value); } fle.OnFinishCallback?.Invoke(texMap); } onFinish?.Invoke(); }
public virtual void Process() { while (ProcessQueue.Count != 0) { FlScriptExecutionContext fle = ProcessQueue.Dequeue(); FLProgram ret = Process(fle); fle.OnFinishCallback?.Invoke(ret); } }
private object _proc() { while (ProcessQueue.Count != 0) { FlScriptExecutionContext fle = ProcessQueue.Dequeue(); FLProgram texUpdate = Process(fle); fle.OnFinishCallback?.Invoke(texUpdate); } OnFinishQueue?.Invoke(); return(new object()); }
public override void Enqueue(FlScriptExecutionContext context) { if (context.OnFinishCallback == null) { context.OnFinishCallback = FlFinished; } else { context.OnFinishCallback += FlFinished; } base.Enqueue(context); }
protected FLProgram Process(FlScriptExecutionContext context) { FLBuffer input = new FLBuffer(Instance, context.Input, context.Width, context.Height, context.Filename); FLProgram program; if (context.IsCompiled) { Stream s = IOManager.GetStream(context.Filename); program = FLSerializer.LoadProgram(s, InstructionSet).Initialize(InstructionSet); s.Close(); } else { program = Parser.Process(new FLParserInput(context.Filename)).Initialize(InstructionSet); } program.Run(Instance, input, true); return(program); }
public virtual void Enqueue(FlScriptExecutionContext context) { ProcessQueue.Enqueue(context); }