public CanvasCase(DeviceResources device, int canvasWidth, int canvasHeight, int renderBufferCount) { Width = canvasWidth; Height = canvasHeight; DeviceResources = device; RenderTarget = new RenderTexture[renderBufferCount]; for (int i = 0; i < renderBufferCount; i++) { RenderTarget[i] = new RenderTexture(device, canvasWidth, canvasHeight, false); } UndoManager = new UndoManager(); PaintingTexture = new RenderTexture(device, canvasWidth, canvasHeight, false); PaintingTextureBackup = new RenderTexture(device, canvasWidth, canvasHeight, false); PaintingTextureTemp = new RenderTexture(device, canvasWidth, canvasHeight, false); SelectionMaskTexture = new RenderTexture(device, canvasWidth, canvasHeight, RenderTextureFormat.RENDERTEXTURE_FORMAT_R8_UNORM, false); PaintAgent = new PaintAgent(this); PaintAgent.SetPaintTarget(device, PaintingTexture, PaintingTextureBackup); PaintAgent.UndoManager = UndoManager; Layouts = new ObservableCollection <PictureLayout>(); ViewRenderer = new ViewRenderer(this); PaintAgent.ViewRenderer = ViewRenderer; Layouts.CollectionChanged += Layouts_Changed; }
public void Dispose() { PaintAgent?.Dispose(); for (int i = 0; i < Layouts.Count; i++) { Layouts[i]?.Dispose(); } UndoManager?.Dispose(); for (int i = 0; i < RenderTarget.Length; i++) { RenderTarget[i]?.Dispose(); } PaintingTexture?.Dispose(); PaintingTextureBackup?.Dispose(); PaintingTextureTemp?.Dispose(); }