FakeBackend class final

A device that records rather than draws.

Implemented types

Constructors

FakeBackend({Set<String> missingShaders = const <String>{}, bool supportsWireframe = true, bool supportsStencil = true, bool supportsRenderToMip = true, Set<TextureFormat> unsupportedFormats = const <TextureFormat>{}, int maxAnisotropy = 16})

Properties

answerReadback ByteData Function(TextureHandle texture, ScreenRect region)?
What a readback answers, or null for a region of zeros.
getter/setter pair
completesImmediately bool
Whether onFrameComplete runs its callback at once.
getter/setter pair
createdCubeRenderTargets List<({TextureFormat format, int mipLevels, int size})>
Every cube a pass may draw into, with the level count it was asked for, so a test can see that a probe allocated what it meant to.
final
createdTextures List<RenderTargetSpec>
final
defaultColorFormat TextureFormat
The colour format this device prefers.
no setteroverride
defaultDepthStencilFormat TextureFormat
The depth/stencil format this device prefers. Legitimately TextureFormat.unknown on a context that has none.
no setteroverride
depthRange DepthRange
What this backend's clip space maps depth onto.
no setteroverride
disposed bool
Whether dispose has been called, for a test that wants to assert a device was actually torn down rather than merely dropped.
getter/setter pair
framebufferOrigin FramebufferOrigin
The engine's own convention, so a fake never exercises the remap. The backends that need the other one are covered by running them.
no setteroverride
frames int
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hdrColorFormat TextureFormat
The format to render high dynamic range colour into.
no setteroverride
linkedPipelines List<String>
Every pair linked so far, by name and in order, so a test can tell whether a frame linked anything — a renderer that relinked drops every pipeline it held and links each one again, and one it forgot to drop shows up here as a link that did not happen.
final
loadedLibraries List<FakeLoadedShaderLibrary>
Every library loadShaders has handed out, in order, so a test can reach the one an application holds and count its refreshes.
final
maxAnisotropy int
Sixteen, which is what most hardware answers, and settable so a test can be the device that answers one and see what a caller clamps to.
final
passes List<FakePass>
Every pass ever opened, in the order it was opened.
final
pendingFrames List<void Function()>
Frames whose work the GPU has not "finished".
final
preferredSampleCount int
Samples to use for multisampled targets, or 1 for none.
no setteroverride
readbacks List<({ScreenRect region, TextureHandle texture})>
Every readback asked for, in order: which texture and which region.
final
releasedGeometry List<GeometryBuffer>
final
releasedTextures List<TextureHandle>
What was handed back one at a time, in the order it was handed back.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shaders FakeShaderLibrary
The compiled bundle this device was built with.
final
supportsBlendColor bool
Whether PassEncoder.setBlendColor reaches the hardware.
no setteroverride
supportsCubeTextures bool
Whether a cube texture can be created and sampled.
no setteroverride
supportsMipmaps bool
True, because a fake has nothing to be incapable with. The real answer is a device property, and the two backends that have one disagree.
no setteroverride
supportsOffscreenMsaa bool
Whether a multisampled offscreen target is available at all.
no setteroverride
supportsRenderToMip bool
Settable for the same reason supportsWireframe is: the interesting case is the backend that says no — flutter_gpu on OpenGL ES — and the renderer is supposed to build a probe without a chain there rather than name a level the device will refuse.
final
supportsStencil bool
Settable for the same reason supportsWireframe is: the case worth a test is the device that says no, where the x-ray stage has to draw nothing rather than configure a test against an attachment with no stencil in it.
final
supportsWireframe bool
Settable, because the interesting case is the backend that says no — OpenGL ES has no glPolygonMode, and the engine is supposed to decline its own wireframe setting rather than let the request reach a backend that would refuse it mid-frame.
final
unsupportedFormats Set<TextureFormat>
The formats this fake says it cannot sample, so a test can be the device that has no BC7 and see what a loader does about it.
final
uploadedMipLevels List<List<ByteData>?>
The chain each of those came with — null for an upload that brought none — so a test can tell a base level from a base level and its mips.
final
uploadedPixels List<ByteData>
The bytes of each of those, for a test that cares what colour it was.
final
uploadedTextures List<RenderTargetSpec>
Pixel uploads, in order, so a test can assert what reached the device.
final
uploads List<GeometryUsage>
Recorded with its usage, because a backend exists that cannot change its mind about one later.
final

Methods

beginFrame() → void
Tells the backend a new frame is starting.
override
beginRenderPass(RenderPassDescriptor descriptor) CommandEncoder
Opens a pass and returns the encoder that records into it.
override
createCubeRenderTarget({required int size, required TextureFormat format, int mipLevels = 1}) TextureHandle?
Allocates a cube texture a pass can draw into, face by face and level by level, with nothing in it yet.
override
createCubeTextureFromPixels({required int size, required TextureFormat format, required List<ByteData> faces, List<List<ByteData>>? mipLevels}) TextureHandle?
Uploads six square images as one cube texture.
override
createPipeline(ShaderHandle vertex, ShaderHandle fragment, {VertexLayoutSpec? layout}) PipelineHandle
Links two stages into something that can be bound.
override
createTexture(RenderTargetSpec spec) TextureHandle
A brand-new texture matching spec, with the single TextureHandle that will ever stand for it.
override
createTextureFromPixels({required int width, required int height, required TextureFormat format, required ByteData pixels, List<ByteData>? mipLevels}) TextureHandle?
Creates a texture already holding pixels.
override
dispose() → void
Releases every persistent resource this device holds — the textures and geometry buffers handed out by createTexture, createTextureFromPixels, createCubeTextureFromPixels, createCubeRenderTarget and uploadGeometry.
override
finishOldestFrame() → void
Lets the oldest unfinished frame complete.
loadShaders(ByteData bytes) Future<LoadedShaderLibrary>
Decodes the bundle — so bytes that are not one are refused the way every real backend refuses them — and answers its names. No section is read: a fake compiles nothing, which is also the software rasteriser's answer.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFrameComplete(void whenDone()) → void
Runs whenDone once the GPU has finished with the frame being encoded now.
override
present(TextureHandle frame, {BoxFit fit = BoxFit.fill, FilterQuality quality = FilterQuality.none}) Widget
Nothing was drawn, so there is nothing to show, and pretending otherwise would be worse than refusing: a test handed a blank widget could assert something about a frame that never existed. Nothing under test here reaches this — only an application does, once per frame.
override
readback(TextureHandle texture, {ScreenRect? region}) Future<ByteData>
Refuses what the contract refuses, records the rest, and answers zeros unless answerReadback says otherwise.
override
readPixels(TextureHandle texture) Future<ByteData?>
Null, which is a legitimate answer rather than a refusal: it is what a real device says about a texture whose pixels cannot be read.
override
releaseGeometry(GeometryBuffer geometry) → void
Releases one geometry buffer, rather than waiting for the whole device to go.
override
releaseTexture(TextureHandle texture) → void
Gives one back, rather than waiting for the whole device to go.
override
supportsTextureFormat(TextureFormat format) bool
Whether a texture uploaded in format can be created and sampled here.
override
toString() String
A string representation of this object.
inherited
uploadGeometry(ByteData bytes, GeometryUsage usage) GeometryBuffer
Uploads geometry that will outlive the frame.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited