// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.PixelFormats;
using System;
namespace SixLabors.ImageSharp.Drawing.Processing {
///
/// Renders a against individual coverage scanlines.
///
/// The pixel format.
public abstract class BrushRenderer
where TPixel : unmanaged, IPixel
{
///
/// Initializes a new instance of the class.
///
/// The configuration instance to use when performing operations.
/// The graphics options.
/// The canvas width for the current render pass.
protected BrushRenderer(
Configuration configuration,
GraphicsOptions options,
int canvasWidth)
{
this.Configuration = configuration;
this.Options = options;
this.CanvasWidth = canvasWidth;
this.Blender = PixelOperations.Instance.GetPixelBlender(options);
}
///
/// Gets the configuration instance to use when performing operations.
///
protected Configuration Configuration { get; }
///
/// Gets the pixel blender.
///
internal PixelBlender Blender { get; }
///
/// Gets the graphics options.
///
protected GraphicsOptions Options { get; }
///
/// Gets the canvas width for the current render pass.
///
protected int CanvasWidth { get; }
///
/// Applies the opacity weighting for each pixel in a scanline to the target based on the
/// pattern contained in the brush.
///
/// The destination row slice to shade.
/// The coverage values for the current destination scanline.
/// The x-position in the target pixel space that the start of the scanline data corresponds to.
/// The y-position in the target pixel space that the scanline corresponds to.
/// The worker-local scratch workspace for temporary blending buffers.
public abstract void Apply(
Span destinationRow,
ReadOnlySpan scanline,
int x,
int y,
BrushWorkspace workspace);
}
}