public override HistoryMemento OnExecute(IHistoryWorkspace historyWorkspace)
        {
            if (!this.QueryCanExecute(historyWorkspace))
            {
                return(null);
            }
            HistoryMemento          memento                    = this.OnPreRender(historyWorkspace);
            int                     activeLayerIndex           = historyWorkspace.ActiveLayerIndex;
            BitmapLayer             activeLayer                = (BitmapLayer)historyWorkspace.ActiveLayer;
            RectInt32               num2                       = activeLayer.Bounds();
            RectDouble              bounds                     = historyWorkspace.Selection.GetCachedClippingMask().Bounds;
            IRenderer <ColorAlpha8> cachedClippingMaskRenderer = historyWorkspace.Selection.GetCachedClippingMaskRenderer(historyWorkspace.ToolSettings.Selection.RenderingQuality.Value);
            IEnumerable <IMaskedRenderer <ColorBgra, ColorAlpha8> > contentRenderers = this.OnCreateContentRenderers(historyWorkspace, num2.Width, num2.Height);
            ContentBlendMode    contentBlendMode = this.GetContentBlendMode();
            ContentRendererBgra renderer         = new ContentRendererBgra(activeLayer.Surface, contentBlendMode, contentRenderers, cachedClippingMaskRenderer);

            base.EnterCriticalRegion();
            HistoryMemento memento2 = new ApplyRendererToBitmapLayerHistoryFunction(this.HistoryMementoName, this.HistoryMementoImage, activeLayerIndex, renderer, bounds.Int32Bound, 4, 0x7d0, ActionFlags.None).Execute(historyWorkspace);
            HistoryMemento memento3 = this.OnPostRender(historyWorkspace);

            HistoryMemento[] items   = new HistoryMemento[] { memento, memento2, memento3 };
            HistoryMemento[] actions = ArrayUtil.Infer <HistoryMemento>(items).WhereNotNull <HistoryMemento>().ToArrayEx <HistoryMemento>();
            if (actions.Length == 0)
            {
                return(null);
            }
            return(new CompoundHistoryMemento(this.HistoryMementoName, this.HistoryMementoImage, actions));
        }
 public BitmapLayerToolLayerOverlay(BitmapLayer layer, RectInt32 affectedBounds, TChanges changes, ContentBlendMode blendMode, IEnumerable <IMaskedRenderer <ColorBgra, ColorAlpha8> > contentRenderers, IRenderer <ColorAlpha8> clipMaskRenderer) : base(layer, affectedBounds)
 {
     Validate.IsNotNull <TChanges>(changes, "changes");
     this.changes          = changes;
     this.blendMode        = blendMode;
     this.contentRenderers = contentRenderers.ToArrayEx <IMaskedRenderer <ColorBgra, ColorAlpha8> >();
     this.clipMaskRenderer = clipMaskRenderer;
     this.renderer         = new ContentRendererBgra(base.Layer.Surface, this.blendMode, this.contentRenderers, this.clipMaskRenderer);
 }