提交 c95724cb 编写于 作者: A Adam Barth

Add debug painting for layer borders

This patch makes it easier to debug layerization issues.
上级 33ec74a4
......@@ -23,6 +23,9 @@ bool debugPaintBaselinesEnabled = false;
const sky.Color debugPaintAlphabeticBaselineColor = const sky.Color(0xFF00FF00);
const sky.Color debugPaintIdeographicBaselineColor = const sky.Color(0xFFFFD000);
bool debugPaintLayerBordersEnabled = false;
const sky.Color debugPaintLayerBordersColor = const sky.Color(0xFFFF9800);
bool debugPaintBoundsEnabled = false;
double timeDilation = 1.0;
......@@ -5,6 +5,7 @@
import 'dart:sky' as sky;
import 'dart:sky' show Point, Offset, Size, Rect, Color, Paint, Path;
import 'package:sky/base/debug.dart';
import 'package:vector_math/vector_math.dart';
abstract class Layer {
......@@ -36,9 +37,21 @@ class PictureLayer extends Layer {
Size size;
sky.Picture picture;
bool _debugPaintLayerBorder(sky.Canvas canvas) {
if (debugPaintLayerBordersEnabled) {
Paint border = new Paint()
..color = debugPaintLayerBordersColor
..strokeWidth = 2.0
..setStyle(sky.PaintingStyle.stroke);
canvas.drawRect(Point.origin & size, border);
}
return true;
}
void paint(sky.Canvas canvas) {
canvas.translate(offset.dx, offset.dy);
canvas.drawPicture(picture);
assert(_debugPaintLayerBorder(canvas));
canvas.translate(-offset.dx, -offset.dy);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册