Browse Source

minor code cleanup in FillProcessor.cs

af/merge-core
Anton Firszov 8 years ago
parent
commit
9499d8ae00
  1. 22
      src/ImageSharp.Drawing/Processing/Drawing/Processors/FillProcessor.cs

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

@ -52,14 +52,8 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Processors
int width = maxX - minX;
var solidBrush = this.brush as SolidBrush<TPixel>;
// If there's no reason for blending, then avoid it.
if (solidBrush != null &&
(
(this.options.BlenderMode == PixelBlenderMode.Normal && this.options.BlendPercentage == 1f && solidBrush.Color.ToVector4().W == 1f) ||
(this.options.BlenderMode == PixelBlenderMode.Over && this.options.BlendPercentage == 1f && solidBrush.Color.ToVector4().W == 1f) ||
(this.options.BlenderMode == PixelBlenderMode.Src)))
if (this.IsSolidBrushWithoutBlending(out SolidBrush<TPixel> solidBrush))
{
Parallel.For(
minY,
@ -67,8 +61,6 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Processors
configuration.ParallelOptions,
y =>
{
int offsetY = y - startY;
int offsetX = minX - startX;
source.GetPixelRowSpan(y).Slice(minX, width).Fill(solidBrush.Color);
});
}
@ -107,5 +99,17 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Processors
}
}
}
private bool IsSolidBrushWithoutBlending(out SolidBrush<TPixel> solidBrush)
{
solidBrush = this.brush as SolidBrush<TPixel>;
return solidBrush != null
&& ((this.options.BlenderMode == PixelBlenderMode.Normal && this.options.BlendPercentage == 1f
&& solidBrush.Color.ToVector4().W == 1f)
|| (this.options.BlenderMode == PixelBlenderMode.Over && this.options.BlendPercentage == 1f
&& solidBrush.Color.ToVector4().W == 1f)
|| (this.options.BlenderMode == PixelBlenderMode.Src));
}
}
}
Loading…
Cancel
Save