public void OnDeserialization(object sender) { threadPool = new PaintDotNet.Threading.ThreadPool(); if (this.path != null) { this.shadowPath = this.path.Clone(); } }
protected override void OnAfterExecute() { for (int i = 0; i < this.blitWindows.Length; ++i) { this.blitWindows[i].Dispose(); this.blitWindows[i] = null; } this.threadPool = null; base.OnAfterExecute(); }
protected override void OnAfterExecute() { for (int i = 0; i < this.blitWindows.Length; ++i) { this.blitWindows[i].Dispose(); this.blitWindows[i] = null; } this.threadPool = null; base.OnAfterExecute(); }
protected override void OnAfterExecute() { for (int i = 0; i < BlitWindows.Length; ++i) { BlitWindows[i].Dispose(); BlitWindows[i] = null; } ThreadPool = null; base.OnAfterExecute(); }
protected override void OnBeforeExecute() { Rectangle blitRect = new Rectangle(0, 0, source.Width, source.Height); this.blitRects = new Rectangle[PaintDotNet.SystemLayer.Processor.LogicalCpuCount]; Utility.SplitRectangle(blitRect, this.blitRects); this.blitWindows = new Surface[this.blitRects.Length]; for (int i = 0; i < blitRects.Length; ++i) { blitWindows[i] = this.dst.CreateWindow(this.blitRects[i]); } this.threadPool = new PaintDotNet.Threading.ThreadPool(); base.OnBeforeExecute(); }
protected override void OnBeforeExecute() { Rectangle blitRect = new Rectangle(0, 0, blitSize.Width, blitSize.Height); this.blitRects = new Rectangle[PaintDotNet.SystemLayer.Processor.LogicalCpuCount]; Utility.SplitRectangle(blitRect, this.blitRects); this.blitWindows = new Surface[this.blitRects.Length]; for (int i = 0; i < blitRects.Length; ++i) { blitWindows[i] = this.dst.CreateWindow(this.blitRects[i]); } this.threadPool = new PaintDotNet.Threading.ThreadPool(); base.OnBeforeExecute(); }
protected override void OnBeforeExecute() { Rectangle blitRect = new Rectangle(0, 0, BlitSize.Width, BlitSize.Height); BlitRects = new Rectangle[PaintDotNet.SystemLayer.Processor.LogicalCpuCount]; Utility.SplitRectangle(blitRect, BlitRects); BlitWindows = new Surface[BlitRects.Length]; for (int i = 0; i < BlitRects.Length; ++i) { BlitWindows[i] = Dest.CreateWindow(BlitRects[i]); } ThreadPool = new PaintDotNet.Threading.ThreadPool(); base.OnBeforeExecute(); }
protected override void OnBeforeExecute() { this.renderer.StartColor = ColorBgra.Black; this.renderer.EndColor = ColorBgra.FromBgra(255, 128, 64, 64); this.renderer.StartPoint = new PointF(surface.Width / 2, surface.Height / 2); this.renderer.EndPoint = new PointF(0, 0); this.renderer.AlphaBlending = true; this.renderer.AlphaOnly = false; this.renderer.BeforeRender(); this.rois = new Rectangle[Processor.LogicalCpuCount]; Utility.SplitRectangle(this.surface.Bounds, rois); this.threadPool = new PaintDotNet.Threading.ThreadPool(Processor.LogicalCpuCount, false); base.OnBeforeExecute(); }
protected override void OnBeforeExecute() { Renderer.StartColor = ColorBgra.Black; Renderer.EndColor = ColorBgra.FromBgra(255, 128, 64, 64); Renderer.StartPoint = new PointF(Surface.Width / 2, Surface.Height / 2); Renderer.EndPoint = new PointF(0, 0); Renderer.AlphaBlending = true; Renderer.AlphaOnly = false; Renderer.BeforeRender(); Rois = new Rectangle[Processor.LogicalCpuCount]; Utility.SplitRectangle(Surface.Bounds, Rois); ThreadPool = new PaintDotNet.Threading.ThreadPool(Processor.LogicalCpuCount, false); base.OnBeforeExecute(); }
void IDeferredSerializable.FinishSerialization(Stream output, DeferredFormatter context) { bool useCompression = context.UseCompression; // formatVersion = 0 for GZIP, or 1 for uncompressed if (useCompression) { output.WriteByte(0); } else { output.WriteByte(1); } // chunkSize WriteUInt(output, serializationChunkSize); uint chunkCount = (uint)((this.length + (long)serializationChunkSize - 1) / (long)serializationChunkSize); PaintDotNet.Threading.ThreadPool threadPool = new PaintDotNet.Threading.ThreadPool(Processor.LogicalCpuCount); ArrayList exceptions = ArrayList.Synchronized(new ArrayList(Processor.LogicalCpuCount)); WaitCallback callback = new WaitCallback(SerializeChunk); object previousLock = null; for (uint chunk = 0; chunk < chunkCount; ++chunk) { long chunkOffset = (long)chunk * (long)serializationChunkSize; uint chunkSize = Math.Min((uint)serializationChunkSize, (uint)(this.length - chunkOffset)); SerializeChunkParms parms = new SerializeChunkParms(output, chunk, chunkOffset, chunkSize, previousLock, context, exceptions); threadPool.QueueUserWorkItem(callback, parms); previousLock = parms; } threadPool.Drain(); output.Flush(); if (exceptions.Count > 0) { throw new SerializationException("Exception thrown by worker thread", (Exception)exceptions[0]); } return; }
void IDeferredSerializable.FinishDeserialization(Stream input, DeferredFormatter context) { // Allocate the memory if (this.bitmapWidth != 0 && this.bitmapHeight != 0) { this.voidStar = Allocate(this.bitmapWidth, this.bitmapHeight, out this.bitmapHandle).ToPointer(); this.valid = true; } else { this.voidStar = Allocate(this.length).ToPointer(); this.valid = true; } // formatVersion should equal 0 int formatVersion = input.ReadByte(); if (formatVersion == -1) { throw new EndOfStreamException(); } if (formatVersion != 0 && formatVersion != 1) { throw new SerializationException("formatVersion was neither zero nor one"); } // chunkSize uint chunkSize = ReadUInt(input); PaintDotNet.Threading.ThreadPool threadPool = new PaintDotNet.Threading.ThreadPool(Processor.LogicalCpuCount); ArrayList exceptions = new ArrayList(Processor.LogicalCpuCount); WaitCallback callback = new WaitCallback(DecompressChunk); // calculate chunkCount uint chunkCount = (uint)((this.length + (long)chunkSize - 1) / (long)chunkSize); bool[] chunksFound = new bool[chunkCount]; for (uint i = 0; i < chunkCount; ++i) { // chunkNumber uint chunkNumber = ReadUInt(input); if (chunkNumber >= chunkCount) { throw new SerializationException("chunkNumber read from stream is out of bounds"); } if (chunksFound[chunkNumber]) { throw new SerializationException("already encountered chunk #" + chunkNumber.ToString()); } chunksFound[chunkNumber] = true; // dataSize uint dataSize = ReadUInt(input); // calculate chunkOffset long chunkOffset = (long)chunkNumber * (long)chunkSize; // calculate decompressed chunkSize uint thisChunkSize = Math.Min(chunkSize, (uint)(this.length - chunkOffset)); // bounds checking if (chunkOffset < 0 || chunkOffset >= this.length || chunkOffset + thisChunkSize > this.length) { throw new SerializationException("data was specified to be out of bounds"); } // read compressed data byte[] compressedBytes = new byte[dataSize]; Utility.ReadFromStream(input, compressedBytes, 0, compressedBytes.Length); // decompress data if (formatVersion == 0) { DecompressChunkParms parms = new DecompressChunkParms(compressedBytes, thisChunkSize, chunkOffset, context, exceptions); threadPool.QueueUserWorkItem(callback, parms); } else { fixed (byte *pbSrc = compressedBytes) { Memory.Copy((void *)((byte *)this.VoidStar + chunkOffset), (void *)pbSrc, thisChunkSize); } } } threadPool.Drain(); if (exceptions.Count > 0) { throw new SerializationException("Exception thrown by worker thread", (Exception)exceptions[0]); } }
/// <summary> /// Called after deserialization occurs so that certain things that are non-serializable /// can be set up. /// </summary> /// <param name="sender"></param> public void OnDeserialization(object sender) { this.updateRegion = new Vector<Rectangle>(); this.updateRegion.Add(this.Bounds); this.threadPool = new PaintDotNet.Threading.ThreadPool(); SetupEvents(); Dirty = true; }
protected override void OnActivate() { PdnBaseForm.RegisterFormHotKey(Keys.Back, OnBackspaceTyped); base.OnActivate(); this.textToolCursor = new Cursor(PdnResources.GetResourceStream("Cursors.TextToolCursor.cur")); this.Cursor = this.textToolCursor; fontChangedDelegate = new EventHandler(FontChangedHandler); fontSmoothingChangedDelegate = new EventHandler(FontSmoothingChangedHandler); alignmentChangedDelegate = new EventHandler(AlignmentChangedHandler); brushChangedDelegate = new EventHandler(BrushChangedHandler); antiAliasChangedDelegate = new EventHandler(AntiAliasChangedHandler); foreColorChangedDelegate = new EventHandler(ForeColorChangedHandler); ra = new RenderArgs(((BitmapLayer)ActiveLayer).Surface); mode = EditingMode.NotEditing; font = AppEnvironment.FontInfo.CreateFont(); alignment = AppEnvironment.TextAlignment; AppEnvironment.BrushInfoChanged += brushChangedDelegate; AppEnvironment.FontInfoChanged += fontChangedDelegate; AppEnvironment.FontSmoothingChanged += fontSmoothingChangedDelegate; AppEnvironment.TextAlignmentChanged += alignmentChangedDelegate; AppEnvironment.AntiAliasingChanged += antiAliasChangedDelegate; AppEnvironment.PrimaryColorChanged += foreColorChangedDelegate; AppEnvironment.SecondaryColorChanged += new EventHandler(BackColorChangedHandler); AppEnvironment.AlphaBlendingChanged += new EventHandler(AlphaBlendingChangedHandler); this.threadPool = new PaintDotNet.Threading.ThreadPool(); this.moveNub = new MoveNubRenderer(this.RendererList); this.moveNub.Shape = MoveNubShape.Compass; this.moveNub.Size = new SizeF(10, 10); this.moveNub.Visible = false; this.RendererList.Add(this.moveNub, false); }
public void OnDeserialization(object sender) { threadPool = new PaintDotNet.Threading.ThreadPool(); if (this.path != null) { this.shadowPath = this.path.Clone(); } }
void IDeferredSerializable.FinishDeserialization(Stream input, DeferredFormatter context) { // Allocate the memory if (this.bitmapWidth != 0 && this.bitmapHeight != 0) { this.voidStar = Allocate(this.bitmapWidth, this.bitmapHeight, out this.bitmapHandle).ToPointer(); this.valid = true; } else { this.voidStar = Allocate(this.length).ToPointer(); this.valid = true; } // formatVersion should equal 0 int formatVersion = input.ReadByte(); if (formatVersion == -1) { throw new EndOfStreamException(); } if (formatVersion != 0 && formatVersion != 1) { throw new SerializationException("formatVersion was neither zero nor one"); } // chunkSize uint chunkSize = ReadUInt(input); PaintDotNet.Threading.ThreadPool threadPool = new PaintDotNet.Threading.ThreadPool(Processor.LogicalCpuCount); ArrayList exceptions = new ArrayList(Processor.LogicalCpuCount); WaitCallback callback = new WaitCallback(DecompressChunk); // calculate chunkCount uint chunkCount = (uint)((this.length + (long)chunkSize - 1) / (long)chunkSize); bool[] chunksFound = new bool[chunkCount]; for (uint i = 0; i < chunkCount; ++i) { // chunkNumber uint chunkNumber = ReadUInt(input); if (chunkNumber >= chunkCount) { throw new SerializationException("chunkNumber read from stream is out of bounds"); } if (chunksFound[chunkNumber]) { throw new SerializationException("already encountered chunk #" + chunkNumber.ToString()); } chunksFound[chunkNumber] = true; // dataSize uint dataSize = ReadUInt(input); // calculate chunkOffset long chunkOffset = (long)chunkNumber * (long)chunkSize; // calculate decompressed chunkSize uint thisChunkSize = Math.Min(chunkSize, (uint)(this.length - chunkOffset)); // bounds checking if (chunkOffset < 0 || chunkOffset >= this.length || chunkOffset + thisChunkSize > this.length) { throw new SerializationException("data was specified to be out of bounds"); } // read compressed data byte[] compressedBytes = new byte[dataSize]; Utility.ReadFromStream(input, compressedBytes, 0, compressedBytes.Length); // decompress data if (formatVersion == 0) { DecompressChunkParms parms = new DecompressChunkParms(compressedBytes, thisChunkSize, chunkOffset, context, exceptions); threadPool.QueueUserWorkItem(callback, parms); } else { fixed(byte *pbSrc = compressedBytes) { Memory.Copy((void *)((byte *)this.VoidStar + chunkOffset), (void *)pbSrc, thisChunkSize); } } } threadPool.Drain(); if (exceptions.Count > 0) { throw new SerializationException("Exception thrown by worker thread", (Exception)exceptions[0]); } }
protected override void OnAfterExecute() { this.renderer.AfterRender(); this.threadPool = null; base.OnAfterExecute(); }
protected override void OnAfterExecute() { this.renderer.AfterRender(); this.threadPool = null; base.OnAfterExecute(); }
void IDeferredSerializable.FinishSerialization(Stream output, DeferredFormatter context) { bool useCompression = context.UseCompression; // formatVersion = 0 for GZIP, or 1 for uncompressed if (useCompression) { output.WriteByte(0); } else { output.WriteByte(1); } // chunkSize WriteUInt(output, serializationChunkSize); uint chunkCount = (uint)((this.length + (long)serializationChunkSize - 1) / (long)serializationChunkSize); PaintDotNet.Threading.ThreadPool threadPool = new PaintDotNet.Threading.ThreadPool(Processor.LogicalCpuCount); ArrayList exceptions = ArrayList.Synchronized(new ArrayList(Processor.LogicalCpuCount)); WaitCallback callback = new WaitCallback(SerializeChunk); object previousLock = null; for (uint chunk = 0; chunk < chunkCount; ++chunk) { long chunkOffset = (long)chunk * (long)serializationChunkSize; uint chunkSize = Math.Min((uint)serializationChunkSize, (uint)(this.length - chunkOffset)); SerializeChunkParms parms = new SerializeChunkParms(output, chunk, chunkOffset, chunkSize, previousLock, context, exceptions); threadPool.QueueUserWorkItem(callback, parms); previousLock = parms; } threadPool.Drain(); output.Flush(); if (exceptions.Count > 0) { throw new SerializationException("Exception thrown by worker thread", (Exception)exceptions[0]); } return; }
protected override void OnDeactivate() { PdnBaseForm.UnregisterFormHotKey(Keys.Back, OnBackspaceTyped); base.OnDeactivate(); switch (mode) { case EditingMode.Editing: SaveHistoryMemento(); break; case EditingMode.EmptyEdit: RedrawText(false); break; case EditingMode.NotEditing: break; default: throw new InvalidEnumArgumentException("Invalid Editing Mode"); } if (ra != null) { ra.Dispose(); ra = null; } if (saved != null) { saved.Dispose(); saved = null; } AppEnvironment.BrushInfoChanged -= brushChangedDelegate; AppEnvironment.FontInfoChanged -= fontChangedDelegate; AppEnvironment.FontSmoothingChanged -= fontSmoothingChangedDelegate; AppEnvironment.TextAlignmentChanged -= alignmentChangedDelegate; AppEnvironment.AntiAliasingChanged -= antiAliasChangedDelegate; AppEnvironment.PrimaryColorChanged -= foreColorChangedDelegate; AppEnvironment.SecondaryColorChanged -= new EventHandler(BackColorChangedHandler); AppEnvironment.AlphaBlendingChanged -= new EventHandler(AlphaBlendingChangedHandler); StopEditing(); this.threadPool = null; this.RendererList.Remove(this.moveNub); this.moveNub.Dispose(); this.moveNub = null; if (this.textToolCursor != null) { this.textToolCursor.Dispose(); this.textToolCursor = null; } }