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

Side by Side Diff: src/core/SkCanvas.cpp

Issue 1113603002: Decrement SkCanvas::fDeferredSaveCount in doSave() (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkCanvasPriv.h" 9 #include "SkCanvasPriv.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 } while ((layer = layer->fNext) != NULL); 794 } while ((layer = layer->fNext) != NULL);
795 } 795 }
796 fDeviceCMDirty = false; 796 fDeviceCMDirty = false;
797 } 797 }
798 } 798 }
799 799
800 /////////////////////////////////////////////////////////////////////////////// 800 ///////////////////////////////////////////////////////////////////////////////
801 801
802 void SkCanvas::checkForDeferredSave() { 802 void SkCanvas::checkForDeferredSave() {
803 if (fMCRec->fDeferredSaveCount > 0) { 803 if (fMCRec->fDeferredSaveCount > 0) {
804 fMCRec->fDeferredSaveCount -= 1;
805 this->doSave(); 804 this->doSave();
806 } 805 }
807 } 806 }
808 807
809 int SkCanvas::getSaveCount() const { 808 int SkCanvas::getSaveCount() const {
810 #ifdef SK_DEBUG 809 #ifdef SK_DEBUG
811 int count = 0; 810 int count = 0;
812 SkDeque::Iter iter(fMCStack, SkDeque::Iter::kFront_IterStart); 811 SkDeque::Iter iter(fMCStack, SkDeque::Iter::kFront_IterStart);
813 for (;;) { 812 for (;;) {
814 const MCRec* rec = (const MCRec*)iter.next(); 813 const MCRec* rec = (const MCRec*)iter.next();
815 if (!rec) { 814 if (!rec) {
816 break; 815 break;
817 } 816 }
818 count += 1 + rec->fDeferredSaveCount; 817 count += 1 + rec->fDeferredSaveCount;
819 } 818 }
820 SkASSERT(count == fSaveCount); 819 SkASSERT(count == fSaveCount);
821 #endif 820 #endif
822 return fSaveCount; 821 return fSaveCount;
823 } 822 }
824 823
825 int SkCanvas::save() { 824 int SkCanvas::save() {
826 fSaveCount += 1; 825 fSaveCount += 1;
827 fMCRec->fDeferredSaveCount += 1; 826 fMCRec->fDeferredSaveCount += 1;
828 return this->getSaveCount() - 1; // return our prev value 827 return this->getSaveCount() - 1; // return our prev value
829 } 828 }
830 829
831 void SkCanvas::doSave() { 830 void SkCanvas::doSave() {
832 this->willSave(); 831 this->willSave();
832
833 SkASSERT(fMCRec->fDeferredSaveCount > 0);
834 fMCRec->fDeferredSaveCount -= 1;
833 this->internalSave(); 835 this->internalSave();
834 } 836 }
835 837
836 void SkCanvas::restore() { 838 void SkCanvas::restore() {
837 if (fMCRec->fDeferredSaveCount > 0) { 839 if (fMCRec->fDeferredSaveCount > 0) {
838 SkASSERT(fSaveCount > 1); 840 SkASSERT(fSaveCount > 1);
839 fSaveCount -= 1; 841 fSaveCount -= 1;
840 fMCRec->fDeferredSaveCount -= 1; 842 fMCRec->fDeferredSaveCount -= 1;
841 } else { 843 } else {
842 // check for underflow 844 // check for underflow
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after
2576 } 2578 }
2577 2579
2578 if (matrix) { 2580 if (matrix) {
2579 canvas->concat(*matrix); 2581 canvas->concat(*matrix);
2580 } 2582 }
2581 } 2583 }
2582 2584
2583 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2585 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2584 fCanvas->restoreToCount(fSaveCount); 2586 fCanvas->restoreToCount(fSaveCount);
2585 } 2587 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698