FakeBackend constructor
FakeBackend({
- Set<
String> missingShaders = const <String>{}, - bool supportsWireframe = true,
- bool supportsAlphaToCoverage = true,
- bool supportsStencil = true,
- bool supportsRenderToMip = true,
- Set<
TextureFormat> unsupportedFormats = const <TextureFormat>{}, - int maxAnisotropy = 16,
- int maxColorAttachments = 2,
- Map<
String, StageBindings> ? stageBindings, - FramebufferOrigin framebufferOrigin = FramebufferOrigin.topLeft,
- Iterable<
DeviceFeature> extraFeatures = const <DeviceFeature>[], - Set<
String> refusingPipelines = const <String>{}, - int? refusedBuilds,
maxAnisotropy and maxColorAttachments become limits; the flags and
extraFeatures become features. See the class doc for what a feature
named in extraFeatures does on a fake.
Implementation
FakeBackend({
Set<String> missingShaders = const <String>{},
bool supportsWireframe = true,
bool supportsAlphaToCoverage = true,
bool supportsStencil = true,
bool supportsRenderToMip = true,
this.unsupportedFormats = const <TextureFormat>{},
int maxAnisotropy = 16,
int maxColorAttachments = 2,
this.stageBindings,
this.framebufferOrigin = FramebufferOrigin.topLeft,
Iterable<DeviceFeature> extraFeatures = const <DeviceFeature>[],
this.refusingPipelines = const <String>{},
this.refusedBuilds,
}) : assert(
!extraFeatures.contains(DeviceFeature.compute),
'a fake runs no compute stage, so it cannot report compute',
),
shaders = FakeShaderLibrary(
missing: missingShaders,
stageBindings: stageBindings,
),
limits = DeviceLimits(
maxSamplerAnisotropy: maxAnisotropy,
maxColorAttachments: maxColorAttachments,
maxComputeWorkgroupStorageSize: 0,
maxComputeInvocationsPerWorkgroup: 0,
maxComputeWorkgroupSizeX: 0,
maxComputeWorkgroupSizeY: 0,
maxComputeWorkgroupSizeZ: 0,
maxComputeWorkgroupsPerDimension: 0,
),
_features = DeviceFeatures(<DeviceFeature>{
DeviceFeature.offscreenMultisample,
// Recorded, not evaluated: this device blends nothing, so the honest
// answer is the one that lets a caller under test set the constant
// and be recorded doing it.
DeviceFeature.blendConstant,
// True, because a fake has nothing to be incapable with. The real
// answer is a device property, and the backends disagree.
DeviceFeature.manualMipmaps,
DeviceFeature.cubeTextures,
// Settable for the same reason as wireframe: 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.
if (supportsRenderToMip) DeviceFeature.renderToMipLevel,
// 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.
if (supportsWireframe) DeviceFeature.wireframe,
// Settable: two of the four real backends say no, and the engine is
// meant to draw the hard alpha test there and report it.
if (supportsAlphaToCoverage) DeviceFeature.alphaToCoverage,
// Settable: 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.
if (supportsStencil) DeviceFeature.stencil,
...extraFeatures,
});