diff options
author | kkinnunen <kkinnunen@nvidia.com> | 2015-01-05 12:58:56 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-05 12:58:56 -0800 |
commit | 26e5400de4db969d32356a0b703261c1c98735f6 (patch) | |
tree | 4f647f2b159d61e2c4c91c581710cccfe8854563 /src/utils/debugger | |
parent | 8aa5b8f852c54706e8a9c3097fd1b6619e3f50db (diff) |
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
Diffstat (limited to 'src/utils/debugger')
-rw-r--r-- | src/utils/debugger/SkDebugCanvas.cpp | 24 | ||||
-rw-r--r-- | src/utils/debugger/SkDebugCanvas.h | 3 |
2 files changed, 12 insertions, 15 deletions
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp index 77cf8a027b..d7704071d7 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 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) { 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 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) { } 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 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) { } 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); diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h index d74d30d24d..4acf8322b9 100644 --- a/src/utils/debugger/SkDebugCanvas.h +++ b/src/utils/debugger/SkDebugCanvas.h @@ -135,8 +135,6 @@ public: */ void toggleCommand(int index, bool toggle); - void setWindowSize(int width, int height) { fWindowSize.set(width, height); } - void setUserMatrix(SkMatrix matrix) { fUserMatrix = matrix; fDrawNeedsReset = true; @@ -225,7 +223,6 @@ protected: private: SkTDArray<SkDrawCommand*> fCommandVector; SkPicture* fPicture; - SkISize fWindowSize; bool fFilter; bool fMegaVizMode; int fIndex; |