From b0cd8b714629352638f17154cfc05ade03fff8f5 Mon Sep 17 00:00:00 2001 From: fmalita Date: Tue, 6 Oct 2015 07:24:03 -0700 Subject: [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 --- src/utils/debugger/SkDrawCommand.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/utils/debugger/SkDrawCommand.cpp') diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp index 20aad3b9a5..99c120bb7f 100644 --- a/src/utils/debugger/SkDrawCommand.cpp +++ b/src/utils/debugger/SkDrawCommand.cpp @@ -100,10 +100,13 @@ void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) { 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 @@ void render_path(SkCanvas* canvas, const SkPath& path) { p.setStyle(SkPaint::kStroke_Style); canvas->drawPath(path, p); - canvas->restore(); } void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRect = nullptr) { -- cgit v1.2.3