Close pending save() calls in QT debugger to avoid saveLayer() corruption.
http://codereview.appspot.com/6856076/
git-svn-id: http://skia.googlecode.com/svn/trunk@6565 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/debugger/SkDebugCanvas.cpp b/debugger/SkDebugCanvas.cpp
index 0c1c26b..af86a1e 100644
--- a/debugger/SkDebugCanvas.cpp
+++ b/debugger/SkDebugCanvas.cpp
@@ -20,7 +20,8 @@
}
SkDebugCanvas::SkDebugCanvas(int width, int height)
- : INHERITED(make_noconfig_bm(width, height)) {
+ : INHERITED(make_noconfig_bm(width, height))
+ , fOutstandingSaveCount(0) {
// TODO(chudy): Free up memory from all draw commands in destructor.
fWidth = width;
fHeight = height;
@@ -96,6 +97,9 @@
if (fIndex < index) {
i = fIndex + 1;
} else {
+ for (int j = 0; j < fOutstandingSaveCount; j++) {
+ canvas->restore();
+ }
i = 0;
canvas->clear(0);
canvas->resetMatrix();
@@ -103,6 +107,7 @@
SkIntToScalar(fHeight));
canvas->clipRect(rect, SkRegion::kReplace_Op );
applyUserTransform(canvas);
+ fOutstandingSaveCount = 0;
}
for (; i <= index; i++) {
@@ -122,6 +127,7 @@
if (commandVector[i]->isVisible()) {
commandVector[i]->execute(canvas);
+ commandVector[i]->trackSaveState(&fOutstandingSaveCount);
}
}
fMatrix = canvas->getTotalMatrix();