Make _RenderCustomClip respect clipBehavior (#103748)

This commit is contained in:
Dan Field
2022-05-13 17:14:07 -07:00
committed by GitHub
parent 8c4e92c694
commit 4f96419612
2 changed files with 34 additions and 2 deletions

View File

@@ -1404,8 +1404,15 @@ abstract class _RenderCustomClip<T> extends RenderProxyBox {
}
@override
Rect describeApproximatePaintClip(RenderObject child) {
return _clipper?.getApproximateClipRect(size) ?? Offset.zero & size;
Rect? describeApproximatePaintClip(RenderObject child) {
switch (clipBehavior) {
case Clip.none:
return null;
case Clip.hardEdge:
case Clip.antiAlias:
case Clip.antiAliasWithSaveLayer:
return _clipper?.getApproximateClipRect(size) ?? Offset.zero & size;
}
}
Paint? _debugPaint;

View File

@@ -686,6 +686,31 @@ void main() {
expect(() => pumpFrame(phase: EnginePhase.composite), returnsNormally);
});
test('RenderCustomClip extenders respect clipBehavior when asked to describeApproximateClip', () {
final RenderBox child = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 200, height: 200));
final RenderClipRect renderClipRect = RenderClipRect(clipBehavior: Clip.none, child: child);
layout(renderClipRect);
expect(
renderClipRect.describeApproximatePaintClip(child),
null,
);
renderClipRect.clipBehavior = Clip.hardEdge;
expect(
renderClipRect.describeApproximatePaintClip(child),
Offset.zero & renderClipRect.size,
);
renderClipRect.clipBehavior = Clip.antiAlias;
expect(
renderClipRect.describeApproximatePaintClip(child),
Offset.zero & renderClipRect.size,
);
renderClipRect.clipBehavior = Clip.antiAliasWithSaveLayer;
expect(
renderClipRect.describeApproximatePaintClip(child),
Offset.zero & renderClipRect.size,
);
});
}
class _TestRectClipper extends CustomClipper<Rect> {