diff --git a/packages/flutter/lib/src/rendering/layer.dart b/packages/flutter/lib/src/rendering/layer.dart index 2a4785257a..8ad458116e 100644 --- a/packages/flutter/lib/src/rendering/layer.dart +++ b/packages/flutter/lib/src/rendering/layer.dart @@ -2178,152 +2178,6 @@ class BackdropFilterLayer extends ContainerLayer { } } -/// A composited layer that uses a physical model to producing lighting effects. -/// -/// For example, the layer casts a shadow according to its geometry and the -/// relative position of lights and other physically modeled objects in the -/// scene. -/// -/// When debugging, setting [debugDisablePhysicalShapeLayers] to true will cause this -/// layer to be skipped (directly replaced by its children). This can be helpful -/// to track down the cause of performance problems. -@Deprecated( - 'Use a clip and canvas operations directly (See RenderPhysicalModel). ' - 'This feature was deprecated after v2.13.0-0.0.pre.', -) -class PhysicalModelLayer extends ContainerLayer { - /// Creates a composited layer that uses a physical model to producing - /// lighting effects. - /// - /// The [clipPath], [clipBehavior], [elevation], [color], and [shadowColor] - /// arguments must be non-null before the compositing phase of the pipeline. - @Deprecated( - 'Use a clip and canvas operations directly (See RenderPhysicalModel). ' - 'This feature was deprecated after v2.13.0-0.0.pre.', - ) - PhysicalModelLayer({ - Path? clipPath, - Clip clipBehavior = Clip.none, - double? elevation, - Color? color, - Color? shadowColor, - }) : _clipPath = clipPath, - _clipBehavior = clipBehavior, - _elevation = elevation, - _color = color, - _shadowColor = shadowColor; - - /// The path to clip in the parent's coordinate system. - /// - /// The scene must be explicitly recomposited after this property is changed - /// (as described at [Layer]). - Path? get clipPath => _clipPath; - Path? _clipPath; - set clipPath(Path? value) { - if (value != _clipPath) { - _clipPath = value; - markNeedsAddToScene(); - } - } - - /// {@macro flutter.material.Material.clipBehavior} - Clip get clipBehavior => _clipBehavior; - Clip _clipBehavior; - set clipBehavior(Clip value) { - if (value != _clipBehavior) { - _clipBehavior = value; - markNeedsAddToScene(); - } - } - - /// The z-coordinate at which to place this physical object. - /// - /// The scene must be explicitly recomposited after this property is changed - /// (as described at [Layer]). - /// - /// In tests, the [debugDisableShadows] flag is set to true by default. - /// Several widgets and render objects force all elevations to zero when this - /// flag is set. For this reason, this property will often be set to zero in - /// tests even if the layer should be raised. To verify the actual value, - /// consider setting [debugDisableShadows] to false in your test. - double? get elevation => _elevation; - double? _elevation; - set elevation(double? value) { - if (value != _elevation) { - _elevation = value; - markNeedsAddToScene(); - } - } - - /// The background color. - /// - /// The scene must be explicitly recomposited after this property is changed - /// (as described at [Layer]). - Color? get color => _color; - Color? _color; - set color(Color? value) { - if (value != _color) { - _color = value; - markNeedsAddToScene(); - } - } - - /// The shadow color. - Color? get shadowColor => _shadowColor; - Color? _shadowColor; - set shadowColor(Color? value) { - if (value != _shadowColor) { - _shadowColor = value; - markNeedsAddToScene(); - } - } - - @override - bool findAnnotations(AnnotationResult result, Offset localPosition, { required bool onlyFirst }) { - if (!clipPath!.contains(localPosition)) { - return false; - } - return super.findAnnotations(result, localPosition, onlyFirst: onlyFirst); - } - - @override - void addToScene(ui.SceneBuilder builder) { - assert(clipPath != null); - assert(elevation != null); - assert(color != null); - assert(shadowColor != null); - - bool enabled = true; - assert(() { - enabled = !debugDisablePhysicalShapeLayers; - return true; - }()); - if (enabled) { - engineLayer = builder.pushPhysicalShape( - path: clipPath!, - elevation: elevation!, - color: color!, - shadowColor: shadowColor, - clipBehavior: clipBehavior, - oldLayer: _engineLayer as ui.PhysicalShapeEngineLayer?, - ); - } else { - engineLayer = null; - } - addChildrenToScene(builder); - if (enabled) { - builder.pop(); - } - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties.add(DoubleProperty('elevation', elevation)); - properties.add(ColorProperty('color', color)); - } -} - /// An object that a [LeaderLayer] can register with. /// /// An instance of this class should be provided as the [LeaderLayer.link] and diff --git a/packages/flutter/test/rendering/layer_annotations_test.dart b/packages/flutter/test/rendering/layer_annotations_test.dart index e7584f2ec5..fb3a69959a 100644 --- a/packages/flutter/test/rendering/layer_annotations_test.dart +++ b/packages/flutter/test/rendering/layer_annotations_test.dart @@ -434,56 +434,6 @@ void main() { ); }); - test('PhysicalModelLayer.findAllAnnotations respects clipPath', () { - // For this triangle, location (1, 1) is inside, while (2, 2) is outside. - // 2 - // ————— - // | / - // | / - // 2 |/ - final Path originalPath = Path(); - originalPath.lineTo(2, 0); - originalPath.lineTo(0, 2); - originalPath.close(); - // Shift this clip path by (10, 10). - final Path path = originalPath.shift(const Offset(10, 10)); - const Offset insidePosition = Offset(11, 11); - const Offset outsidePosition = Offset(12, 12); - - final Layer root = _withBackgroundAnnotation( - 1000, - _Layers( - PhysicalModelLayer( - clipPath: path, - elevation: 10, - color: const Color.fromARGB(0, 0, 0, 0), - shadowColor: const Color.fromARGB(0, 0, 0, 0), - ), - children: [ - _TestAnnotatedLayer( - 1, - opaque: true, - size: const Size(10, 10), - offset: const Offset(10, 10), - ), - ], - ).build(), - ); - - expect( - root.findAllAnnotations(insidePosition).entries.toList(), - _equalToAnnotationResult(>[ - const AnnotationEntry(annotation: 1, localPosition: insidePosition), - ]), - ); - expect( - root.findAllAnnotations(outsidePosition).entries.toList(), - _equalToAnnotationResult(>[ - const AnnotationEntry(annotation: 1000, localPosition: outsidePosition), - ]), - ); - }); - test('LeaderLayer.findAllAnnotations respects offset', () { const Offset insidePosition = Offset(-5, 5); const Offset outsidePosition = Offset(5, 5); diff --git a/packages/flutter/test/rendering/layers_test.dart b/packages/flutter/test/rendering/layers_test.dart index b4904a47b7..cc95ace405 100644 --- a/packages/flutter/test/rendering/layers_test.dart +++ b/packages/flutter/test/rendering/layers_test.dart @@ -512,29 +512,6 @@ void main() { }); }); - test('mutating PhysicalModelLayer fields triggers needsAddToScene', () { - final PhysicalModelLayer layer = PhysicalModelLayer( - clipPath: Path(), - elevation: 0, - color: const Color(0x00000000), - shadowColor: const Color(0x00000000), - ); - checkNeedsAddToScene(layer, () { - final Path newPath = Path(); - newPath.addRect(unitRect); - layer.clipPath = newPath; - }); - checkNeedsAddToScene(layer, () { - layer.elevation = 1; - }); - checkNeedsAddToScene(layer, () { - layer.color = const Color(0x00000001); - }); - checkNeedsAddToScene(layer, () { - layer.shadowColor = const Color(0x00000001); - }); - }); - test('ContainerLayer.toImage can render interior layer', () { final OffsetLayer parent = OffsetLayer(); final OffsetLayer child = OffsetLayer(); @@ -1007,7 +984,6 @@ void main() { final ClipRRectLayer clipRRectLayer = ClipRRectLayer(); final ImageFilterLayer imageFilterLayer = ImageFilterLayer(); final BackdropFilterLayer backdropFilterLayer = BackdropFilterLayer(); - final PhysicalModelLayer physicalModelLayer = PhysicalModelLayer(); final ColorFilterLayer colorFilterLayer = ColorFilterLayer(); final ShaderMaskLayer shaderMaskLayer = ShaderMaskLayer(); final TextureLayer textureLayer = TextureLayer(rect: Rect.zero, textureId: 1); @@ -1017,7 +993,6 @@ void main() { expect(clipRRectLayer.supportsRasterization(), true); expect(imageFilterLayer.supportsRasterization(), true); expect(backdropFilterLayer.supportsRasterization(), true); - expect(physicalModelLayer.supportsRasterization(), true); expect(colorFilterLayer.supportsRasterization(), true); expect(shaderMaskLayer.supportsRasterization(), true); expect(textureLayer.supportsRasterization(), true);