Commit 2a6b6ac1 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Add some debugging aids (#8108)

I've been using these locally, but they're likely to be useful to other people
as well.
parent c40b92b9
...@@ -111,6 +111,14 @@ class CupertinoSlider extends StatefulWidget { ...@@ -111,6 +111,14 @@ class CupertinoSlider extends StatefulWidget {
@override @override
_CupertinoSliderState createState() => new _CupertinoSliderState(); _CupertinoSliderState createState() => new _CupertinoSliderState();
@override
void debugFillDescription(List<String> description) {
super.debugFillDescription(description);
description.add('value: ${value.toStringAsFixed(1)}');
description.add('min: $min');
description.add('max: $max');
}
} }
class _CupertinoSliderState extends State<CupertinoSlider> with TickerProviderStateMixin { class _CupertinoSliderState extends State<CupertinoSlider> with TickerProviderStateMixin {
......
...@@ -143,6 +143,14 @@ class Slider extends StatefulWidget { ...@@ -143,6 +143,14 @@ class Slider extends StatefulWidget {
@override @override
_SliderState createState() => new _SliderState(); _SliderState createState() => new _SliderState();
@override
void debugFillDescription(List<String> description) {
super.debugFillDescription(description);
description.add('value: ${value.toStringAsFixed(1)}');
description.add('min: $min');
description.add('max: $max');
}
} }
class _SliderState extends State<Slider> with TickerProviderStateMixin { class _SliderState extends State<Slider> with TickerProviderStateMixin {
......
...@@ -85,6 +85,9 @@ int debugPaintPointersColorValue = _kDebugPaintPointersColorValue; ...@@ -85,6 +85,9 @@ int debugPaintPointersColorValue = _kDebugPaintPointersColorValue;
/// Overlay a rotating set of colors when repainting layers in checked mode. /// Overlay a rotating set of colors when repainting layers in checked mode.
bool debugRepaintRainbowEnabled = false; bool debugRepaintRainbowEnabled = false;
/// Overlay a rotating set of colors when repainting text in checked mode.
bool debugRepaintTextRainbowEnabled = false;
/// The current color to overlay when repainting a layer. /// The current color to overlay when repainting a layer.
HSVColor debugCurrentRepaintColor = _kDebugCurrentRepaintColor; HSVColor debugCurrentRepaintColor = _kDebugCurrentRepaintColor;
...@@ -162,6 +165,7 @@ bool debugAssertAllRenderVarsUnset(String reason) { ...@@ -162,6 +165,7 @@ bool debugAssertAllRenderVarsUnset(String reason) {
debugPaintLayerBordersEnabled || debugPaintLayerBordersEnabled ||
debugPaintPointersEnabled || debugPaintPointersEnabled ||
debugRepaintRainbowEnabled || debugRepaintRainbowEnabled ||
debugRepaintTextRainbowEnabled ||
debugPrintMarkNeedsPaintStacks || debugPrintMarkNeedsPaintStacks ||
debugPrintMarkNeedsLayoutStacks || debugPrintMarkNeedsLayoutStacks ||
debugCheckIntrinsicSizes || debugCheckIntrinsicSizes ||
......
...@@ -2018,6 +2018,11 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -2018,6 +2018,11 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
parent.markNeedsPaint(); parent.markNeedsPaint();
assert(parent == this.parent); assert(parent == this.parent);
} else { } else {
assert(() {
if (debugPrintMarkNeedsPaintStacks)
debugPrintStack(label: 'markNeedsPaint() called for $this (root of render tree)');
return true;
});
// If we're the root of the render tree (probably a RenderView), // If we're the root of the render tree (probably a RenderView),
// then we have to paint ourselves, since nobody else can paint // then we have to paint ourselves, since nobody else can paint
// us. We don't add ourselves to _nodesNeedingPaint in this // us. We don't add ourselves to _nodesNeedingPaint in this
......
...@@ -7,6 +7,7 @@ import 'dart:ui' as ui; ...@@ -7,6 +7,7 @@ import 'dart:ui' as ui;
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'box.dart'; import 'box.dart';
import 'debug.dart';
import 'object.dart'; import 'object.dart';
import 'semantics.dart'; import 'semantics.dart';
...@@ -252,6 +253,16 @@ class RenderParagraph extends RenderBox { ...@@ -252,6 +253,16 @@ class RenderParagraph extends RenderBox {
// works properly. // works properly.
_layoutTextWithConstraints(constraints); _layoutTextWithConstraints(constraints);
final Canvas canvas = context.canvas; final Canvas canvas = context.canvas;
assert(() {
if (debugRepaintTextRainbowEnabled) {
Paint paint = new Paint()
..color = debugCurrentRepaintColor.toColor();
canvas.drawRect(offset & size, paint);
}
return true;
});
if (_hasVisualOverflow) { if (_hasVisualOverflow) {
final Rect bounds = offset & size; final Rect bounds = offset & size;
if (_overflowShader != null) if (_overflowShader != null)
......
...@@ -154,7 +154,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> ...@@ -154,7 +154,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
ui.window.render(scene); ui.window.render(scene);
scene.dispose(); scene.dispose();
assert(() { assert(() {
if (debugRepaintRainbowEnabled) if (debugRepaintRainbowEnabled || debugRepaintTextRainbowEnabled)
debugCurrentRepaintColor = debugCurrentRepaintColor.withHue(debugCurrentRepaintColor.hue + debugRepaintRainbowHueIncrement); debugCurrentRepaintColor = debugCurrentRepaintColor.withHue(debugCurrentRepaintColor.hue + debugRepaintRainbowHueIncrement);
return true; return 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