Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: src/core/SkPictureContentInfo.cpp

Issue 464433002: Add layer counting to SkPictureRecord (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bug Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureContentInfo.h ('k') | src/core/SkPictureData.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureContentInfo.cpp
diff --git a/src/core/SkPictureContentInfo.cpp b/src/core/SkPictureContentInfo.cpp
index 8185d850b8d9b0b81f1c97a2dfe7d4819ab21663..1d19f352f4adf806527e6c4fbe33f38a2f19339c 100644
--- a/src/core/SkPictureContentInfo.cpp
+++ b/src/core/SkPictureContentInfo.cpp
@@ -71,6 +71,62 @@ void SkPictureContentInfo::onAddPaintPtr(const SkPaint* paint) {
}
}
+void SkPictureContentInfo::onSaveLayer() {
+ *fSaveStack.append() = kSaveLayer_Flag;
+}
+
+void SkPictureContentInfo::onSave() {
+ *fSaveStack.append() = kSave_Flag;
+}
+
+void SkPictureContentInfo::onRestore() {
+ SkASSERT(fSaveStack.count() > 0);
+
+ bool containedSaveLayer = fSaveStack.top() & kContainedSaveLayer_Flag;
+
+ if (fSaveStack.top() & kSaveLayer_Flag) {
+ ++fNumLayers;
+ if (containedSaveLayer) {
+ ++fNumInteriorLayers;
+ } else {
+ ++fNumLeafLayers;
+ }
+ containedSaveLayer = true;
+ }
+
+ fSaveStack.pop();
+
+ if (containedSaveLayer && fSaveStack.count() > 0) {
+ fSaveStack.top() |= kContainedSaveLayer_Flag;
+ }
+}
+
+void SkPictureContentInfo::rescindLastSave() {
+ SkASSERT(fSaveStack.count() > 0);
+ SkASSERT(fSaveStack.top() & kSave_Flag);
+
+ bool containedSaveLayer = fSaveStack.top() & kContainedSaveLayer_Flag;
+
+ fSaveStack.pop();
+
+ if (containedSaveLayer && fSaveStack.count() > 0) {
+ fSaveStack.top() |= kContainedSaveLayer_Flag;
+ }
+}
+
+void SkPictureContentInfo::rescindLastSaveLayer() {
+ SkASSERT(fSaveStack.count() > 0);
+ SkASSERT(fSaveStack.top() & kSaveLayer_Flag);
+
+ bool containedSaveLayer = fSaveStack.top() & kContainedSaveLayer_Flag;
+
+ fSaveStack.pop();
+
+ if (containedSaveLayer && fSaveStack.count() > 0) {
+ fSaveStack.top() |= kContainedSaveLayer_Flag;
+ }
+}
+
void SkPictureContentInfo::set(const SkPictureContentInfo& src) {
fNumOperations = src.fNumOperations;
fNumTexts = src.fNumTexts;
@@ -78,6 +134,10 @@ void SkPictureContentInfo::set(const SkPictureContentInfo& src) {
fNumFastPathDashEffects = src.fNumFastPathDashEffects;
fNumAAConcavePaths = src.fNumAAConcavePaths;
fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths;
+ fNumLayers = src.fNumLayers;
+ fNumInteriorLayers = src.fNumInteriorLayers;
+ fNumLeafLayers = src.fNumLeafLayers;
+ fSaveStack = src.fSaveStack;
}
void SkPictureContentInfo::reset() {
@@ -87,6 +147,10 @@ void SkPictureContentInfo::reset() {
fNumFastPathDashEffects = 0;
fNumAAConcavePaths = 0;
fNumAAHairlineConcavePaths = 0;
+ fNumLayers = 0;
+ fNumInteriorLayers = 0;
+ fNumLeafLayers = 0;
+ fSaveStack.rewind();
}
void SkPictureContentInfo::swap(SkPictureContentInfo* other) {
@@ -96,4 +160,8 @@ void SkPictureContentInfo::swap(SkPictureContentInfo* other) {
SkTSwap(fNumFastPathDashEffects, other->fNumFastPathDashEffects);
SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths);
SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths);
+ SkTSwap(fNumLayers, other->fNumLayers);
+ SkTSwap(fNumInteriorLayers, other->fNumInteriorLayers);
+ SkTSwap(fNumLeafLayers, other->fNumLeafLayers);
+ fSaveStack.swap(other->fSaveStack);
}
« no previous file with comments | « src/core/SkPictureContentInfo.h ('k') | src/core/SkPictureData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698