diff options
author | 2012-02-13 21:53:45 +0000 | |
---|---|---|
committer | 2012-02-13 21:53:45 +0000 | |
commit | 8f9ecbd3466d4330886b4c23b06e75b468c795ad (patch) | |
tree | f80694e771c12c45d9c738b879ab3e379f61f148 /src/core/SkPictureRecord.cpp | |
parent | 813d38b7a07957f2990ccca52ddab55fe0b1c632 (diff) |
Adding API and unit testing for deferred canvas clearing/purging
REVIEW=http://codereview.appspot.com/5646057/
TEST=DeferredCanvas unit test
git-svn-id: http://skia.googlecode.com/svn/trunk@3181 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkPictureRecord.cpp')
-rw-r--r-- | src/core/SkPictureRecord.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index f31065b444..c56c104ebe 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -23,6 +23,7 @@ SkPictureRecord::SkPictureRecord(uint32_t flags) : fRestoreOffsetStack.push(0); fPathHeap = NULL; // lazy allocate + fFirstSavedLayerIndex = kNoSavedLayerIndex; } SkPictureRecord::~SkPictureRecord() { @@ -50,6 +51,10 @@ int SkPictureRecord::saveLayer(const SkRect* bounds, const SkPaint* paint, fRestoreOffsetStack.push(0); + if (kNoSavedLayerIndex == fFirstSavedLayerIndex) { + fFirstSavedLayerIndex = fRestoreOffsetStack.count(); + } + validate(); /* Don't actually call saveLayer, because that will try to allocate an offscreen device (potentially very big) which we don't actually need @@ -60,6 +65,10 @@ int SkPictureRecord::saveLayer(const SkRect* bounds, const SkPaint* paint, return this->INHERITED::save(flags); } +bool SkPictureRecord::isDrawingToLayer() const { + return fFirstSavedLayerIndex != kNoSavedLayerIndex; +} + void SkPictureRecord::restore() { // check for underflow if (fRestoreOffsetStack.count() == 0) { @@ -74,6 +83,11 @@ void SkPictureRecord::restore() { offset = *peek; *peek = restoreOffset; } + + if (fRestoreOffsetStack.count() == fFirstSavedLayerIndex) { + fFirstSavedLayerIndex = kNoSavedLayerIndex; + } + fRestoreOffsetStack.pop(); addDraw(RESTORE); |