Documentation
¶
Overview ¶
Package soft is the pure-Go software rasterizer, used for golden tests and headless rendering.
Flutter: Skia's software rasterizer (the CPU backend used in flutter_test goldens).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
Render draws a scene into a new image of width x height pixels, in premultiplied RGBA with a transparent background.
Not everything is supported yet. A layer, an operation or a paint feature that is not returns the error SoftNotImplemented naming it, and no image. What works now: container, transform, offset, clip, opacity and color filter layers and picture layers; every operation, text included; paints with colors, gradients, image shaders, all 29 blend modes, color filters and inverted colors; and SaveLayer with a paint. The blurs, shadows, image filters and the backdrop filter and shader mask layers come with step 2.9, text with 4.x.
Flutter: no counterpart (flutter_test renders with Skia's software backend)
func Stroke ¶
func Stroke(contours []ui.FlatContour, st StrokeStyle) [][]ui.Offset
Stroke turns flattened contours into the polygons that cover their stroke. The polygons all wind the same way, so they are filled together with FillNonZero.
A contour with a single point, after repeated points are removed, draws a dot for round and square caps and nothing for butt caps.
Flutter: no counterpart (Skia's SkStroke)
Types ¶
type FillRule ¶
type FillRule int
FillRule says which points are inside a shape whose outline crosses itself.
Flutter: ui/painting.dart PathFillType
type ImageRasterizer ¶
type ImageRasterizer struct{}
ImageRasterizer is the ui.Rasterizer of the software renderer: Picture.ToImage and Scene.ToImage use it to make images in headless tests.
Flutter: no counterpart
func (ImageRasterizer) RasterizeScene ¶
RasterizeScene draws the scene into a new image of width x height pixels.
type Mask ¶
type Mask struct {
// Rect is the area of the surface the mask covers.
Rect image.Rectangle
// Cov holds the coverage of each pixel of Rect, row by row from the top.
Cov []float32
}
Mask is the coverage of a shape over a rectangle of pixels: 0 where the shape does not touch a pixel and 1 where it covers the pixel fully.
Flutter: no counterpart (SkMask)
func ClipMask ¶
ClipMask returns the coverage of a clip shape: the path, filled by its fill type under the transform m, inside the area of the surface. Without antiAlias the coverage is all or nothing, sampled at the pixel centers. It returns nil when nothing is covered.
Flutter: no counterpart (SkClipStack)
func OpMask ¶
OpMask returns the coverage of the shape that a drawing operation makes, drawn under the transform m, inside the area of the surface: the same coverage Render paints with, anti-aliased or not as the operation's paint says. It works for the operations that draw a shape from an outline: paths, rectangles, rounded rectangles, superellipses, DRRects, ovals, circles, arcs, lines and points. It returns nil when nothing is covered, and false for any other operation. The operation's mask filter and blend mode do not apply.
This is what the GPU renderer rasterizes into its coverage atlas (SPEC §9.2).
Flutter: no counterpart (SkMask)
func Rasterize ¶
Rasterize computes the coverage of the area enclosed by the contours, each of which is closed implicitly, inside the clip rectangle. The coverage of a pixel is the exact area of the pixel the shape covers where only one edge crosses it; with several edges in one pixel it is the area under the fill rule applied to the accumulated winding. It returns nil when nothing is covered. Contours with a point that is not finite are skipped.
Flutter: no counterpart (Skia's SkScan_AntiPath)
type StrokeStyle ¶
type StrokeStyle struct {
// Width is the width of the stroke; it must be greater than 0.
Width float64
// Cap is the shape of the ends of open contours; StrokeCapUnspecified is
// StrokeCapButt.
Cap ui.StrokeCap
// Join is the shape of the corners; StrokeJoinUnspecified is
// StrokeJoinMiter.
Join ui.StrokeJoin
// MiterLimit is the longest miter, as a multiple of half the width, that a
// miter join may have before it becomes a bevel; 0 is Flutter's default, 4.
MiterLimit float64
// Scale is how much a transform applied to the result magnifies lengths. It
// only sets the number of segments used for round joins and caps; 0 is 1.
Scale float64
}
StrokeStyle describes how a path is stroked. The units are those of the path.
Flutter: ui/painting.dart Paint.strokeWidth