aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-10-16 14:28:28 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-16 14:28:28 -0700
commit70171683e6977af7472f0f465bd81852d0644ddd (patch)
tree6658846b90529d06b19f0e084a30890bc56fe7f6 /src/utils
parent427cf28861867c0ea9aafca3a23878ec4068ad99 (diff)
"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
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/debugger/SkDebugCanvas.cpp8
-rw-r--r--src/utils/debugger/SkDebugCanvas.h2
-rw-r--r--src/utils/debugger/SkDrawCommand.cpp8
-rw-r--r--src/utils/debugger/SkDrawCommand.h5
4 files changed, 20 insertions, 3 deletions
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index 85fb7a4ee0..684c5cd17b 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -27,6 +27,7 @@ SkDebugCanvas::SkDebugCanvas(int windowWidth, int windowHeight)
, 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 @@ int SkDebugCanvas::getCommandAtPoint(int x, int y, int index) {
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 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
// 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 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
}
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 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
// 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 c61627d71d..0beb64237f 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -149,6 +149,7 @@ public:
void setUserMatrix(SkMatrix matrix) {
fUserMatrix = matrix;
+ fDrawNeedsReset = true;
}
SkString clipStackData() const { return fClipStackData; }
@@ -261,6 +262,7 @@ private:
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 0da8f98954..93c436df64 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -964,13 +964,19 @@ void SkScaleCommand::execute(SkCanvas* canvas) {
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 def0db4d8a..1d3d373ac8 100644
--- a/src/utils/debugger/SkDrawCommand.h
+++ b/src/utils/debugger/SkDrawCommand.h
@@ -41,6 +41,9 @@ public:
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 @@ private:
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;