From 8f9ecbd3466d4330886b4c23b06e75b468c795ad Mon Sep 17 00:00:00 2001 From: "junov@chromium.org" Date: Mon, 13 Feb 2012 21:53:45 +0000 Subject: 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 --- src/core/SkPictureRecord.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/core/SkPictureRecord.cpp') 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); -- cgit v1.2.3