Unverified Commit 12b3023e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[framework] delete physical model layer. (#125719)

Engine PR: https://github.com/flutter/engine/pull/41593

This must land first

We should remove these, as they've been deprecated for a while. On the engine side of things, the physical model layer is the only one which requires the device pixel ratio, so deleting it will allow us to simplify the layer tree code in https://github.com/flutter/engine/pull/41559
parent e51b6167
...@@ -2178,152 +2178,6 @@ class BackdropFilterLayer extends ContainerLayer { ...@@ -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<S extends Object>(AnnotationResult<S> result, Offset localPosition, { required bool onlyFirst }) {
if (!clipPath!.contains(localPosition)) {
return false;
}
return super.findAnnotations<S>(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 object that a [LeaderLayer] can register with.
/// ///
/// An instance of this class should be provided as the [LeaderLayer.link] and /// An instance of this class should be provided as the [LeaderLayer.link] and
......
...@@ -434,56 +434,6 @@ void main() { ...@@ -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: <Object>[
_TestAnnotatedLayer(
1,
opaque: true,
size: const Size(10, 10),
offset: const Offset(10, 10),
),
],
).build(),
);
expect(
root.findAllAnnotations<int>(insidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1, localPosition: insidePosition),
]),
);
expect(
root.findAllAnnotations<int>(outsidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition),
]),
);
});
test('LeaderLayer.findAllAnnotations respects offset', () { test('LeaderLayer.findAllAnnotations respects offset', () {
const Offset insidePosition = Offset(-5, 5); const Offset insidePosition = Offset(-5, 5);
const Offset outsidePosition = Offset(5, 5); const Offset outsidePosition = Offset(5, 5);
......
...@@ -512,29 +512,6 @@ void main() { ...@@ -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', () { test('ContainerLayer.toImage can render interior layer', () {
final OffsetLayer parent = OffsetLayer(); final OffsetLayer parent = OffsetLayer();
final OffsetLayer child = OffsetLayer(); final OffsetLayer child = OffsetLayer();
...@@ -1007,7 +984,6 @@ void main() { ...@@ -1007,7 +984,6 @@ void main() {
final ClipRRectLayer clipRRectLayer = ClipRRectLayer(); final ClipRRectLayer clipRRectLayer = ClipRRectLayer();
final ImageFilterLayer imageFilterLayer = ImageFilterLayer(); final ImageFilterLayer imageFilterLayer = ImageFilterLayer();
final BackdropFilterLayer backdropFilterLayer = BackdropFilterLayer(); final BackdropFilterLayer backdropFilterLayer = BackdropFilterLayer();
final PhysicalModelLayer physicalModelLayer = PhysicalModelLayer();
final ColorFilterLayer colorFilterLayer = ColorFilterLayer(); final ColorFilterLayer colorFilterLayer = ColorFilterLayer();
final ShaderMaskLayer shaderMaskLayer = ShaderMaskLayer(); final ShaderMaskLayer shaderMaskLayer = ShaderMaskLayer();
final TextureLayer textureLayer = TextureLayer(rect: Rect.zero, textureId: 1); final TextureLayer textureLayer = TextureLayer(rect: Rect.zero, textureId: 1);
...@@ -1017,7 +993,6 @@ void main() { ...@@ -1017,7 +993,6 @@ void main() {
expect(clipRRectLayer.supportsRasterization(), true); expect(clipRRectLayer.supportsRasterization(), true);
expect(imageFilterLayer.supportsRasterization(), true); expect(imageFilterLayer.supportsRasterization(), true);
expect(backdropFilterLayer.supportsRasterization(), true); expect(backdropFilterLayer.supportsRasterization(), true);
expect(physicalModelLayer.supportsRasterization(), true);
expect(colorFilterLayer.supportsRasterization(), true); expect(colorFilterLayer.supportsRasterization(), true);
expect(shaderMaskLayer.supportsRasterization(), true); expect(shaderMaskLayer.supportsRasterization(), true);
expect(textureLayer.supportsRasterization(), true); expect(textureLayer.supportsRasterization(), true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment