diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillRegionProcessor.cs
index 598e696ba..c81f4028b 100644
--- a/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillRegionProcessor.cs
+++ b/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillRegionProcessor.cs
@@ -37,29 +37,22 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Processors
}
///
- /// Initializes a new instance of the class.
- ///
- public FillRegionProcessor()
- {
- }
-
- ///
- /// Gets or sets the brush.
+ /// Gets the brush.
///
- public IBrush Brush { get; set; }
+ public IBrush Brush { get; }
///
- /// Gets or sets the region that this processor applies to.
+ /// Gets the region that this processor applies to.
///
- public Region Region { get; set; }
+ public Region Region { get; }
///
- /// Gets or sets the options.
+ /// Gets the options.
///
///
/// The options.
///
- public GraphicsOptions Options { get; set; }
+ public GraphicsOptions Options { get; }
///
protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
diff --git a/src/ImageSharp.Drawing/Processing/Text/Processors/DrawTextProcessor.cs b/src/ImageSharp.Drawing/Processing/Text/Processors/DrawTextProcessor.cs
index 0d534dc39..f6a66b566 100644
--- a/src/ImageSharp.Drawing/Processing/Text/Processors/DrawTextProcessor.cs
+++ b/src/ImageSharp.Drawing/Processing/Text/Processors/DrawTextProcessor.cs
@@ -39,43 +39,50 @@ namespace SixLabors.ImageSharp.Processing.Text.Processors
/// The location on the image to start drawign the text from.
public DrawTextProcessor(TextGraphicsOptions options, string text, Font font, IBrush brush, IPen pen, PointF location)
{
- this.Brush = brush;
+ Guard.NotNull(text, nameof(text));
+ Guard.NotNull(font, nameof(font));
+ if (brush == null && pen == null)
+ {
+ throw new ArgumentNullException($"at least one of {nameof(brush)} or {nameof(pen)} must not be null");
+ }
+
this.Options = options;
this.Text = text;
- this.Pen = pen;
this.Font = font;
this.Location = location;
+ this.Brush = brush;
+ this.Pen = pen;
}
///
- /// Gets or sets the brush.
+ /// Gets the brush.
///
- public IBrush Brush { get; set; }
+ public IBrush Brush { get; }
///
- /// Gets or sets the options
+ /// Gets the options
///
- public TextGraphicsOptions Options { get; set; }
+ public TextGraphicsOptions Options { get; }
///
- /// Gets or sets the text
+ /// Gets the text
///
- public string Text { get; set; }
+ public string Text { get; }
///
- /// Gets or sets the pen used for outlining the text, if Null then we will not outline
+ /// Gets the pen used for outlining the text, if Null then we will not outline
///
- public IPen Pen { get; set; }
+ public IPen Pen { get; }
///
- /// Gets or sets the font used to render the text.
+ /// Gets the font used to render the text.
///
- public Font Font { get; set; }
+ public Font Font { get; }
///
- /// Gets or sets the location to draw the text at.
+ /// Gets the location to draw the text at.
///
- public PointF Location { get; set; }
+ public PointF Location { get; }
protected override void BeforeImageApply(Image source, Rectangle sourceRectangle)
{
diff --git a/tests/ImageSharp.Benchmarks/Drawing/OldProcessors/DrawTextProcessorV1.cs b/tests/ImageSharp.Benchmarks/Drawing/OldProcessors/DrawTextProcessorV1.cs
deleted file mode 100644
index 3faaec2c2..000000000
--- a/tests/ImageSharp.Benchmarks/Drawing/OldProcessors/DrawTextProcessorV1.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using SixLabors.Fonts;
-using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Primitives;
-using SixLabors.ImageSharp.Processing.Drawing.Brushes;
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
-using SixLabors.ImageSharp.Processing.Drawing.Processors;
-using SixLabors.ImageSharp.Processing.Processors;
-using SixLabors.ImageSharp.Processing.Text;
-using SixLabors.Primitives;
-using SixLabors.Shapes;
-
-namespace SixLabors.ImageSharp.Benchmarks.Drawing.OldProcessors
-{
-
- ///
- /// Using the brush as a source of pixels colors blends the brush color with source.
- ///
- /// The pixel format.
- internal class DrawTextProcessor : ImageProcessor
- where TPixel : struct, IPixel
- {
- private FillRegionProcessor fillRegionProcessor = null;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The options
- /// The text we want to render
- /// The font we want to render with
- /// The brush to source pixel colors from.
- /// The pen to outline text with.
- /// The location on the image to start drawign the text from.
- public DrawTextProcessor(TextGraphicsOptions options, string text, Font font, IBrush brush, IPen pen, PointF location)
- {
- this.Brush = brush;
- this.Options = options;
- this.Text = text;
- this.Pen = pen;
- this.Font = font;
- this.Location = location;
- }
-
- ///
- /// Gets or sets the brush.
- ///
- public IBrush Brush { get; set; }
-
- ///
- /// Gets or sets the options
- ///
- public TextGraphicsOptions Options { get; set; }
-
- ///
- /// Gets or sets the text
- ///
- public string Text { get; set; }
-
- ///
- /// Gets or sets the pen used for outlining the text, if Null then we will not outline
- ///
- public IPen Pen { get; set; }
-
- ///
- /// Gets or sets the font used to render the text.
- ///
- public Font Font { get; set; }
-
- ///
- /// Gets or sets the location to draw the text at.
- ///
- public PointF Location { get; set; }
-
- protected override void BeforeImageApply(Image source, Rectangle sourceRectangle)
- {
- base.BeforeImageApply(source, sourceRectangle);
-
- // do everythign at the image level as we are deligating the processing down to other processors
- var style = new RendererOptions(this.Font, this.Options.DpiX, this.Options.DpiY, this.Location)
- {
- ApplyKerning = this.Options.ApplyKerning,
- TabWidth = this.Options.TabWidth,
- WrappingWidth = this.Options.WrapTextWidth,
- HorizontalAlignment = this.Options.HorizontalAlignment,
- VerticalAlignment = this.Options.VerticalAlignment
- };
-
- IPathCollection glyphs = TextBuilder.GenerateGlyphs(this.Text, style);
-
- var pathOptions = (GraphicsOptions)this.Options;
- if (this.Brush != null)
- {
- // we will reuse the processor for all fill operations to reduce allocations
- if (this.fillRegionProcessor == null)
- {
- this.fillRegionProcessor = new FillRegionProcessor()
- {
- Brush = this.Brush,
- Options = pathOptions
- };
- }
-
- foreach (IPath p in glyphs)
- {
- this.fillRegionProcessor.Region = new ShapeRegion(p);
- this.fillRegionProcessor.Apply(source, sourceRectangle);
- }
- }
-
- if (this.Pen != null)
- {
- // we will reuse the processor for all fill operations to reduce allocations
- if (this.fillRegionProcessor == null)
- {
- this.fillRegionProcessor = new FillRegionProcessor()
- {
- Brush = this.Brush,
- Options = pathOptions
- };
- }
-
- foreach (IPath p in glyphs)
- {
- this.fillRegionProcessor.Region = new ShapePath(p, this.Pen);
- this.fillRegionProcessor.Apply(source, sourceRectangle);
- }
- }
- }
-
- ///
- protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
- {
- // this is a no-op as we have processes all as an image, we should be able to pass out of before email apply a skip frames outcome
- }
- }
-}