aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkCanvas.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index f382893f8c..353c92c6f0 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -404,6 +404,7 @@ SkDevice* SkCanvas::init(SkDevice* device) {
fLocalBoundsCompareTypeDirtyBW = true;
fLastDeviceToGainFocus = NULL;
fDeviceCMDirty = false;
+ fLayerCount = 0;
fMCRec = (MCRec*)fMCStack.push_back();
new (fMCRec) MCRec(NULL, 0);
@@ -443,6 +444,8 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap)
SkCanvas::~SkCanvas() {
// free up the contents of our deque
this->restoreToCount(1); // restore everything but the last
+ SkASSERT(0 == fLayerCount);
+
this->internalRestore(); // restore the last, since we're going away
SkSafeUnref(fBounder);
@@ -747,6 +750,7 @@ int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
fMCRec->fLayer = layer;
fMCRec->fTopLayer = layer; // this field is NOT an owner of layer
+ fLayerCount += 1;
return count;
}
@@ -797,6 +801,9 @@ void SkCanvas::internalRestore() {
layer->fPaint);
// reset this, since drawDevice will have set it to true
fDeviceCMDirty = true;
+
+ SkASSERT(fLayerCount > 0);
+ fLayerCount -= 1;
}
SkDELETE(layer);
}
@@ -820,6 +827,10 @@ void SkCanvas::restoreToCount(int count) {
}
}
+bool SkCanvas::isDrawingToLayer() const {
+ return fLayerCount > 0;
+}
+
/////////////////////////////////////////////////////////////////////////////
// can't draw it if its empty, or its too big for a fixed-point width or height