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

Unified Diff: src/core/SkCanvas.cpp

Issue 763503003: add basic tests for save/restore counting (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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 | « no previous file | tests/CanvasTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 3bf1ad9e8041393c53c8d1ffa225e630f0795e56..afb89b038e59a3bbcb5788abd179712203eb7626 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -811,6 +811,36 @@ void SkCanvas::updateDeviceCMCache() {
///////////////////////////////////////////////////////////////////////////////
+int SkCanvas::getSaveCount() const {
+ return fMCStack.count();
+}
+
+int SkCanvas::save() {
+ this->willSave();
+ return this->internalSave();
+}
+
+void SkCanvas::restore() {
+ // check for underflow
+ if (fMCStack.count() > 1) {
+ this->willRestore();
+ this->internalRestore();
+ this->didRestore();
+ }
+}
+
+void SkCanvas::restoreToCount(int count) {
+ // sanity check
+ if (count < 1) {
+ count = 1;
+ }
+
+ int n = this->getSaveCount() - count;
+ for (int i = 0; i < n; ++i) {
+ this->restore();
+ }
+}
+
int SkCanvas::internalSave() {
int saveCount = this->getSaveCount(); // record this before the actual save
@@ -823,11 +853,6 @@ int SkCanvas::internalSave() {
return saveCount;
}
-int SkCanvas::save() {
- this->willSave();
- return this->internalSave();
-}
-
static bool bounds_affects_clip(SkCanvas::SaveFlags flags) {
#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
return (flags & SkCanvas::kClipToLayer_SaveFlag) != 0;
@@ -977,15 +1002,6 @@ int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha,
}
}
-void SkCanvas::restore() {
- // check for underflow
- if (fMCStack.count() > 1) {
- this->willRestore();
- this->internalRestore();
- this->didRestore();
- }
-}
-
void SkCanvas::internalRestore() {
SkASSERT(fMCStack.count() != 0);
@@ -1023,22 +1039,6 @@ void SkCanvas::internalRestore() {
}
}
-int SkCanvas::getSaveCount() const {
- return fMCStack.count();
-}
-
-void SkCanvas::restoreToCount(int count) {
- // sanity check
- if (count < 1) {
- count = 1;
- }
-
- int n = this->getSaveCount() - count;
- for (int i = 0; i < n; ++i) {
- this->restore();
- }
-}
-
bool SkCanvas::isDrawingToLayer() const {
return fSaveLayerCount > 0;
}
« no previous file with comments | « no previous file | tests/CanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698