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>
internal void Clear(ParallelOptions parallelOptions, TPixel value)
{
Parallel.For(
0,
this.Height,
parallelOptions,
y =>
{
Span<TPixel> targetRow = this.GetPixelRowSpan(y);
targetRow.Fill(value);
});
Span<TPixel> span = this.GetPixelSpan();
if (value.Equals(default))
{
span.Clear();
}
else
{
span.Fill(value);
}
}
/// <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)
{
// TODO: can we simplify the rectangle calculation?
int startY = sourceRectangle.Y;
int endY = sourceRectangle.Bottom;
int startX = sourceRectangle.X;

Loading…
Cancel
Save