aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/debugger/SkDebugCanvas.cpp
diff options
context:
space:
mode:
authorGravatar kkinnunen <kkinnunen@nvidia.com>2015-01-05 12:58:56 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-05 12:58:56 -0800
commit26e5400de4db969d32356a0b703261c1c98735f6 (patch)
tree4f647f2b159d61e2c4c91c581710cccfe8854563 /src/utils/debugger/SkDebugCanvas.cpp
parent8aa5b8f852c54706e8a9c3097fd1b6619e3f50db (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/SkDebugCanvas.cpp')
-rw-r--r--src/utils/debugger/SkDebugCanvas.cpp24
1 files changed, 12 insertions, 12 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);