Unverified Commit 4f964196 authored by Dan Field's avatar Dan Field Committed by GitHub

Make _RenderCustomClip respect clipBehavior (#103748)

parent 8c4e92c6
......@@ -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;
......
......@@ -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> {
......
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