public virtual void TryAndProcess() { int c = Nodes.Count; for (int i = 0; i < c; i++) { Node n = Nodes[i]; if (OutputNodes.Contains(n.Id)) { continue; } if (InputNodes.Contains(n.Id)) { continue; } n.TryAndProcess(); } c = InputNodes.Count; for (int i = 0; i < c; i++) { Node n; if (NodeLookup.TryGetValue(InputNodes[i], out n)) { InputNode inp = (InputNode)n; inp.TryAndProcess(); } } }
/// <summary> /// this is used in GraphInstances /// To resize proportionate to new size /// </summary> /// <param name="width"></param> /// <param name="height"></param> public virtual void ResizeWith(int width, int height) { this.width = width; this.height = height; int c = Nodes.Count; for (int i = 0; i < c; i++) { Node n = Nodes[i]; if (OutputNodes.Contains(n.Id)) { continue; } if (InputNodes.Contains(n.Id)) { continue; } if (n is BitmapNode) { BitmapNode bn = (BitmapNode)n; bn.TryAndProcess(); } else { Point osize; if (OriginSizes.TryGetValue(n.Id, out osize)) { float wratio = width / (float)osize.X; float hratio = height / (float)osize.Y; int fwidth = (int)Math.Min(4096, Math.Max(16, Math.Round(osize.X * wratio))); int fheight = (int)Math.Min(4096, Math.Max(16, Math.Round(osize.Y * hratio))); n.Width = fwidth; n.Height = fheight; } } } c = InputNodes.Count; for (int i = 0; i < c; i++) { Node n; if (NodeLookup.TryGetValue(InputNodes[i], out n)) { InputNode inp = (InputNode)n; inp.TryAndProcess(); } } }
/// <summary> /// This is used in GraphInstanceNodes /// We only save the final buffers connected to the outputs, /// and release all other buffers to save video card memory /// since it is all in video memory and shader based /// we do not have to transfer data to the video card /// so it will be relatively fast still to update /// when we have to recreate the textures /// </summary> public virtual void ReleaseIntermediateBuffers() { foreach (Node n in Nodes) { if (OutputNodes.Contains(n.Id)) { continue; } if (n.Buffer != null) { n.Buffer.Release(); } } }