Documentation
¶
Overview ¶
Package soft is a CPU renderer: it draws scene primitives into memory in pure Go, with no GPU and no system library.
It follows the Direct3D 11 renderer's shaders (see render/d3d11): the same signed-distance coverage for rounded rectangles, borders and clips, the same blurred-shadow and gradient formulas, the same glyph contrast correction, and premultiplied blending in sRGB space into an 8-bit target. A scene therefore looks the same drawn by either renderer, to within rounding.
It is the renderer of platforms that have no GPU backend yet, and it draws the frames of headless screenshot tests on every platform.
Index ¶
- type Renderer
- func (r *Renderer) BeginFrame(width, height int, clear scene.Color) error
- func (r *Renderer) CaptureNextFrame(fn func(*image.RGBA, error))
- func (r *Renderer) Close()
- func (rr *Renderer) DrawGlyphs(run scene.GlyphRun)
- func (rr *Renderer) DrawImages(ims []scene.ImageDraw)
- func (rr *Renderer) DrawQuads(qs []scene.Quad)
- func (r *Renderer) EndFrame() error
- func (r *Renderer) Image() *image.RGBA
- func (r *Renderer) PopClip()
- func (r *Renderer) PushClip(c scene.Rect)
- func (r *Renderer) PushRoundedClip(c scene.Rect, radii scene.Corners)
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer implements render.Renderer on the CPU.
func New ¶
New returns a renderer that draws into t's buffers, or into memory of its own when t is nil (see Image).
func (*Renderer) BeginFrame ¶
BeginFrame implements render.Renderer.
func (*Renderer) CaptureNextFrame ¶
CaptureNextFrame implements render.Renderer.
func (*Renderer) DrawGlyphs ¶
DrawGlyphs implements render.Renderer.
func (*Renderer) DrawImages ¶
DrawImages implements render.Renderer.
func (*Renderer) EndFrame ¶
EndFrame implements render.Renderer. It rasterizes the frame and hands it to the target; a window's target paces frames to its display.
func (*Renderer) Image ¶
Image returns a copy of the latest frame, premultiplied as image.RGBA is, with the alpha the frame has (opaque where an opaque clear color or fill covers it). It returns nil before the first frame.
type Target ¶
type Target interface {
// Buffer returns the pixels to draw the next width×height frame into, as
// premultiplied BGRA (Wayland's and DRM's ARGB8888 on a little-endian
// machine), stride bytes per row. The contents need not be kept from the
// previous frame: each frame is drawn in full.
Buffer(width, height int) (pix []byte, stride int, err error)
// Present shows the frame drawn into the latest buffer.
Present() error
}
A Target shows the frames a Renderer draws, for example a window's shared memory buffers. Without one, a Renderer draws into memory of its own.