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 {
@override
_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 {
......
......@@ -143,6 +143,14 @@ class Slider extends StatefulWidget {
@override
_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 {
......
......@@ -85,6 +85,9 @@ int debugPaintPointersColorValue = _kDebugPaintPointersColorValue;
/// Overlay a rotating set of colors when repainting layers in checked mode.
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.
HSVColor debugCurrentRepaintColor = _kDebugCurrentRepaintColor;
......@@ -162,6 +165,7 @@ bool debugAssertAllRenderVarsUnset(String reason) {
debugPaintLayerBordersEnabled ||
debugPaintPointersEnabled ||
debugRepaintRainbowEnabled ||
debugRepaintTextRainbowEnabled ||
debugPrintMarkNeedsPaintStacks ||
debugPrintMarkNeedsLayoutStacks ||
debugCheckIntrinsicSizes ||
......
......@@ -2018,6 +2018,11 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
parent.markNeedsPaint();
assert(parent == this.parent);
} 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),
// then we have to paint ourselves, since nobody else can paint
// us. We don't add ourselves to _nodesNeedingPaint in this
......
......@@ -7,6 +7,7 @@ import 'dart:ui' as ui;
import 'package:flutter/gestures.dart';
import 'box.dart';
import 'debug.dart';
import 'object.dart';
import 'semantics.dart';
......@@ -252,6 +253,16 @@ class RenderParagraph extends RenderBox {
// works properly.
_layoutTextWithConstraints(constraints);
final Canvas canvas = context.canvas;
assert(() {
if (debugRepaintTextRainbowEnabled) {
Paint paint = new Paint()
..color = debugCurrentRepaintColor.toColor();
canvas.drawRect(offset & size, paint);
}
return true;
});
if (_hasVisualOverflow) {
final Rect bounds = offset & size;
if (_overflowShader != null)
......
......@@ -154,7 +154,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
ui.window.render(scene);
scene.dispose();
assert(() {
if (debugRepaintRainbowEnabled)
if (debugRepaintRainbowEnabled || debugRepaintTextRainbowEnabled)
debugCurrentRepaintColor = debugCurrentRepaintColor.withHue(debugCurrentRepaintColor.hue + debugRepaintRainbowHueIncrement);
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