Unverified Commit 264082f3 authored by liyuqian's avatar liyuqian Committed by GitHub

Print clipBehavior while debugging ClipXXXLayer (#45716)

Fixes https://github.com/flutter/flutter/issues/45587
parent 5ccd4f34
...@@ -1294,6 +1294,7 @@ class ClipRectLayer extends ContainerLayer { ...@@ -1294,6 +1294,7 @@ class ClipRectLayer extends ContainerLayer {
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<Rect>('clipRect', clipRect)); properties.add(DiagnosticsProperty<Rect>('clipRect', clipRect));
properties.add(DiagnosticsProperty<Clip>('clipBehavior', clipBehavior));
} }
} }
...@@ -1374,6 +1375,7 @@ class ClipRRectLayer extends ContainerLayer { ...@@ -1374,6 +1375,7 @@ class ClipRRectLayer extends ContainerLayer {
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<RRect>('clipRRect', clipRRect)); properties.add(DiagnosticsProperty<RRect>('clipRRect', clipRRect));
properties.add(DiagnosticsProperty<Clip>('clipBehavior', clipBehavior));
} }
} }
...@@ -1449,6 +1451,12 @@ class ClipPathLayer extends ContainerLayer { ...@@ -1449,6 +1451,12 @@ class ClipPathLayer extends ContainerLayer {
if (enabled) if (enabled)
builder.pop(); builder.pop();
} }
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<Clip>('clipBehavior', clipBehavior));
}
} }
/// A composite layer that applies a [ColorFilter] to its children. /// A composite layer that applies a [ColorFilter] to its children.
......
...@@ -224,6 +224,38 @@ void main() { ...@@ -224,6 +224,38 @@ void main() {
expect(layer.debugSubtreeNeedsAddToScene, true); expect(layer.debugSubtreeNeedsAddToScene, true);
} }
List<String> _getDebugInfo(Layer layer) {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
layer.debugFillProperties(builder);
return builder.properties
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
.map((DiagnosticsNode node) => node.toString()).toList();
}
test('ClipRectLayer prints clipBehavior in debug info', () {
expect(_getDebugInfo(ClipRectLayer()), contains('clipBehavior: Clip.hardEdge'));
expect(
_getDebugInfo(ClipRectLayer(clipBehavior: Clip.antiAliasWithSaveLayer)),
contains('clipBehavior: Clip.antiAliasWithSaveLayer'),
);
});
test('ClipRRectLayer prints clipBehavior in debug info', () {
expect(_getDebugInfo(ClipRRectLayer()), contains('clipBehavior: Clip.antiAlias'));
expect(
_getDebugInfo(ClipRRectLayer(clipBehavior: Clip.antiAliasWithSaveLayer)),
contains('clipBehavior: Clip.antiAliasWithSaveLayer'),
);
});
test('ClipPathLayer prints clipBehavior in debug info', () {
expect(_getDebugInfo(ClipPathLayer()), contains('clipBehavior: Clip.antiAlias'));
expect(
_getDebugInfo(ClipPathLayer(clipBehavior: Clip.antiAliasWithSaveLayer)),
contains('clipBehavior: Clip.antiAliasWithSaveLayer'),
);
});
test('mutating PictureLayer fields triggers needsAddToScene', () { test('mutating PictureLayer fields triggers needsAddToScene', () {
final PictureLayer pictureLayer = PictureLayer(Rect.zero); final PictureLayer pictureLayer = PictureLayer(Rect.zero);
checkNeedsAddToScene(pictureLayer, () { checkNeedsAddToScene(pictureLayer, () {
......
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