Browse Source

optimize ImageFrame.Clear()

af/merge-core
Anton Firszov 8 years ago
parent
commit
d63d08a9ac
  1. 19
      src/ImageSharp/ImageFrame{TPixel}.cs
  2. 1
      src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs

19
src/ImageSharp/ImageFrame{TPixel}.cs

@ -318,15 +318,16 @@ namespace SixLabors.ImageSharp
/// <param name="value">The value to initialize the bitmap with.</param> /// <param name="value">The value to initialize the bitmap with.</param>
internal void Clear(ParallelOptions parallelOptions, TPixel value) internal void Clear(ParallelOptions parallelOptions, TPixel value)
{ {
Parallel.For( Span<TPixel> span = this.GetPixelSpan();
0,
this.Height, if (value.Equals(default))
parallelOptions, {
y => span.Clear();
{ }
Span<TPixel> targetRow = this.GetPixelRowSpan(y); else
targetRow.Fill(value); {
}); span.Fill(value);
}
} }
/// <inheritdoc/> /// <inheritdoc/>

1
src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs

@ -86,7 +86,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration) protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration)
{ {
// TODO: can we simplify the rectangle calculation? // TODO: can we simplify the rectangle calculation?
int startY = sourceRectangle.Y; int startY = sourceRectangle.Y;
int endY = sourceRectangle.Bottom; int endY = sourceRectangle.Bottom;
int startX = sourceRectangle.X; int startX = sourceRectangle.X;

Loading…
Cancel
Save