OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 /* This is the record we keep for each save/restore level in the stack. | 207 /* This is the record we keep for each save/restore level in the stack. |
208 Since a level optionally copies the matrix and/or stack, we have pointers | 208 Since a level optionally copies the matrix and/or stack, we have pointers |
209 for these fields. If the value is copied for this level, the copy is | 209 for these fields. If the value is copied for this level, the copy is |
210 stored in the ...Storage field, and the pointer points to that. If the | 210 stored in the ...Storage field, and the pointer points to that. If the |
211 value is not copied for this level, we ignore ...Storage, and just point | 211 value is not copied for this level, we ignore ...Storage, and just point |
212 at the corresponding value in the previous level in the stack. | 212 at the corresponding value in the previous level in the stack. |
213 */ | 213 */ |
214 class SkCanvas::MCRec { | 214 class SkCanvas::MCRec { |
215 public: | 215 public: |
216 MCRec* fNext; | 216 MCRec* fNext; |
| 217 int fFlags; |
217 SkMatrix* fMatrix; // points to either fMatrixStorage or prev M
CRec | 218 SkMatrix* fMatrix; // points to either fMatrixStorage or prev M
CRec |
218 SkRasterClip* fRasterClip; // points to either fRegionStorage or prev M
CRec | 219 SkRasterClip* fRasterClip; // points to either fRegionStorage or prev M
CRec |
219 SkDrawFilter* fFilter; // the current filter (or null) | 220 SkDrawFilter* fFilter; // the current filter (or null) |
220 | 221 |
221 DeviceCM* fLayer; | 222 DeviceCM* fLayer; |
222 /* If there are any layers in the stack, this points to the top-most | 223 /* If there are any layers in the stack, this points to the top-most |
223 one that is at or below this level in the stack (so we know what | 224 one that is at or below this level in the stack (so we know what |
224 bitmap/device to draw into from this level. This value is NOT | 225 bitmap/device to draw into from this level. This value is NOT |
225 reference counted, since the real owner is either our fLayer field, | 226 reference counted, since the real owner is either our fLayer field, |
226 or a previous one in a lower level.) | 227 or a previous one in a lower level.) |
227 */ | 228 */ |
228 DeviceCM* fTopLayer; | 229 DeviceCM* fTopLayer; |
229 | 230 |
230 MCRec(const MCRec* prev, int flags) { | 231 MCRec(const MCRec* prev, int flags) : fFlags(flags) { |
231 if (NULL != prev) { | 232 if (NULL != prev) { |
232 if (flags & SkCanvas::kMatrix_SaveFlag) { | 233 if (flags & SkCanvas::kMatrix_SaveFlag) { |
233 fMatrixStorage = *prev->fMatrix; | 234 fMatrixStorage = *prev->fMatrix; |
234 fMatrix = &fMatrixStorage; | 235 fMatrix = &fMatrixStorage; |
235 } else { | 236 } else { |
236 fMatrix = prev->fMatrix; | 237 fMatrix = prev->fMatrix; |
237 } | 238 } |
238 | 239 |
239 if (flags & SkCanvas::kClip_SaveFlag) { | 240 if (flags & SkCanvas::kClip_SaveFlag) { |
240 fRasterClipStorage = *prev->fRasterClip; | 241 fRasterClipStorage = *prev->fRasterClip; |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 714 |
714 int SkCanvas::internalSave(SaveFlags flags) { | 715 int SkCanvas::internalSave(SaveFlags flags) { |
715 int saveCount = this->getSaveCount(); // record this before the actual save | 716 int saveCount = this->getSaveCount(); // record this before the actual save |
716 | 717 |
717 MCRec* newTop = (MCRec*)fMCStack.push_back(); | 718 MCRec* newTop = (MCRec*)fMCStack.push_back(); |
718 new (newTop) MCRec(fMCRec, flags); // balanced in restore() | 719 new (newTop) MCRec(fMCRec, flags); // balanced in restore() |
719 | 720 |
720 newTop->fNext = fMCRec; | 721 newTop->fNext = fMCRec; |
721 fMCRec = newTop; | 722 fMCRec = newTop; |
722 | 723 |
723 fClipStack.save(); | 724 if (SkCanvas::kClip_SaveFlag & flags) { |
724 SkASSERT(fClipStack.getSaveCount() == this->getSaveCount() - 1); | 725 fClipStack.save(); |
| 726 } |
725 | 727 |
726 return saveCount; | 728 return saveCount; |
727 } | 729 } |
728 | 730 |
729 int SkCanvas::save(SaveFlags flags) { | 731 int SkCanvas::save(SaveFlags flags) { |
730 // call shared impl | 732 // call shared impl |
731 return this->internalSave(flags); | 733 return this->internalSave(flags); |
732 } | 734 } |
733 | 735 |
734 #define C32MASK (1 << SkBitmap::kARGB_8888_Config) | 736 #define C32MASK (1 << SkBitmap::kARGB_8888_Config) |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 this->internalRestore(); | 891 this->internalRestore(); |
890 } | 892 } |
891 } | 893 } |
892 | 894 |
893 void SkCanvas::internalRestore() { | 895 void SkCanvas::internalRestore() { |
894 SkASSERT(fMCStack.count() != 0); | 896 SkASSERT(fMCStack.count() != 0); |
895 | 897 |
896 fDeviceCMDirty = true; | 898 fDeviceCMDirty = true; |
897 fLocalBoundsCompareTypeDirty = true; | 899 fLocalBoundsCompareTypeDirty = true; |
898 | 900 |
899 fClipStack.restore(); | 901 if (SkCanvas::kClip_SaveFlag & fMCRec->fFlags) { |
| 902 fClipStack.restore(); |
| 903 } |
| 904 |
900 // reserve our layer (if any) | 905 // reserve our layer (if any) |
901 DeviceCM* layer = fMCRec->fLayer; // may be null | 906 DeviceCM* layer = fMCRec->fLayer; // may be null |
902 // now detach it from fMCRec so we can pop(). Gets freed after its drawn | 907 // now detach it from fMCRec so we can pop(). Gets freed after its drawn |
903 fMCRec->fLayer = NULL; | 908 fMCRec->fLayer = NULL; |
904 | 909 |
905 // now do the normal restore() | 910 // now do the normal restore() |
906 fMCRec->~MCRec(); // balanced in save() | 911 fMCRec->~MCRec(); // balanced in save() |
907 fMCStack.pop_back(); | 912 fMCStack.pop_back(); |
908 fMCRec = (MCRec*)fMCStack.back(); | 913 fMCRec = (MCRec*)fMCStack.back(); |
909 | 914 |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2213 return *paint; | 2218 return *paint; |
2214 } | 2219 } |
2215 | 2220 |
2216 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } | 2221 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } |
2217 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } | 2222 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } |
2218 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } | 2223 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } |
2219 | 2224 |
2220 /////////////////////////////////////////////////////////////////////////////// | 2225 /////////////////////////////////////////////////////////////////////////////// |
2221 | 2226 |
2222 SkCanvas::ClipVisitor::~ClipVisitor() { } | 2227 SkCanvas::ClipVisitor::~ClipVisitor() { } |
OLD | NEW |