Add override for debug warning highlights for non-performant views and commands.

Summary: Adds a flag that can be set in FlatViewGroup to see known performance issues in Nodes objects.  This is mostly useful in internal development of Nodes, and will be a dead code path when not set.

Reviewed By: ahmedre

Differential Revision: D3732675
This commit is contained in:
Seth Kirby
2016-08-17 18:13:27 -07:00
committed by Ahmed El-Helw
parent 4a12efad02
commit d601cc084b
5 changed files with 104 additions and 5 deletions

View File

@@ -201,7 +201,35 @@ import android.graphics.RectF;
}
@Override
public void debugDraw(FlatViewGroup parent, Canvas canvas) {
protected void onDebugDraw(FlatViewGroup parent, Canvas canvas) {
parent.debugDrawNextChild(canvas);
}
@Override
protected void onDebugDrawHighlight(Canvas canvas) {
if (mPath != null) {
debugDrawWarningHighlight(canvas, "borderRadius: " + mClipRadius);
} else if (!boundsMatch(mLogicalLeft, mLogicalTop, mLogicalRight, mLogicalBottom)) {
StringBuilder warn = new StringBuilder("Overflow: { ");
String[] names = { "left: ", "top: ", "right: ", "bottom: "};
int i = 0;
float[] offsets = new float[4];
offsets[i++] = getLeft() - mLogicalLeft;
offsets[i++] = getTop() - mLogicalTop;
offsets[i++] = mLogicalRight - getRight();
offsets[i++] = mLogicalBottom - getBottom();
for (i = 0; i < 4; i++) {
if (offsets[i] != 0f) {
warn.append(names[i]);
warn.append(offsets[i]);
warn.append(", ");
}
}
warn.append("}");
debugDrawCautionHighlight(canvas, warn.toString());
}
}
}