FakeBackend constructor

FakeBackend({
  1. Set<String> missingShaders = const <String>{},
  2. bool supportsWireframe = true,
  3. bool supportsAlphaToCoverage = true,
  4. bool supportsStencil = true,
  5. bool supportsRenderToMip = true,
  6. Set<TextureFormat> unsupportedFormats = const <TextureFormat>{},
  7. int maxAnisotropy = 16,
  8. int maxColorAttachments = 2,
  9. Map<String, StageBindings>? stageBindings,
  10. FramebufferOrigin framebufferOrigin = FramebufferOrigin.topLeft,
  11. Iterable<DeviceFeature> extraFeatures = const <DeviceFeature>[],
  12. Set<String> refusingPipelines = const <String>{},
  13. int? refusedBuilds,
  14. bool compute = false,
})

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,
  bool compute = false,
}) : assert(
       !extraFeatures.contains(DeviceFeature.compute),
       'compute is the constructor\'s compute: true, which records it',
     ),
     _compute = compute,
     shaders = FakeShaderLibrary(
       missing: missingShaders,
       stageBindings: stageBindings,
     ),
     limits = compute
         ? DeviceLimits(
             maxSamplerAnisotropy: maxAnisotropy,
             maxColorAttachments: maxColorAttachments,
           )
         : 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,
       DeviceFeature.blendConstantAlpha,
       // What every drawing backend in the repository lists since
       // 1.0.0-rc.1, so a caller under test can name them and be
       // recorded doing it.
       DeviceFeature.primitiveStrips,
       DeviceFeature.pointPrimitives,
       DeviceFeature.indexUint32,
       // Recorded, as the blend constant's alpha pair is: three of the
       // four drawing backends have a mask pair per face and clear an
       // integer target exactly.
       DeviceFeature.separateStencilMasks,
       DeviceFeature.exactIntegerClear,
       // 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,
       if (compute) ...<DeviceFeature>[
         DeviceFeature.compute,
         DeviceFeature.buffers,
         DeviceFeature.renderStageStorage,
       ],
       ...extraFeatures,
     });