private static unsafe void RenderWithClipMask(Effect effect, EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, IRenderer <ColorAlpha8> clipMaskRenderer) { effect.Render(token, dstArgs, srcArgs, rois); if (!effect.IsCancelRequested && (clipMaskRenderer != null)) { RectInt32 bounds = RectangleUtil.Bounds(rois).ToRectInt32(); if (bounds.HasPositiveArea) { using (ISurface <ColorAlpha8> surface = clipMaskRenderer.UseTileOrToSurface(bounds)) { int width = bounds.Width; int height = bounds.Height; int left = bounds.Left; int top = bounds.Top; int bottom = bounds.Bottom; int stride = dstArgs.Surface.Stride; int num8 = srcArgs.Surface.Stride; int num9 = surface.Stride; ColorBgra *pointAddress = dstArgs.Surface.GetPointAddress(left, top); ColorBgra *bgraPtr2 = srcArgs.Surface.GetPointAddress(left, top); byte * numPtr = (byte *)surface.Scan0; for (int i = height; i > 0; i--) { ColorBgra.Underwrite(bgraPtr2, pointAddress, numPtr, width); pointAddress += stride; bgraPtr2 += num8; numPtr += num9; } } } } }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { if (projectType == ProjectType.Shape && shapeSurface != null) { dstArgs.Surface.CopySurface(srcArgs.Surface, rois, startIndex, length); normalOp.Apply(dstArgs.Surface, shapeSurface, rois, startIndex, length); } else if (projectType == ProjectType.Effect && userEffect != null) { CodeLabConfigToken sect = (CodeLabConfigToken)parameters; try { userEffect.Render(sect.PreviewToken, dstArgs, srcArgs, rois, startIndex, length); } catch (Exception exc) { sect.LastExceptions.Add(exc); dstArgs.Surface.CopySurface(srcArgs.Surface); sect.UserScriptObject = null; userEffect?.Dispose(); userEffect = null; } if (fetchDebugMsg) { fetchDebugMsg = false; try { string output = userEffect?.GetType().GetProperty("__DebugMsgs", typeof(string))?.GetValue(userEffect)?.ToString(); if (!output.IsNullOrEmpty()) { sect.Output.Add(output); } } catch { // just fail silently } } } }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { CodeLabConfigToken sect = (CodeLabConfigToken)parameters; Effect userEffect = sect.UserScriptObject; if (userEffect != null) { userEffect.EnvironmentParameters = this.EnvironmentParameters; try { userEffect.Render(null, dstArgs, srcArgs, rois, startIndex, length); } catch (Exception exc) { sect.LastExceptions.Add(exc); dstArgs.Surface.CopySurface(srcArgs.Surface); sect.UserScriptObject = null; } } }