Better debugPaintSize logic for clip renderers (#11725)

diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart
index cb486b0..0351502 100644
--- a/packages/flutter/lib/src/rendering/proxy_box.dart
+++ b/packages/flutter/lib/src/rendering/proxy_box.dart
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-import 'dart:ui' as ui show ImageFilter;
+import 'dart:ui' as ui show ImageFilter, Gradient;
 
 import 'package:flutter/foundation.dart';
 import 'package:flutter/gestures.dart';
@@ -1014,6 +1014,35 @@
   Rect describeApproximatePaintClip(RenderObject child) {
     return _clipper?.getApproximateClipRect(size) ?? Offset.zero & size;
   }
+
+  Paint _debugPaint;
+  TextPainter _debugText;
+  @override
+  void debugPaintSize(PaintingContext context, Offset offset) {
+    assert(() {
+      _debugPaint ??= new Paint()
+        ..shader = new ui.Gradient.linear(
+          const Offset(0.0, 0.0),
+          const Offset(10.0, 10.0),
+          <Color>[const Color(0x00000000), const Color(0xFFFF00FF), const Color(0xFFFF00FF), const Color(0x00000000)],
+          <double>[0.25, 0.25, 0.75, 0.75],
+          TileMode.repeated,
+        )
+        ..strokeWidth = 2.0
+        ..style = PaintingStyle.stroke;
+      _debugText ??= new TextPainter(
+        text: const TextSpan(
+          text: '✂',
+          style: const TextStyle(
+            color: const Color(0xFFFF00FF),
+              fontSize: 14.0,
+            ),
+          ),
+        )
+        ..layout();
+      return true;
+    });
+  }
 }
 
 /// Clips its child using a rectangle.
@@ -1052,6 +1081,18 @@
       context.pushClipRect(needsCompositing, offset, _clip, super.paint);
     }
   }
+
+  @override
+  void debugPaintSize(PaintingContext context, Offset offset) {
+    assert(() {
+      if (child != null) {
+        super.debugPaintSize(context, offset);
+        context.canvas.drawRect(_clip.shift(offset), _debugPaint);
+        _debugText.paint(context.canvas, offset + new Offset(_clip.width / 8.0, -_debugText.text.style.fontSize * 1.1));
+      }
+      return true;
+    });
+  }
 }
 
 /// Clips its child using a rounded rectangle.
@@ -1111,6 +1152,18 @@
       context.pushClipRRect(needsCompositing, offset, _clip.outerRect, _clip, super.paint);
     }
   }
+
+  @override
+  void debugPaintSize(PaintingContext context, Offset offset) {
+    assert(() {
+      if (child != null) {
+        super.debugPaintSize(context, offset);
+        context.canvas.drawRRect(_clip.shift(offset), _debugPaint);
+        _debugText.paint(context.canvas, offset + new Offset(_clip.tlRadiusX, -_debugText.text.style.fontSize * 1.1));
+      }
+      return true;
+    });
+  }
 }
 
 /// Clips its child using an oval.
@@ -1163,6 +1216,18 @@
       context.pushClipPath(needsCompositing, offset, _clip, _getClipPath(_clip), super.paint);
     }
   }
+
+  @override
+  void debugPaintSize(PaintingContext context, Offset offset) {
+    assert(() {
+      if (child != null) {
+        super.debugPaintSize(context, offset);
+        context.canvas.drawPath(_getClipPath(_clip).shift(offset), _debugPaint);
+        _debugText.paint(context.canvas, offset + new Offset((_clip.width - _debugText.width) / 2.0, -_debugText.text.style.fontSize * 1.1));
+      }
+      return true;
+    });
+  }
 }
 
 /// Clips its child using a path.
@@ -1209,6 +1274,18 @@
       context.pushClipPath(needsCompositing, offset, Offset.zero & size, _clip, super.paint);
     }
   }
+
+  @override
+  void debugPaintSize(PaintingContext context, Offset offset) {
+    assert(() {
+      if (child != null) {
+        super.debugPaintSize(context, offset);
+        context.canvas.drawPath(_clip.shift(offset), _debugPaint);
+        _debugText.paint(context.canvas, offset);
+      }
+      return true;
+    });
+  }
 }
 
 /// Creates a physical model layer that clips its children to a rounded