"Fix" debugger's setMatrix handling
This remedies two problems with the debugger's matrix handling:
1) the user matrix was not being passed to the setMatrix command (for a concat)
2) the setting of the user matrix was not consistently forcing a complete re-rendering of the scene
BUG=skia:3018
Review URL: https://codereview.chromium.org/660883002
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index 85fb7a4..684c5cd 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -27,6 +27,7 @@
, fTexOverrideFilter(NULL)
, fOutstandingSaveCount(0) {
fUserMatrix.reset();
+ fDrawNeedsReset = false;
// SkPicturePlayback uses the base-class' quickReject calls to cull clipped
// operations. This can lead to problems in the debugger which expects all
@@ -81,6 +82,7 @@
SkColor prev = bitmap.getColor(0,0);
for (int i = 0; i < index; i++) {
if (fCommandVector[i]->isVisible()) {
+ fCommandVector[i]->setUserMatrix(fUserMatrix);
fCommandVector[i]->execute(&canvas);
}
if (prev != bitmap.getColor(0,0)) {
@@ -246,7 +248,7 @@
// and restores.
// The visibility filter also requires a full re-draw - otherwise we can
// end up drawing the filter repeatedly.
- if (fIndex < index && !fFilter && !fMegaVizMode && !pathOpsMode) {
+ if (fIndex < index && !fFilter && !fMegaVizMode && !pathOpsMode && !fDrawNeedsReset) {
i = fIndex + 1;
} else {
for (int j = 0; j < fOutstandingSaveCount; j++) {
@@ -254,10 +256,11 @@
}
canvas->clear(SK_ColorTRANSPARENT);
canvas->resetMatrix();
- SkRect rect = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth),
+ SkRect rect = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth),
SkIntToScalar(fWindowSize.fHeight));
canvas->clipRect(rect, SkRegion::kReplace_Op);
this->applyUserTransform(canvas);
+ fDrawNeedsReset = false;
fOutstandingSaveCount = 0;
}
@@ -302,6 +305,7 @@
// All active culls draw their cull box
fCommandVector[i]->vizExecute(canvas);
} else {
+ fCommandVector[i]->setUserMatrix(fUserMatrix);
fCommandVector[i]->execute(canvas);
}
diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h
index c61627d..0beb642 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -149,6 +149,7 @@
void setUserMatrix(SkMatrix matrix) {
fUserMatrix = matrix;
+ fDrawNeedsReset = true;
}
SkString clipStackData() const { return fClipStackData; }
@@ -261,6 +262,7 @@
bool fMegaVizMode;
int fIndex;
SkMatrix fUserMatrix;
+ bool fDrawNeedsReset; // fUserMatrix has changed so the incremental draw won't work
SkMatrix fMatrix;
SkIRect fClip;
diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp
index 0da8f98..93c436d 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -964,13 +964,19 @@
SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix)
: INHERITED(SET_MATRIX) {
+ fUserMatrix.reset();
fMatrix = matrix;
fInfo.push(SkObjectParser::MatrixToString(matrix));
}
+void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) {
+ fUserMatrix = userMatrix;
+}
+
void SkSetMatrixCommand::execute(SkCanvas* canvas) {
- canvas->setMatrix(fMatrix);
+ SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix);
+ canvas->setMatrix(temp);
}
SkSkewCommand::SkSkewCommand(SkScalar sx, SkScalar sy)
diff --git a/src/utils/debugger/SkDrawCommand.h b/src/utils/debugger/SkDrawCommand.h
index def0db4..1d3d373 100644
--- a/src/utils/debugger/SkDrawCommand.h
+++ b/src/utils/debugger/SkDrawCommand.h
@@ -41,6 +41,9 @@
SkTDArray<SkString*>* Info() {return &fInfo; };
virtual void execute(SkCanvas* canvas) = 0;
virtual void vizExecute(SkCanvas* canvas) { };
+
+ virtual void setUserMatrix(const SkMatrix& userMtx) { };
+
/** Does nothing by default, but used by save() and restore()-type
subclasses to track unresolved save() calls. */
virtual void trackSaveState(int* state) { };
@@ -592,8 +595,10 @@
class SkSetMatrixCommand : public SkDrawCommand {
public:
SkSetMatrixCommand(const SkMatrix& matrix);
+ virtual void setUserMatrix(const SkMatrix&) SK_OVERRIDE;
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
+ SkMatrix fUserMatrix;
SkMatrix fMatrix;
typedef SkDrawCommand INHERITED;