Browse Source

ParallelHelper -> FillProcessor

af/merge-core
Anton Firszov 8 years ago
parent
commit
4da33609f8
  1. 39
      src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs

39
src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs

@ -6,6 +6,7 @@ using System.Buffers;
using System.Threading.Tasks; using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.ParallelUtils;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Memory; using SixLabors.Memory;
using SixLabors.Primitives; using SixLabors.Primitives;
@ -52,17 +53,23 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
int width = maxX - minX; int width = maxX - minX;
var workingRect = Rectangle.FromLTRB(minX, minY, maxX, maxY);
// If there's no reason for blending, then avoid it. // If there's no reason for blending, then avoid it.
if (this.IsSolidBrushWithoutBlending(out SolidBrush<TPixel> solidBrush)) if (this.IsSolidBrushWithoutBlending(out SolidBrush<TPixel> solidBrush))
{ {
ParallelFor.WithConfiguration( ParallelExecutionSettings parallelSettings = configuration.GetParallelSettings().MultiplyMinimumPixelsPerTask(4);
minY,
maxY, ParallelHelper.IterateRows(
configuration, workingRect,
y => parallelSettings,
{ rows =>
source.GetPixelRowSpan(y).Slice(minX, width).Fill(solidBrush.Color); {
}); for (int y = rows.Min; y < rows.Max; y++)
{
source.GetPixelRowSpan(y).Slice(minX, width).Fill(solidBrush.Color);
}
});
} }
else else
{ {
@ -85,16 +92,18 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
{ {
amount.GetSpan().Fill(1f); amount.GetSpan().Fill(1f);
ParallelFor.WithConfiguration( ParallelHelper.IterateRows(
minY, workingRect,
maxY,
configuration, configuration,
y => rows =>
{ {
int offsetY = y - startY; for (int y = rows.Min; y < rows.Max; y++)
int offsetX = minX - startX; {
int offsetY = y - startY;
int offsetX = minX - startX;
applicator.Apply(amount.GetSpan(), offsetX, offsetY); applicator.Apply(amount.GetSpan(), offsetX, offsetY);
}
}); });
} }
} }

Loading…
Cancel
Save