Skip to content

Commit 24f6ff9

Browse files
committed
minor code cleanup in FillProcessor.cs
1 parent d2bfaf2 commit 24f6ff9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,15 @@ protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle source
5252

5353
int width = maxX - minX;
5454

55-
var solidBrush = this.brush as SolidBrush<TPixel>;
56-
5755
// If there's no reason for blending, then avoid it.
58-
if (solidBrush != null &&
59-
(
60-
(this.options.BlenderMode == PixelBlenderMode.Normal && this.options.BlendPercentage == 1f && solidBrush.Color.ToVector4().W == 1f) ||
61-
(this.options.BlenderMode == PixelBlenderMode.Over && this.options.BlendPercentage == 1f && solidBrush.Color.ToVector4().W == 1f) ||
62-
(this.options.BlenderMode == PixelBlenderMode.Src)))
56+
if (this.IsSolidBrushWithoutBlending(out SolidBrush<TPixel> solidBrush))
6357
{
6458
Parallel.For(
6559
minY,
6660
maxY,
6761
configuration.ParallelOptions,
6862
y =>
6963
{
70-
int offsetY = y - startY;
71-
int offsetX = minX - startX;
7264
source.GetPixelRowSpan(y).Slice(minX, width).Fill(solidBrush.Color);
7365
});
7466
}
@@ -107,5 +99,17 @@ protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle source
10799
}
108100
}
109101
}
102+
103+
private bool IsSolidBrushWithoutBlending(out SolidBrush<TPixel> solidBrush)
104+
{
105+
solidBrush = this.brush as SolidBrush<TPixel>;
106+
107+
return solidBrush != null
108+
&& ((this.options.BlenderMode == PixelBlenderMode.Normal && this.options.BlendPercentage == 1f
109+
&& solidBrush.Color.ToVector4().W == 1f)
110+
|| (this.options.BlenderMode == PixelBlenderMode.Over && this.options.BlendPercentage == 1f
111+
&& solidBrush.Color.ToVector4().W == 1f)
112+
|| (this.options.BlenderMode == PixelBlenderMode.Src));
113+
}
110114
}
111115
}

0 commit comments

Comments
 (0)