[SkDebugger] Handle path empty-bounds gracefully
Paths with empty bounds crash the debugger: mapping their bounds onto
the shapshot area gets the canvas into an unhappy state.
R=robertphillips@google.com
Review URL: https://codereview.chromium.org/1387173003
diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp
index 20aad3b..99c120b 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -100,10 +100,13 @@
void render_path(SkCanvas* canvas, const SkPath& path) {
canvas->clear(0xFFFFFFFF);
- canvas->save();
const SkRect& bounds = path.getBounds();
+ if (bounds.isEmpty()) {
+ return;
+ }
+ SkAutoCanvasRestore acr(canvas, true);
xlate_and_scale_to_bounds(canvas, bounds);
SkPaint p;
@@ -111,7 +114,6 @@
p.setStyle(SkPaint::kStroke_Style);
canvas->drawPath(path, p);
- canvas->restore();
}
void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRect = nullptr) {