Documentation
¶
Overview ¶
Package gpu defines the Renderer interface, flattens a ui.Scene into draw commands, and holds the glyph and path atlases shared by the renderers.
Flutter: the compositor and rasterizer (engine/src/flutter/flow and impeller).
Index ¶
- Constants
- func BlendIndex(m ui.BlendMode) (int, bool)
- func BlurRadiusToSigma(radius float64) float64
- func ClipCoverage(c Clip, area image.Rectangle, ...) (data []byte, empty bool)
- func ClipKey(area image.Rectangle, shapes []ClipShape) uint64
- func CoverageBytes(cov []float32) []byte
- func FloorDiv(a, b int) int
- func IsAxisAligned(m *ui.Matrix4) bool
- func MaskMargin(sh OpShape, scale float64) float64
- func MipLevels(w, h int) int
- func NinePieces(origin, size float64, src [4]float64) [4]float64
- func OpPaint(op ui.DisplayOp) *ui.Paint
- func OvalRadii(r ui.Rect) [4]ui.Radius
- func PaintAccess(op ui.DisplayOp) (*ui.Paint, func(*ui.Paint) ui.DisplayOp)
- func PaintOf(op ui.DisplayOp) *ui.Paint
- func PixelRect(r ui.Rect) image.Rectangle
- func RadiiOfRRect(r ui.RRect) [4]ui.Radius
- func RectOfRRect(r ui.RRect) ui.Rect
- func ShadowBounds(op ui.OpDrawShadow) (ui.Rect, bool)
- func ShapeBounds(op ui.DisplayOp) (ui.Rect, bool)
- func StyleCode(s ui.BlurStyle) int32
- func StyleKey(p *ui.Paint, stroke bool) uint64
- func TileIndex(m ui.TileMode) int32
- func VertexTriangles(v *ui.Vertices, m *ui.Matrix4) (floats []float32, bounds image.Rectangle, ok bool)
- func WhiteFill(p *ui.Paint) *ui.Paint
- type Affine2D
- type Atlas
- type AtlasEntry
- type AtlasStats
- type BlendFactor
- type Clip
- type ClipShape
- type ClipShapeKind
- type Command
- type CommandKind
- type Damage
- type DamageTracker
- type DrawList
- type FilterPass
- func BlurPasses(sx, sy float64, tile ui.TileMode, w, h int) []FilterPass
- func FilterPasses(f ui.ImageFilter, ctm Affine2D, tile ui.TileMode, w, h int) ([]FilterPass, bool)
- func MatrixPass(f *ui.MatrixImageFilter, ctm Affine2D, w, h int) FilterPass
- func MorphPasses(rx, ry float64, dilate bool, w, h int) []FilterPass
- type FixedBlend
- type FlattenOpts
- type Hasher
- type ImageEncoder
- type ImageInstance
- type ImageKey
- type LayerCache
- func (c *LayerCache[T]) BeginFrame(root ui.Layer)
- func (c *LayerCache[T]) Boundary(l ui.Layer) bool
- func (c *LayerCache[T]) Bytes() int
- func (c *LayerCache[T]) EndFrame(release func(T))
- func (c *LayerCache[T]) Len() int
- func (c *LayerCache[T]) Lookup(l ui.Layer, k LayerKey) *LayerEntry[T]
- func (c *LayerCache[T]) Put(l ui.Layer, k LayerKey, tex T, release func(T)) bool
- func (c *LayerCache[T]) Release(release func(T))
- type LayerEntry
- type LayerKey
- type MaskCache
- type MaskKey
- type MaskTile
- type OpShape
- type PaintResult
- type PaintSpec
- type PassKind
- type RRectParts
- type Renderer
- type ShadowPlan
- type ShapeEncoder
- func (e *ShapeEncoder) DRRect(outer, inner ui.RRect, p *ui.Paint) (needsMask string)
- func (e *ShapeEncoder) Fill()
- func (e *ShapeEncoder) Place(in *ShapeInstance, local ui.Rect, kind, flags int, alpha float32)
- func (e *ShapeEncoder) PlacePadded(in *ShapeInstance, local ui.Rect, kind, flags int, alpha float32, pad float64)
- func (e *ShapeEncoder) RRect(r ui.Rect, radii [4]ui.Radius, p *ui.Paint) (needsMask string)
- func (e *ShapeEncoder) Scale() float64
- func (e *ShapeEncoder) Segments(pts []ui.Offset, p *ui.Paint, line bool, mode ui.PointMode) (needsMask string)
- func (e *ShapeEncoder) StrokeHalfWidth(p *ui.Paint) (hw float64, alpha float32)
- func (e *ShapeEncoder) Superellipse(rs ui.RSuperellipse, p *ui.Paint) (needsMask string)
- type ShapeInstance
- type ShapePaint
- type Surface
- type SurfaceHandle
- type SurfaceKind
- type Tint
Constants ¶
const ( // ShadowAmbientAlpha is the alpha of the ambient shadow. // // Flutter: no counterpart ShadowAmbientAlpha = 0.039 // ShadowSpotAlpha is the alpha of the spot shadow. // // Flutter: no counterpart ShadowSpotAlpha = 0.25 // ShadowLightHeight is the height of the light above the surface. // // Flutter: no counterpart ShadowLightHeight = 600.0 // ShadowLightRadius is the radius of the light. // // Flutter: no counterpart ShadowLightRadius = 800.0 // ShadowAmbientFactor is the blur radius of the ambient shadow for each unit of elevation. // // Flutter: no counterpart ShadowAmbientFactor = 0.5 // ShadowMaxAmbient is the largest blur radius of the ambient shadow. // // Flutter: no counterpart ShadowMaxAmbient = 300.0 )
Skia's constants for the shadows of Flutter's physical shapes, as in the software renderer.
const ( // ClipMaskBudget is the most memory, in bytes, that clip masks that are not used in the // current frame may hold. // // Flutter: no counterpart ClipMaskBudget = 64 << 20 // ImageBudget is the same for image textures (RGBA, with mipmaps). // // Flutter: no counterpart ImageBudget = 256 << 20 // IdleFrames is how long a cached mask or image may go unused before it is dropped, // whatever the budget. // // Flutter: no counterpart IdleFrames = 240 )
The sizes of the caches of clip masks and images, and how long an entry may go unused.
const ( // ImageFloats is the size of an image instance in floats. // // Flutter: no counterpart ImageFloats = 32 // ImageFlagBox says that the instance's box is in pixels: exact coverage of an // axis-aligned rectangle. // // Flutter: no counterpart ImageFlagBox = 1 // ImageFlagAntialias says that the edge is smoothed. // // Flutter: no counterpart ImageFlagAntialias = 2 )
The image instance: eight vec4 attributes, see the image shaders.
const ( // LayerCacheBytes is how much the entries may hold, in bytes of pixels. // // Flutter: no counterpart LayerCacheBytes = 64 << 20 // LayerCacheIdleFrames is how many frames an entry may go unused. // // Flutter: no counterpart LayerCacheIdleFrames = 120 )
const ( // AtlasPageSize is the side of a page of the coverage atlas, and AtlasMaxPages the number // of pages it may grow to: 8-bit pages, so 32 MB at most. // // Flutter: no counterpart AtlasPageSize = 2048 // AtlasMaxPages is the number of pages the coverage atlas may grow to. // // Flutter: no counterpart AtlasMaxPages = 8 )
The sizes of the coverage atlas.
const ( // ShaderNone is no shader: the paint's color. // // Flutter: no counterpart ShaderNone = 0 // ShaderLinear is a linear gradient. // // Flutter: no counterpart ShaderLinear = 1 // ShaderRadial is a radial gradient. // // Flutter: no counterpart ShaderRadial = 2 // ShaderConical is a two-point conical gradient. // // Flutter: no counterpart ShaderConical = 3 // ShaderSweep is a sweep gradient. // // Flutter: no counterpart ShaderSweep = 4 // ShaderImage is an image shader. // // Flutter: no counterpart ShaderImage = 5 // ShaderConst is a degenerate gradient: one color. // // Flutter: no counterpart ShaderConst = 6 )
The shader kinds of the paint shaders (PaintSpec.Shader).
const ( // FilterNone is no color filter. // // Flutter: no counterpart FilterNone = 0 // FilterMode blends a color with the paint by a blend mode. // // Flutter: no counterpart FilterMode = 1 // FilterMatrix is a 4x5 color matrix. // // Flutter: no counterpart FilterMatrix = 2 // FilterToSrgb is the linear to sRGB gamma. // // Flutter: no counterpart FilterToSrgb = 3 // FilterFromSrgb is the sRGB to linear gamma. // // Flutter: no counterpart FilterFromSrgb = 4 )
The color filter kinds of the paint shaders (PaintSpec.Filter).
const ( // ShapeVec4s is the number of vec4 attributes of a shape instance. // // Flutter: no counterpart ShapeVec4s = 12 // ShapeFloats is the size of a shape instance in floats. // // Flutter: no counterpart ShapeFloats = ShapeVec4s * 4 // ShapeStride is the size of a shape instance in bytes. // // Flutter: no counterpart ShapeStride = ShapeFloats * 4 )
The layout of an instance: twelve vec4 attributes, the same in both shaders.
const ( // ShapeKindRRect is a rounded rectangle, minus shape B when the flags say so. // // Flutter: no counterpart ShapeKindRRect = 0 // ShapeKindSuper is a rounded superellipse. // // Flutter: no counterpart ShapeKindSuper = 1 // ShapeKindSegment is a line segment with caps, or a dot. // // Flutter: no counterpart ShapeKindSegment = 2 // ShapeKindFill covers every pixel of the quad. // // Flutter: no counterpart ShapeKindFill = 3 // ShapeKindBox is an axis-aligned rectangle in pixels, minus shape B, by exact area. // // Flutter: no counterpart ShapeKindBox = 4 // ShapeKindOutline is every point within a half width of a rounded rectangle's // outline. // // Flutter: no counterpart ShapeKindOutline = 5 // ShapeKindShadow is a rounded rectangle in pixels blurred by a Gaussian. // // Flutter: no counterpart ShapeKindShadow = 6 )
The kinds of shape of the shader (instance float 10).
const ( // ShapeFlagHasB says that shape B is cut out of shape A. // // Flutter: no counterpart ShapeFlagHasB = 1 // ShapeFlagAntialias says that the edge is smoothed. // // Flutter: no counterpart ShapeFlagAntialias = 2 // ShapeFlagSimilarity says that the transform only rotates, flips and scales evenly. // // Flutter: no counterpart ShapeFlagSimilarity = 4 )
The flags of the shader (instance float 11).
const ( // SuperellipseExtent is the size of a corner box in radii. // // Flutter: no counterpart SuperellipseExtent = 1.2924 // SuperellipseExponent is the exponent n of the corner curve. // // Flutter: no counterpart SuperellipseExponent = 5 )
The constants of ui.Path.AddRSuperellipse, which the software renderer draws: a corner box is this much times the radius, filled by |x|^n + |y|^n = 1.
const MaxAtlasTile = 256
MaxAtlasTile is the largest width or height of a tile of an Atlas; a bigger mask is cut into tiles.
Flutter: no counterpart
const MaxKernelRadius = 64
MaxKernelRadius bounds the taps of a blur pass on each side of the center.
Flutter: no counterpart
const MaxLowSigma = 8.0
MaxLowSigma is the largest deviation a blur pass works with: a blur with more is done on a picture scaled down by a power of two until it is not.
Flutter: no counterpart
const MaxStops = 32
MaxStops is the most color stops a gradient can have; it is the size of the arrays of the paint shaders.
Flutter: no counterpart
const MinSigma = 0.01
MinSigma is the deviation below which a blur does nothing, as in the software renderer.
Flutter: no counterpart
const VertexFloats = 8
VertexFloats is the size of a vertex that VertexTriangles makes, in floats: the position in pixels (x, y), the color not premultiplied (r, g, b, a), and the texture coordinates.
Flutter: no counterpart
Variables ¶
This section is empty.
Functions ¶
func BlendIndex ¶
BlendIndex is the index of a blend mode in the order of Flutter's BlendMode, which is the index the blend shaders switch on; false for a mode outside it. The zero mode is srcOver.
Flutter: no counterpart
func BlurRadiusToSigma ¶
BlurRadiusToSigma is Skia's conversion of a blur radius to a deviation.
Flutter: no counterpart
func ClipCoverage ¶
func ClipCoverage(c Clip, area image.Rectangle, rasterize func(path *ui.Path, m *ui.Matrix4, antiAlias bool, area image.Rectangle) (rect image.Rectangle, cov []float32)) (data []byte, empty bool)
ClipCoverage makes the coverage of the shapes of the clip over the area, as the bytes of an 8-bit texture, row by row from the top. empty says that the shapes leave nothing (no bytes). rasterize fills the shape's outline under its transform, with or without anti-aliasing, over the area: one coverage from 0 to 1 per pixel of rect, or nil for a shape that covers nothing.
Flutter: no counterpart
func ClipKey ¶
ClipKey hashes what a clip mask is made of: its area and its shapes, with the transform each was clipped under.
Flutter: no counterpart
func CoverageBytes ¶
CoverageBytes converts coverages from 0 to 1 to the bytes of an 8-bit texture.
Flutter: no counterpart
func IsAxisAligned ¶
IsAxisAligned reports whether the transform keeps rectangles axis-aligned: it has no rotation by other than a multiple of 90 degrees, no skew and no perspective. A rotation off by less than a millionth (what float32 gives for a quarter turn) counts as none.
Flutter: no counterpart
func MaskMargin ¶
MaskMargin is how far the coverage of the shape can reach beyond its bounds, in its own units, under a transform that scales lengths by scale: an edge pixel, and for a stroke half its width times its miter.
Flutter: no counterpart
func MipLevels ¶
MipLevels is the number of levels of an image of w x h pixels down to one pixel, the image itself included.
Flutter: no counterpart
func NinePieces ¶
NinePieces returns the four edges of the three pieces along one axis of the destination, starting at origin and size long. The outer pieces keep their size in the image, and the middle one takes the rest; when they do not fit the outer pieces shrink in proportion and the middle one vanishes.
Flutter: no counterpart
func OpPaint ¶
OpPaint returns the paint that a drawing operation is drawn with, or nil for an operation that has none (clips, transforms, pictures, paragraphs, shadows, colors).
Flutter: no counterpart
func OvalRadii ¶
OvalRadii returns the radii that make a rounded rectangle of the rectangle an oval.
Flutter: no counterpart
func PaintAccess ¶
PaintAccess returns the paint of a drawing operation and the function that makes the same operation with another paint; nil for the operations without one.
Flutter: no counterpart
func PaintOf ¶
PaintOf returns the paint of a drawing operation; nil for the operations without one.
Flutter: no counterpart
func RadiiOfRRect ¶
RadiiOfRRect returns the corner radii of a rounded rectangle, clockwise from the top left.
Flutter: no counterpart
func ShadowBounds ¶
func ShadowBounds(op ui.OpDrawShadow) (ui.Rect, bool)
ShadowBounds returns the rectangle, in the path's coordinates, that Canvas.drawShadow can change: the ambient shadow (the shape blurred in place) and the spot shadow (the shape grown about its center, moved down, and blurred), both reaching three sigma. It returns false when the bounds cannot be known (a path that is not finite).
Flutter: no counterpart
func ShapeBounds ¶
ShapeBounds returns the bounds of what a shape-drawing operation covers in its own coordinates, strokes included, and false for an operation that is not one of the shapes (rectangles, rounded rectangles, ovals, circles, arcs, paths, lines and points).
Flutter: no counterpart
func StyleKey ¶
StyleKey hashes the parts of a paint that change the shape's coverage.
Flutter: no counterpart
func VertexTriangles ¶
func VertexTriangles(v *ui.Vertices, m *ui.Matrix4) (floats []float32, bounds image.Rectangle, ok bool)
VertexTriangles turns the vertices of Canvas.drawVertices into the triangles that are drawn, three vertices of VertexFloats floats each, with the positions under the transform. bounds are the pixels the triangles touch; ok is false when there is nothing to draw.
Flutter: no counterpart
Types ¶
type Affine2D ¶
type Affine2D struct{ A, B, C, D, E, F float64 }
Affine2D is the 2D part of a transform: x' = A*x + C*y + E, y' = B*x + D*y + F. The shape and image pipelines of every GPU renderer work with it, because a shader needs the inverse of the transform, not the 4x4 matrix.
Flutter: no counterpart
func (Affine2D) AxisAligned ¶
AxisAligned says that the transform keeps rectangles axis-aligned (it may flip them or turn them by a quarter).
Flutter: no counterpart
func (Affine2D) Invert ¶
Invert returns the inverse transform; false when the transform has none (its determinant is 0 or not a number).
Flutter: no counterpart
func (Affine2D) Similarity ¶
Similarity says that the transform only rotates, flips and scales evenly, so that a distance in the shape's units is the same number of pixels in every direction.
Flutter: no counterpart
type Atlas ¶
type Atlas[K comparable] struct { // contains filtered or unexported fields }
Atlas keeps track of where the 8-bit coverage tiles of a renderer's coverage atlas are (SPEC §9.1, "General paths"). The pages are squares of pageSize pixels that the renderer makes into textures. A page is cut into square slots of one size, so a freed slot is always reusable, and tiles are cached by key: the least recently used are evicted when the atlas is full, but never one that was used in the current frame, because the frame's draws still read it.
It does not touch the pixels; the renderer uploads a tile into its slot after Put. It is not safe for concurrent use.
Flutter: no counterpart (Skia's GrDrawOpAtlas)
func NewAtlas ¶
func NewAtlas[K comparable](pageSize, maxPages int) *Atlas[K]
NewAtlas makes an atlas of at most maxPages pages of pageSize pixels each. pageSize should be a multiple of MaxAtlasTile.
Flutter: no counterpart
func (*Atlas[K]) BeginFrame ¶
func (a *Atlas[K]) BeginFrame()
BeginFrame starts a frame: the tiles used from now on are protected from eviction until the next call.
Flutter: no counterpart
func (*Atlas[K]) Clear ¶
func (a *Atlas[K]) Clear()
Clear forgets every tile and every page.
Flutter: no counterpart
func (*Atlas[K]) Get ¶
func (a *Atlas[K]) Get(key K) *AtlasEntry[K]
Get returns the tile stored under key, or nil, and marks it used in this frame.
Flutter: no counterpart
func (*Atlas[K]) Pages ¶
Pages returns the number of pages made; the renderer keeps a texture for each.
Flutter: no counterpart
func (*Atlas[K]) Put ¶
func (a *Atlas[K]) Put(key K, w, h int) (*AtlasEntry[K], error)
Put stores a tile of w x h pixels under key and returns it; the caller uploads the pixels at (X, Y) of the page. A tile of no size is stored as an empty entry with no slot. The key must not be stored already. It fails with AtlasTileInvalid for a size that is negative or above MaxAtlasTile, and AtlasFull when every slot is in use in this frame and no page can be made.
Flutter: no counterpart
func (*Atlas[K]) Stats ¶
func (a *Atlas[K]) Stats() AtlasStats
Stats says what the atlas holds.
Flutter: no counterpart
type AtlasEntry ¶
type AtlasEntry[K comparable] struct { // Key is what the tile was stored under. Key K // Page is the index of the page the tile is on. Page int // X and Y are the top left corner of the tile's slot in the page, in pixels. X, Y int // W and H are the size of the tile's content, at the slot's corner. W, H int // Empty says that the tile holds nothing: it has no slot, and W and H are 0. // Storing the empty tiles keeps a renderer from rasterizing them again. Empty bool // OX and OY are free for the renderer to keep a tile's offset in; the atlas // does not use them. OX, OY int // contains filtered or unexported fields }
AtlasEntry is a tile of an Atlas: where it is, and how much of its slot it uses. An entry stays valid until the atlas evicts it, which only happens for entries that were not used in the current frame.
Flutter: no counterpart
type AtlasStats ¶
type AtlasStats struct {
// Pages is the number of pages made, Entries the number of tiles stored
// (including empty ones), and Evicted the number of tiles evicted so far.
Pages, Entries, Evicted int
}
AtlasStats says what an Atlas holds.
Flutter: no counterpart
type BlendFactor ¶
type BlendFactor int
BlendFactor is a factor of a fixed-function blend equation.
Flutter: no counterpart
const ( // BlendFactorZero is 0. // // Flutter: no counterpart BlendFactorZero BlendFactor = iota // BlendFactorOne is 1. // // Flutter: no counterpart BlendFactorOne // BlendFactorOneMinusSrcAlpha is 1 minus the alpha of the source. // // Flutter: no counterpart BlendFactorOneMinusSrcAlpha // BlendFactorOneMinusDstAlpha is 1 minus the alpha of the destination. // // Flutter: no counterpart BlendFactorOneMinusDstAlpha )
The factors that the fixed-function blend modes use.
type Clip ¶
type Clip struct {
// Bounds is the rectangle that everything drawn is cut to. Its edges are
// whole pixels, except for the edges of anti-aliased clips.
Bounds ui.Rect
// Shapes are the clips that are not folded into Bounds, in the order they were
// made. Treat the slice as read-only.
Shapes []ClipShape
}
Clip is the part of the surface that drawing may change. Bounds is a rectangle in pixels (whose edges are fractional when the clip is anti-aliased); Shapes narrow it further and are applied in order. A rectangle clip that the transform keeps axis-aligned is folded into Bounds, so that a renderer can use the scissor test; only the other shapes are listed.
Flutter: no counterpart
type ClipShape ¶
type ClipShape struct {
// Kind says which of the shape fields is used.
Kind ClipShapeKind
// Rect is the shape of ClipShapeRect.
Rect ui.Rect
// RRect is the shape of ClipShapeRRect.
RRect ui.RRect
// RSuperellipse is the shape of ClipShapeRSuperellipse.
RSuperellipse ui.RSuperellipse
// Path is the shape of ClipShapePath.
Path *ui.Path
// Difference says that the shape is cut out of the clip instead of being
// intersected with it.
Difference bool
// AntiAlias says whether the edge is smoothed.
AntiAlias bool
// Transform maps the shape to the surface.
Transform ui.Matrix4
}
ClipShape is a clip that is not a rectangle of pixels. The shape is in its own coordinates; Transform maps them to the surface.
Flutter: no counterpart
type ClipShapeKind ¶
type ClipShapeKind int
ClipShapeKind says what a ClipShape is.
Flutter: no counterpart
const ( // ClipShapeUnspecified is the zero value: not a shape. // // Flutter: no counterpart ClipShapeUnspecified ClipShapeKind = iota // ClipShapeRect is a rectangle that is not axis-aligned in the surface (the // transform rotates or skews it) or a rectangle that is subtracted // (Difference). // // Flutter: no counterpart ClipShapeRect // ClipShapeRRect is a rounded rectangle. // // Flutter: no counterpart ClipShapeRRect // ClipShapeRSuperellipse is a rounded superellipse. // // Flutter: no counterpart ClipShapeRSuperellipse // ClipShapePath is a path. // // Flutter: no counterpart ClipShapePath )
The kinds of clip shape.
type Command ¶
type Command struct {
// Kind says which fields are meaningful.
Kind CommandKind
// Op is the drawing operation of a CommandDraw, or the ui.OpSaveLayer of a
// CommandBeginLayer that a canvas made. Clips, transforms and Save are not
// commands: they are folded into Transform and Clip.
Op ui.DisplayOp
// Layer is the scene layer of a CommandBeginLayer that a scene made, or nil.
// Its Offset, if it has one, is already part of the transform of the commands
// inside the group.
Layer ui.Layer
// Transform maps the coordinates of Op to the surface's pixels. For a group it
// is the transform in effect where the group is composited.
Transform ui.Matrix4
// Clip is what may be drawn into. For CommandBeginLayer it is the clip the
// group is composited with, which for a clip layer with a save layer includes
// the layer's own shape.
Clip Clip
}
Command is one step of drawing, with the state it is drawn in. A renderer runs the commands of a DrawList in order.
Flutter: no counterpart
type CommandKind ¶
type CommandKind int
CommandKind says what a Command asks of a renderer.
Flutter: no counterpart
const ( // CommandKindUnspecified is the zero value: not a command. // // Flutter: no counterpart CommandKindUnspecified CommandKind = iota // CommandDraw draws one operation of a picture with the command's transform // and clip. // // Flutter: no counterpart CommandDraw // CommandBeginLayer starts a group that is drawn separately and composited at // the matching CommandEndLayer: a SaveLayer, or a scene layer that needs a // group (opacity, filters, masks, and clips with a save layer). // // Flutter: no counterpart CommandBeginLayer // CommandEndLayer ends the innermost group and composites it. // // Flutter: no counterpart CommandEndLayer )
The kinds of command.
type Damage ¶
type Damage struct {
// Full says that the whole surface may have changed; Rects is then empty.
Full bool
// Rects are the changed pixels, from the top left, when Full is false. There is
// none when the frame is the same as the one before it.
Rects []image.Rectangle
}
Damage is the part of a surface that a frame changed from the frame before it (SPEC §9.1, "Damage"): what a renderer tells the compositor when it presents.
Flutter: no counterpart (flutter::FrameDamage)
type DamageTracker ¶
type DamageTracker struct {
// contains filtered or unexported fields
}
DamageTracker finds what changed between the scenes of a surface. It divides the surface into tiles, and for each tile hashes what the scene draws there: every picture (by identity: a picture is immutable, and a layer that the framework did not repaint keeps its picture) with the transform it is drawn under, and the parameters of the layers around it (clips, opacity, filters). A tile whose hash differs from the last frame's is damaged. A picture that was recorded again is damaged even if it drew the same, and what the tracker cannot bound (a draw that fills the clip, an image filter on a layer, an unknown layer) damages the whole clip or the whole surface; it errs on the side of drawing more.
The tracker holds on to the last scene's pictures and parameters so that their addresses are not reused while they are compared. Use it on one thread.
Flutter: no counterpart (flutter::DiffContext)
func NewDamageTracker ¶
func NewDamageTracker() *DamageTracker
NewDamageTracker returns a tracker that has seen no frame, so that the first Update reports the whole surface.
Flutter: no counterpart
func (*DamageTracker) Invalidate ¶
func (t *DamageTracker) Invalidate()
Invalidate forgets the last frame: the next Update reports the whole surface. Call it when the pixels the compositor has are not the last frame's (the window lost its content, or a frame was drawn and not presented).
Flutter: no counterpart
func (*DamageTracker) Update ¶
func (t *DamageTracker) Update(scene *ui.Scene, w, h int) Damage
Update says what the scene changes from the scene given to the last call, for a surface of w x h pixels. The whole surface is reported for the first frame, after Invalidate, when the size changed, for the same scene again (a request to draw it once more means that the window needs all of it), and for a scene with something that depends on the pixels around it.
Flutter: no counterpart
type DrawList ¶
type DrawList struct {
// Commands are in drawing order; each CommandBeginLayer has a matching
// CommandEndLayer after it.
Commands []Command
}
DrawList is a scene flattened into the commands that draw it, in order.
Flutter: no counterpart (flutter::DisplayList of the whole layer tree)
func Flatten ¶
func Flatten(scene *ui.Scene, opts ...FlattenOpts) (*DrawList, error)
Flatten turns a scene into the list of commands that draws it. The layer tree and the pictures' operations are walked in painting order. Transforms and clips are folded into each command; layers that need a group become a pair of CommandBeginLayer and CommandEndLayer. Nothing is dropped: a renderer decides what it can draw. A clip that leaves nothing to draw does not remove the commands inside it; a renderer may skip a command whose Clip is empty.
It fails with FlattenSceneNil for a nil scene and FlattenLayerUnknown for a layer of a type it does not know.
Flutter: no counterpart (flutter::LayerTree::Preroll and Paint)
type FilterPass ¶
type FilterPass struct {
Kind PassKind
// OutW and OutH are the size of the pass's output.
OutW, OutH int
// Axis is 0 for x and 1 for y, for blur and morphology.
Axis int32
// Sigma, Radius and Norm describe the Gaussian kernel: its deviation, the taps
// on each side of the center, and 1 over the sum of the weights.
Sigma, Norm float32
Radius int32
// Tile is what lies beyond the edges of the source for blur and resampling.
Tile int32
// Dilate says that morphology takes the largest value, else the smallest.
Dilate bool
// Factor is how many source pixels one output pixel spans, for PassDown and PassUp.
Factor [2]int32
// Inv maps a pixel of the surface to where the output pixel is read from, for
// PassMatrix, and Quality is 0 for bilinear, 1 for nearest, 2 for nothing.
Inv [6]float32
Quality int32
// Spec holds the color filter of PassColor.
Spec *PaintSpec
}
FilterPass is one pass over the pixels.
Flutter: no counterpart
func BlurPasses ¶
func BlurPasses(sx, sy float64, tile ui.TileMode, w, h int) []FilterPass
BlurPasses makes the passes of a blur of a w x h picture with the deviations in pixels along x and y.
Flutter: no counterpart
func FilterPasses ¶
func FilterPasses(f ui.ImageFilter, ctm Affine2D, tile ui.TileMode, w, h int) ([]FilterPass, bool)
FilterPasses turns an image filter into the passes over a w x h picture, under the transform that the filter's radii and matrix are in; tile is the mode a blur gets when it has none. false says that the filter is not one the renderer knows.
Flutter: no counterpart
func MatrixPass ¶
func MatrixPass(f *ui.MatrixImageFilter, ctm Affine2D, w, h int) FilterPass
MatrixPass moves the pixels by the filter's matrix, which acts in the local space of the canvas: on the surface the transform is ctm * M * ctm^-1.
Flutter: no counterpart
func MorphPasses ¶
func MorphPasses(rx, ry float64, dilate bool, w, h int) []FilterPass
MorphPasses makes the passes of a dilation or erosion by radii in pixels, rounded to whole pixels.
Flutter: no counterpart
type FixedBlend ¶
type FixedBlend struct{ Src, Dst BlendFactor }
FixedBlend is the equation of a blend mode that the blend unit makes exactly when the shape's coverage scales the source: source * Src + destination * Dst, for color and alpha alike.
Flutter: no counterpart
func FixedBlendOf ¶
func FixedBlendOf(mode ui.BlendMode) (FixedBlend, bool)
FixedBlendOf returns the fixed-function equation of a blend mode; false for the modes that need a shader reading a copy of the destination (SPEC §9.1 "Blend modes"). The zero mode is srcOver.
Flutter: no counterpart
type FlattenOpts ¶
type FlattenOpts struct {
// Bounds is the surface in pixels; the clip starts as this rectangle. The zero
// value starts with an unbounded clip.
Bounds ui.Rect
// Boundary, when it is not nil, is asked about every ui.TransformLayer and
// ui.ContainerLayer (the layers Flatten folds into the commands under them),
// and a layer it answers true for becomes a group, so that a renderer can keep
// what the group draws for the next frame. The group is composited under the
// clip it is in, and what is inside it is drawn under a clip of whole pixels
// that has none of that clip's shapes, so that the group's pixels do not depend
// on them. The group's Command.Transform is the transform of its contents.
Boundary func(l ui.Layer) bool
}
FlattenOpts are the optional arguments of Flatten.
Flutter: no counterpart
type Hasher ¶
type Hasher uint64
Hasher is a 64-bit FNV-1a hash that the cache keys of the renderers are made with.
Flutter: no counterpart
type ImageEncoder ¶
type ImageEncoder struct {
// T is the transform of the command, and Outer the pixels its clip reaches.
T Affine2D
Outer image.Rectangle
// Clip is the clip rectangle with fractional edges.
Clip [4]float32
// Paint gives the alpha (as the color's four components) and the antialiasing.
Paint ShapePaint
// Quality is the paint's filter quality.
Quality ui.FilterQuality
// Levels is the number of mip levels of the image.
Levels int
// Emit is called with each finished instance and the pixels its quad covers.
Emit func(in *ImageInstance, covers image.Rectangle)
}
ImageEncoder turns the image draws of one drawing command into instances. The renderer fills in the command's state and Emit, which receives each instance with the pixels it covers.
Flutter: no counterpart
func (*ImageEncoder) Atlas ¶
func (e *ImageEncoder) Atlas(w, h int, op ui.OpDrawAtlas, mode int)
Atlas draws the parts of an atlas image of w x h pixels, each moved by its transform. With colors, each sprite is the source and its color the destination of the blend mode with the index mode, so that srcIn with a transparent white scales the sprite's alpha.
Flutter: no counterpart
func (*ImageEncoder) Blit ¶
func (e *ImageEncoder) Blit(src ui.Rect, toDevice Affine2D, t *Tint)
Blit draws the part src of the image, whose texels the transform maps to the surface.
Flutter: no counterpart
type ImageInstance ¶
type ImageInstance = [ImageFloats]float32
ImageInstance is the attributes of one image rectangle: the quad in pixels (0-3), the inverse transform to texels (4-9), the flags (10), the paint's alpha as a multiplier (12-15), the clip (16-19), the box (20-23), the level of detail, the quality and the blend index of the tint (24-26, -1 for none), and the tint (28-31).
Flutter: no counterpart
type ImageKey ¶
ImageKey identifies an image's pixels: clones share them.
Flutter: no counterpart
type LayerCache ¶
type LayerCache[T any] struct { // contains filtered or unexported fields }
LayerCache holds the pixels of retained layers.
Flutter: no counterpart
func NewLayerCache ¶
func NewLayerCache[T any](after int) *LayerCache[T]
NewLayerCache makes a cache that keeps the layers that were in the last after scenes.
Flutter: no counterpart
func (*LayerCache[T]) BeginFrame ¶
func (c *LayerCache[T]) BeginFrame(root ui.Layer)
BeginFrame starts a frame of the scene whose root layer is given; the root is never cached.
Flutter: no counterpart
func (*LayerCache[T]) Boundary ¶
func (c *LayerCache[T]) Boundary(l ui.Layer) bool
Boundary says whether the layer is cached: one of the layers that the draw list folds, that is not the root, and that has been in the last c.after scenes.
Flutter: no counterpart
func (*LayerCache[T]) Bytes ¶
func (c *LayerCache[T]) Bytes() int
Bytes returns the bytes of pixels the entries hold.
Flutter: no counterpart
func (*LayerCache[T]) EndFrame ¶
func (c *LayerCache[T]) EndFrame(release func(T))
EndFrame forgets the layers that were not in the scene, and evicts the entries that have not been used for a while, then the least recently used ones while the cache holds more than its budget.
Flutter: no counterpart
func (*LayerCache[T]) Len ¶
func (c *LayerCache[T]) Len() int
Len returns the number of entries.
Flutter: no counterpart
func (*LayerCache[T]) Lookup ¶
func (c *LayerCache[T]) Lookup(l ui.Layer, k LayerKey) *LayerEntry[T]
Lookup returns the layer's entry if it has the pixels for the key, and marks it used in this frame.
Flutter: no counterpart
func (*LayerCache[T]) Put ¶
func (c *LayerCache[T]) Put(l ui.Layer, k LayerKey, tex T, release func(T)) bool
Put keeps the texture as the layer's pixels, and says whether it did; release frees the texture of the entry it replaces. An entry that a draw of this frame still waits for is not replaced.
Flutter: no counterpart
func (*LayerCache[T]) Release ¶
func (c *LayerCache[T]) Release(release func(T))
Release frees every texture.
Flutter: no counterpart
type LayerEntry ¶
type LayerEntry[T any] struct { LayerKey // Tex is the renderer's texture of the pixels. Tex T // contains filtered or unexported fields }
LayerEntry is a layer's pixels.
Flutter: no counterpart
type LayerKey ¶
type LayerKey struct {
// M is the transform of the layer's contents.
M [16]float32
// Rect is the pixels of the surface that the group covers.
Rect image.Rectangle
}
LayerKey is what the pixels of a cached layer depend on.
Flutter: no counterpart
type MaskCache ¶
type MaskCache struct {
// Rasterize makes the coverage of op under m over area: the rectangle it covers and one
// coverage from 0 to 1 per pixel, row by row; nil when the shape covers nothing there.
Rasterize func(op ui.DisplayOp, m *ui.Matrix4, area image.Rectangle) (rect image.Rectangle, cov []float32)
// NewPage is called when the atlas grows by a page, which the renderer must make: an 8-bit
// texture of PageSize pixels on each side.
NewPage func() error
// Upload copies the bytes of a tile, w x h, row by row, to the page at (x, y).
Upload func(page, x, y, w, h int, data []byte) error
// Rasterized counts the tiles that were rasterized.
Rasterized int
// contains filtered or unexported fields
}
MaskCache is the coverage atlas of a renderer and the tiling of shapes into it.
Flutter: no counterpart
func NewMaskCache ¶
NewMaskCache returns an empty cache whose atlas has pages of pageSize pixels, at most maxPages of them.
Flutter: no counterpart
func (*MaskCache) BeginFrame ¶
func (c *MaskCache) BeginFrame()
BeginFrame starts a frame: what is used from now on survives until the next.
Flutter: no counterpart
func (*MaskCache) Clear ¶
func (c *MaskCache) Clear()
Clear forgets every tile.
Flutter: no counterpart
func (*MaskCache) SetAtlas ¶
SetAtlas replaces the atlas, for tests that need a small one.
Flutter: no counterpart
func (*MaskCache) Tiles ¶
func (c *MaskCache) Tiles(op ui.DisplayOp, sh OpShape, m *ui.Matrix4, margin float64, visible image.Rectangle) ([]MaskTile, error)
Tiles returns the tiles of coverage to draw for the shape under the transform, within the visible pixels, rasterizing and uploading the ones the atlas does not have. margin is how far the shape's coverage can reach beyond its bounds, in its own units. It fails with AtlasFull when a tile fits no page.
Flutter: no counterpart
type MaskKey ¶
type MaskKey struct {
Geom uint64 // a hash of the shape's geometry
Style uint64 // a hash of the paint's stroke and anti-aliasing
Lin [4]float32 // the linear part of the transform
FX, FY float32 // the fractional part of its translation
TX, TY int32 // the tile, in tiles from the origin of the shape's space
}
MaskKey identifies a tile of the coverage of a shape.
Flutter: no counterpart
type MaskTile ¶
type MaskTile struct {
Page int // the atlas page
X0, Y0, X1, Y1 int // the pixels of the surface it covers
AX, AY int // its top left texel on the page
}
MaskTile is a tile of coverage to draw: where it goes on the surface and where its texels are.
Flutter: no counterpart
type OpShape ¶
type OpShape struct {
Geom uint64
Bounds ui.Rect
Paint *ui.Paint
Stroke bool // the outline is stroked, not filled
}
OpShape describes what an operation draws, for the atlas: a hash of its geometry, its bounds in its own coordinates, and its paint.
Flutter: no counterpart
type PaintResult ¶
type PaintResult int
PaintResult says what to do with a paint after a spec was made from it.
Flutter: no counterpart
const ( // PaintDraw says to draw with the spec. // // Flutter: no counterpart PaintDraw PaintResult = iota // PaintNothing says that the paint draws nothing: the command is done. // // Flutter: no counterpart PaintNothing // PaintUnsupported says that the renderer cannot draw the paint; the name of the feature // comes with it. // // Flutter: no counterpart PaintUnsupported )
type PaintSpec ¶
type PaintSpec struct {
// Shader is one of the Shader constants.
Shader int32
// XF maps a pixel of the surface to the shader's space: a, b, c, d, e, f.
XF [6]float32
// P0 and P1 are the geometry of the gradient: linear: from x, y, dx, dy and
// 1 / (dx*dx + dy*dy); radial: center x, y, radius; conical: focal x, y, focal radius and
// end center x, y, end radius; sweep: center x, y, start, span.
P0, P1 [4]float32
// Tile is the tile mode in x and y: 0 clamp, 1 repeated, 2 mirror, 3 decal.
Tile [2]int32
// RampN is the number of color stops, RampCol their colors (not premultiplied) and RampPos
// their positions.
RampN int32
RampCol [MaxStops][4]float32
RampPos [MaxStops]float32
// Image is the renderer's texture of an image shader, and ImgInfo its quality (0 none, 1
// low, 2 medium, 3 high) and level.
Image any
ImgInfo [4]float32
// ConstCol is the color of a degenerate gradient, premultiplied.
ConstCol [4]float32
// Dither says that the ordered dither of gradients is added.
Dither bool
// Filter is one of the Filter constants, FilterCol the premultiplied color of a mode filter,
// FilterBlend its blend index, and FilterMat the columns of a matrix filter.
Filter int32
FilterCol [4]float32
FilterBlend int32
FilterMat [20]float32
// Invert says that the colors are inverted after the filter.
Invert bool
// ReadBlend is 0 when the fixed-function blend does the paint's blend mode, else the blend
// index plus one: the shader blends with a copy of the pixels under the draw.
ReadBlend int32
}
PaintSpec is the shader, color filter and blend of a paint, as uniforms.
Flutter: no counterpart
func (*PaintSpec) SetColorFilter ¶
func (sp *PaintSpec) SetColorFilter(f *ui.ColorFilter, invert bool)
SetColorFilter fills the color filter and inverted colors of a spec.
Flutter: no counterpart
func (*PaintSpec) SetGradient ¶
SetGradient fills the shader part of a spec for a gradient under the transform that takes the shader's local space to the surface. The result says what to do with the paint; for PaintUnsupported the string is the feature.
Flutter: no counterpart
func (*PaintSpec) SetImageShader ¶
func (sp *PaintSpec) SetImageShader(is *ui.ImageShader, toDevice Affine2D, texture func(img *ui.Image) (tex any, levels int, err error)) (PaintResult, error)
SetImageShader fills the shader part of a spec for an image shader under the transform that takes the shader's local space to the surface. texture finds the renderer's texture of the image and its number of mip levels, making it if it must. The result says what to do with the paint; an error from texture is returned as it is.
Flutter: no counterpart
type PassKind ¶
type PassKind int
PassKind is what a filter pass does.
Flutter: no counterpart
const ( // PassCopy is the pixels as they are. // // Flutter: no counterpart PassCopy PassKind = iota // PassBlur is one axis of a Gaussian blur. // // Flutter: no counterpart PassBlur // PassMorph is one axis of a dilation or erosion. // // Flutter: no counterpart PassMorph // PassMatrix is the pixels moved by a transform. // // Flutter: no counterpart PassMatrix // PassColor is a color filter. // // Flutter: no counterpart PassColor // PassDown is the average of blocks of pixels. // // Flutter: no counterpart PassDown // PassUp is bilinear scaling up. // // Flutter: no counterpart PassUp )
type RRectParts ¶
RRectParts is a rounded rectangle ready for the shader: its center, half extents and the radius of each corner, clockwise from the top left.
Flutter: no counterpart
func PartsOf ¶
PartsOf normalizes a rectangle with corner radii as Skia does: edges in order, a corner with a missing radius square, and the radii scaled down together when two on one side are longer than the side. It reports false for a rectangle that is not finite.
Flutter: no counterpart
func (RRectParts) Rect ¶
func (p RRectParts) Rect() ui.Rect
Rect returns the rectangle of the parts.
Flutter: no counterpart
func (RRectParts) Write ¶
func (p RRectParts) Write(in *ShapeInstance, at int)
Write puts the parts in the instance at the float index at: center and half extents, then the radii of the four corners.
Flutter: no counterpart
type Renderer ¶
type Renderer interface {
// Attach starts drawing into a native surface. The first call creates the
// renderer's device.
Attach(SurfaceHandle) (Surface, error)
// Render draws the scene into the surface, at the given size in device pixels,
// and presents it. dpr is the device pixel ratio, which the scene's
// coordinates are already scaled by.
Render(s Surface, scene *ui.Scene, size ui.Size, dpr float32) error
// Snapshot draws the scene into a new image of the size, without a window:
// the work of Picture.ToImage and of the raster cache.
Snapshot(scene *ui.Scene, size ui.Size) (*image.RGBA, error)
// Close destroys every surface and the device.
Close() error
}
Renderer draws scenes. The GLES renderer (internal/gpu/gles) draws on the GPU; the software renderer (internal/gpu/soft) is the reference it is compared with. Only the UI thread calls a Renderer (SPEC §13).
Flutter: no counterpart (flutter::Rasterizer)
type ShadowPlan ¶
type ShadowPlan struct {
// AmbientSigma and SpotSigma are the deviations of the two blurs in pixels.
AmbientSigma, SpotSigma float64
// Spot is the transform of the path of the spot shadow: moved down and grown, away from a
// light above the shape.
Spot *ui.Matrix4
}
ShadowPlan is how Canvas.drawShadow's two blurred shadows are drawn.
Flutter: no counterpart
func PlanShadow ¶
func PlanShadow(elevation float64, m *ui.Matrix4, scale float64, devBounds image.Rectangle) (ShadowPlan, bool)
PlanShadow plans the shadow of a path of elevation, under the transform m with the scale (the square root of its determinant), when the path covers devBounds of the surface. false says that there is nothing to draw.
Flutter: no counterpart
type ShapeEncoder ¶
type ShapeEncoder struct {
// Transform maps the shape's coordinates to the surface's pixels, and T is its 2D part.
Transform *ui.Matrix4
T Affine2D
// Outer is the pixels the command's clip reaches, inside the target.
Outer image.Rectangle
// Clip is the clip rectangle, which the shader cuts to by exact coverage.
Clip [4]float32
// ClipBounds is the clip's bounds, which Fill covers.
ClipBounds ui.Rect
// Paint is the color and antialiasing for the instances.
Paint ShapePaint
// Emit is called with each finished instance and the pixels its quad covers.
Emit func(in *ShapeInstance, covers image.Rectangle)
}
ShapeEncoder turns the shapes of one drawing command into instances. The renderer fills in the command's state and Emit, which receives each instance with the pixels it covers; the methods return the name of a feature when the shape has no analytic form and the coverage atlas has to draw it, and "" otherwise (including when the shape draws nothing).
Flutter: no counterpart
func (*ShapeEncoder) DRRect ¶
DRRect draws the region between two rounded rectangles.
Flutter: no counterpart
func (*ShapeEncoder) Fill ¶
func (e *ShapeEncoder) Fill()
Fill paints the whole clip with the paint's color.
Flutter: no counterpart
func (*ShapeEncoder) Place ¶
func (e *ShapeEncoder) Place(in *ShapeInstance, local ui.Rect, kind, flags int, alpha float32)
Place finishes an instance: the placement of the quad around the local bounds, the inverse transform, the color and the clip. It hands the instance to Emit.
Flutter: no counterpart
func (*ShapeEncoder) PlacePadded ¶
func (e *ShapeEncoder) PlacePadded(in *ShapeInstance, local ui.Rect, kind, flags int, alpha float32, pad float64)
PlacePadded is Place with the quad grown by pad pixels around the shape's bounds.
Flutter: no counterpart
func (*ShapeEncoder) RRect ¶
RRect draws a rounded rectangle, filled or stroked.
Flutter: no counterpart
func (*ShapeEncoder) Scale ¶
func (e *ShapeEncoder) Scale() float64
Scale is the factor that lengths in the shape's units grow by.
Flutter: no counterpart
func (*ShapeEncoder) Segments ¶
func (e *ShapeEncoder) Segments(pts []ui.Offset, p *ui.Paint, line bool, mode ui.PointMode) (needsMask string)
Segments draws lines and points with the paint's width and cap. For a line, pts are its two ends.
Flutter: no counterpart
func (*ShapeEncoder) StrokeHalfWidth ¶
func (e *ShapeEncoder) StrokeHalfWidth(p *ui.Paint) (hw float64, alpha float32)
StrokeHalfWidth returns the half width of a stroke in the shape's units for a paint, and the factor to scale its alpha by: a stroke thinner than a pixel is drawn one pixel wide with less alpha, as Skia does; width 0 is a hairline, one full pixel.
Flutter: no counterpart
func (*ShapeEncoder) Superellipse ¶
func (e *ShapeEncoder) Superellipse(rs ui.RSuperellipse, p *ui.Paint) (needsMask string)
Superellipse draws a filled rounded superellipse.
Flutter: no counterpart
type ShapeInstance ¶
type ShapeInstance = [ShapeFloats]float32
ShapeInstance is the attributes of one shape, in the order of the shaders: the quad in pixels (0-3), the inverse transform (4-9), the kind and flags (10, 11), the premultiplied color (12-15), the clip rectangle (16-19), shape A (20-31), shape B (32-43), the parameters (44-47: half stroke width, cap, exponent, pixels per local unit).
Flutter: no counterpart
type ShapePaint ¶
type ShapePaint struct {
// Color is premultiplied; for a shader, its alpha in all four components.
Color [4]float32
// Antialias says whether the edge is smoothed.
Antialias bool
}
ShapePaint is what a paint gives the shape encoder.
Flutter: no counterpart
type Surface ¶
type Surface interface {
// Destroy releases the surface. It must be done before the native window is
// destroyed, and is safe to do twice.
Destroy()
}
Surface is a native drawing surface that a Renderer has attached to: the target that Render draws and presents into.
Flutter: no counterpart (flutter::Surface)
type SurfaceHandle ¶
type SurfaceHandle struct {
// Kind says how to read Display and Window.
Kind SurfaceKind
// Display is the native connection to the windowing system.
Display uintptr
// Window is the native window that EGL draws into: the wl_egl_window on Wayland.
Window uintptr
// Surface is the native surface that the explicit APIs (Vulkan) make their own
// surface from: the wl_surface on Wayland, the window ID again on X11.
Surface uintptr
}
SurfaceHandle identifies a native drawing surface. A platform backend creates it and only a GPU backend looks inside. Display, Window and Surface hold native addresses or IDs whose meaning depends on Kind; they are opaque to everyone else.
Flutter: no counterpart
type SurfaceKind ¶
type SurfaceKind string
SurfaceKind says which windowing system a SurfaceHandle belongs to, so that a GPU backend knows what Display and Window mean.
Flutter: no counterpart
const ( // SurfaceKindUnspecified is the zero value: no surface. // // Flutter: no counterpart SurfaceKindUnspecified SurfaceKind = "" // SurfaceKindWayland is a window of a Wayland compositor. Display is the // connection and Window the native window that the backend renders into. // // Flutter: no counterpart SurfaceKindWayland SurfaceKind = "wayland" // SurfaceKindX11 is a window of an X server. Display is the connection and // Window the window ID. // // Flutter: no counterpart SurfaceKindX11 SurfaceKind = "x11" // SurfaceKindWeb is the canvas of a web page. Window is the ID of the view, which // names the canvas (the attribute data-glutter-view); Display and Surface are zero. // // Flutter: no counterpart SurfaceKindWeb SurfaceKind = "web" // SurfaceKindFake is the surface of the scripted test platform. No GPU // backend renders into it. // // Flutter: no counterpart SurfaceKindFake SurfaceKind = "fake" )
The kinds of surface.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package canvas2d is the last renderer of the web (SPEC §9.6): it draws each frame with the software renderer (internal/gpu/soft) and puts the image into the page's 2D canvas with putImageData, so that an app shows even where neither WebGPU nor WebGL 2 works.
|
Package canvas2d is the last renderer of the web (SPEC §9.6): it draws each frame with the software renderer (internal/gpu/soft) and puts the image into the page's 2D canvas with putImageData, so that an app shows even where neither WebGPU nor WebGL 2 works. |
|
Package explicit is the renderer for the explicit GPU APIs, Vulkan and WebGPU (D19): the Device interface that both implement, the design limits they share (SPEC §9.3), and the WGSL shaders with the SPIR-V that glutter-gen makes from them (D20).
|
Package explicit is the renderer for the explicit GPU APIs, Vulkan and WebGPU (D19): the Device interface that both implement, the design limits they share (SPEC §9.3), and the WGSL shaders with the SPIR-V that glutter-gen makes from them (D20). |
|
fakedevice
Package fakedevice is an explicit.Device that records every call, for the unit tests of the explicit renderer without a GPU.
|
Package fakedevice is an explicit.Device that records every call, for the unit tests of the explicit renderer without a GPU. |
|
Package gles is the OpenGL ES 3.0 renderer.
|
Package gles is the OpenGL ES 3.0 renderer. |
|
glwebtest
command
Command glwebtest is the program of the browser tests of the WebGL 2 renderer (step 21.4, SPEC §9.1, §17).
|
Command glwebtest is the program of the browser tests of the WebGL 2 renderer (step 21.4, SPEC §9.1, §17). |
|
Package gputest has what the display tests of the GPU renderers share: the scenes the renderers are compared on, the comparison with the software renderer's image, and its tolerance.
|
Package gputest has what the display tests of the GPU renderers share: the scenes the renderers are compared on, the comparison with the software renderer's image, and its tolerance. |
|
Package soft is the pure-Go software rasterizer, used for golden tests and headless rendering.
|
Package soft is the pure-Go software rasterizer, used for golden tests and headless rendering. |
|
Package textdraw turns the drawing of a paragraph into ordinary drawing operations, for the renderers: each glyph is a path, drawn with its origin on a quarter of a pixel horizontally and on a pixel vertically, so that the coverage of a glyph at a size can be cached for the four subpixel positions (SPEC §9.1).
|
Package textdraw turns the drawing of a paragraph into ordinary drawing operations, for the renderers: each glyph is a path, drawn with its origin on a quarter of a pixel horizontally and on a pixel vertically, so that the coverage of a glyph at a size can be cached for the four subpixel positions (SPEC §9.1). |
|
Package vulkan is the Vulkan backend of the explicit renderer (SPEC §9.4): it loads libvulkan.so.1 through purego and implements explicit.Device on it.
|
Package vulkan is the Vulkan backend of the explicit renderer (SPEC §9.4): it loads libvulkan.so.1 through purego and implements explicit.Device on it. |
|
Package webgpu is the WebGPU backend of the explicit renderer (SPEC §9.5): an explicit.Device over navigator.gpu, through syscall/js, so that internal/gpu/explicit draws on the web the way it draws on Vulkan.
|
Package webgpu is the WebGPU backend of the explicit renderer (SPEC §9.5): an explicit.Device over navigator.gpu, through syscall/js, so that internal/gpu/explicit draws on the web the way it draws on Vulkan. |
|
gpuwebtest
command
Command gpuwebtest is the program of the browser tests of the WebGPU renderer (step 21.5, SPEC §9.5, §17).
|
Command gpuwebtest is the program of the browser tests of the WebGPU renderer (step 21.5, SPEC §9.5, §17). |