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

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

Issue 1037653004: Revert of Make the canvas draw looper setup update the canvas save count (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 | « gyp/tests.gypi ('k') | tests/DrawLooperTest.cpp » ('j') | 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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 void SkCanvas::restore() { 788 void SkCanvas::restore() {
789 if (fMCRec->fDeferredSaveCount > 0) { 789 if (fMCRec->fDeferredSaveCount > 0) {
790 SkASSERT(fSaveCount > 1); 790 SkASSERT(fSaveCount > 1);
791 fSaveCount -= 1; 791 fSaveCount -= 1;
792 fMCRec->fDeferredSaveCount -= 1; 792 fMCRec->fDeferredSaveCount -= 1;
793 } else { 793 } else {
794 // check for underflow 794 // check for underflow
795 if (fMCStack.count() > 1) { 795 if (fMCStack.count() > 1) {
796 this->willRestore(); 796 this->willRestore();
797 SkASSERT(fSaveCount > 1); 797 SkASSERT(fSaveCount > 1);
798 fSaveCount -= 1;
798 this->internalRestore(); 799 this->internalRestore();
799 this->didRestore(); 800 this->didRestore();
800 } 801 }
801 } 802 }
802 } 803 }
803 804
804 void SkCanvas::restoreToCount(int count) { 805 void SkCanvas::restoreToCount(int count) {
805 // sanity check 806 // sanity check
806 if (count < 1) { 807 if (count < 1) {
807 count = 1; 808 count = 1;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 *intersection = ir; 872 *intersection = ir;
872 } 873 }
873 return true; 874 return true;
874 } 875 }
875 876
876 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) { 877 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) {
877 if (gIgnoreSaveLayerBounds) { 878 if (gIgnoreSaveLayerBounds) {
878 bounds = NULL; 879 bounds = NULL;
879 } 880 }
880 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, kARGB_ClipLa yer_SaveFlag); 881 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, kARGB_ClipLa yer_SaveFlag);
882 fSaveCount += 1;
881 this->internalSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag, strategy); 883 this->internalSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag, strategy);
882 return this->getSaveCount() - 1; 884 return this->getSaveCount() - 1;
883 } 885 }
884 886
885 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags fl ags) { 887 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags fl ags) {
886 if (gIgnoreSaveLayerBounds) { 888 if (gIgnoreSaveLayerBounds) {
887 bounds = NULL; 889 bounds = NULL;
888 } 890 }
889 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags); 891 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags);
892 fSaveCount += 1;
890 this->internalSaveLayer(bounds, paint, flags, strategy); 893 this->internalSaveLayer(bounds, paint, flags, strategy);
891 return this->getSaveCount() - 1; 894 return this->getSaveCount() - 1;
892 } 895 }
893 896
894 void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav eFlags flags, 897 void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav eFlags flags,
895 SaveLayerStrategy strategy) { 898 SaveLayerStrategy strategy) {
896 #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG 899 #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
897 flags |= kClipToLayer_SaveFlag; 900 flags |= kClipToLayer_SaveFlag;
898 #endif 901 #endif
899 902
900 fSaveCount += 1;
901
902 // do this before we create the layer. We don't call the public save() since 903 // do this before we create the layer. We don't call the public save() since
903 // that would invoke a possibly overridden virtual 904 // that would invoke a possibly overridden virtual
904 this->internalSave(); 905 this->internalSave();
905 906
906 fDeviceCMDirty = true; 907 fDeviceCMDirty = true;
907 908
908 SkIRect ir; 909 SkIRect ir;
909 if (!this->clipRectBounds(bounds, flags, &ir, paint ? paint->getImageFilter( ) : NULL)) { 910 if (!this->clipRectBounds(bounds, flags, &ir, paint ? paint->getImageFilter( ) : NULL)) {
910 return; 911 return;
911 } 912 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 } else { 971 } else {
971 SkPaint tmpPaint; 972 SkPaint tmpPaint;
972 tmpPaint.setAlpha(alpha); 973 tmpPaint.setAlpha(alpha);
973 return this->saveLayer(bounds, &tmpPaint, flags); 974 return this->saveLayer(bounds, &tmpPaint, flags);
974 } 975 }
975 } 976 }
976 977
977 void SkCanvas::internalRestore() { 978 void SkCanvas::internalRestore() {
978 SkASSERT(fMCStack.count() != 0); 979 SkASSERT(fMCStack.count() != 0);
979 980
980 fSaveCount -= 1;
981
982 fDeviceCMDirty = true; 981 fDeviceCMDirty = true;
983 fCachedLocalClipBoundsDirty = true; 982 fCachedLocalClipBoundsDirty = true;
984 983
985 fClipStack->restore(); 984 fClipStack->restore();
986 985
987 // reserve our layer (if any) 986 // reserve our layer (if any)
988 DeviceCM* layer = fMCRec->fLayer; // may be null 987 DeviceCM* layer = fMCRec->fLayer; // may be null
989 // now detach it from fMCRec so we can pop(). Gets freed after its drawn 988 // now detach it from fMCRec so we can pop(). Gets freed after its drawn
990 fMCRec->fLayer = NULL; 989 fMCRec->fLayer = NULL;
991 990
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2521 } 2520 }
2522 2521
2523 if (matrix) { 2522 if (matrix) {
2524 canvas->concat(*matrix); 2523 canvas->concat(*matrix);
2525 } 2524 }
2526 } 2525 }
2527 2526
2528 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2527 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2529 fCanvas->restoreToCount(fSaveCount); 2528 fCanvas->restoreToCount(fSaveCount);
2530 } 2529 }
OLDNEW
« no previous file with comments | « gyp/tests.gypi ('k') | tests/DrawLooperTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698