Remove draw window size state from SkDebugCanvas

The SkDebugCanvas can be (or is currently) being used to draw to multiple
different canvases. If this use-case is intended, then storing draw
-related state in the canvas causes bugs.

Remove draw window size state form SkDebugCanvas. Instead, use the canvas
base layer size as the window size to clip to. This is consistent with
the current use in debugger.

This is part of work trying to remove bugs in debugger that result from
replaying one SkDrawCanvas to two different canvases. Currently the
SkDrawCanvas stores state that can only be valid if it is used for one
canvas.

Review URL: https://codereview.chromium.org/835113002
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index 77cf8a0..d770407 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -14,10 +14,9 @@
 #include "SkDevice.h"
 #include "SkXfermode.h"
 
-SkDebugCanvas::SkDebugCanvas(int windowWidth, int windowHeight)
-        : INHERITED(windowWidth, windowHeight)
+SkDebugCanvas::SkDebugCanvas(int width, int height)
+        : INHERITED(width, height)
         , fPicture(NULL)
-        , fWindowSize(SkISize::Make(windowWidth, windowHeight))
         , fFilter(false)
         , fMegaVizMode(false)
         , fIndex(0)
@@ -233,6 +232,8 @@
     SkASSERT(!fCommandVector.isEmpty());
     SkASSERT(index < fCommandVector.count());
     int i = 0;
+    SkRect windowRect = SkRect::MakeWH(SkIntToScalar(canvas->getBaseLayerSize().width()),
+                                       SkIntToScalar(canvas->getBaseLayerSize().height()));
 
     bool pathOpsMode = getAllowSimplifyClip();
     canvas->setAllowSimplifyClip(pathOpsMode);
@@ -249,9 +250,9 @@
         }
         canvas->clear(SK_ColorTRANSPARENT);
         canvas->resetMatrix();
-        SkRect rect = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth),
-                                     SkIntToScalar(fWindowSize.fHeight));
-        canvas->clipRect(rect, SkRegion::kReplace_Op);
+        if (!windowRect.isEmpty()) {
+            canvas->clipRect(windowRect, SkRegion::kReplace_Op);
+        }
         this->applyUserTransform(canvas);
         fDrawNeedsReset = false;
         fOutstandingSaveCount = 0;
@@ -307,16 +308,15 @@
     }
 
     if (fMegaVizMode) {
-        SkRect r = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth),
-                                  SkIntToScalar(fWindowSize.fHeight));
-        r.outset(SK_Scalar1, SK_Scalar1);
-
         canvas->save();
         // nuke the CTM
         canvas->resetMatrix();
         // turn off clipping
-        canvas->clipRect(r, SkRegion::kReplace_Op);
-
+        if (!windowRect.isEmpty()) {
+            SkRect r = windowRect;
+            r.outset(SK_Scalar1, SK_Scalar1);
+            canvas->clipRect(r, SkRegion::kReplace_Op);
+        }
         // visualize existing clips
         SkDebugClipVisitor visitor(canvas);