OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
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 #include "SkPictureStateTree.h" | 9 #include "SkPictureStateTree.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 fCurrentState.fNode->fFlags |= Node::kSave_Flag; | 39 fCurrentState.fNode->fFlags |= Node::kSave_Flag; |
40 } | 40 } |
41 | 41 |
42 void SkPictureStateTree::appendSaveLayer(size_t offset) { | 42 void SkPictureStateTree::appendSaveLayer(size_t offset) { |
43 *static_cast<Draw*>(fStateStack.push_back()) = fCurrentState; | 43 *static_cast<Draw*>(fStateStack.push_back()) = fCurrentState; |
44 this->appendNode(offset); | 44 this->appendNode(offset); |
45 fCurrentState.fNode->fFlags |= Node::kSaveLayer_Flag; | 45 fCurrentState.fNode->fFlags |= Node::kSaveLayer_Flag; |
46 } | 46 } |
47 | 47 |
48 void SkPictureStateTree::saveCollapsed() { | 48 void SkPictureStateTree::saveCollapsed() { |
49 SkASSERT(NULL != fLastRestoredNode); | 49 SkASSERT(fLastRestoredNode); |
50 SkASSERT(SkToBool(fLastRestoredNode->fFlags & \ | 50 SkASSERT(SkToBool(fLastRestoredNode->fFlags & \ |
51 (Node::kSaveLayer_Flag | Node::kSave_Flag))); | 51 (Node::kSaveLayer_Flag | Node::kSave_Flag))); |
52 SkASSERT(fLastRestoredNode->fParent == fCurrentState.fNode); | 52 SkASSERT(fLastRestoredNode->fParent == fCurrentState.fNode); |
53 // The structure of the tree is not modified here. We just turn off | 53 // The structure of the tree is not modified here. We just turn off |
54 // the save or saveLayer flag to prevent the iterator from making state | 54 // the save or saveLayer flag to prevent the iterator from making state |
55 // changing calls on the playback canvas when traversing a save or | 55 // changing calls on the playback canvas when traversing a save or |
56 // saveLayerNode node. | 56 // saveLayerNode node. |
57 fLastRestoredNode->fFlags = 0; | 57 fLastRestoredNode->fFlags = 0; |
58 } | 58 } |
59 | 59 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 fCanvas = canvas; | 95 fCanvas = canvas; |
96 fCurrentNode = root; | 96 fCurrentNode = root; |
97 fPlaybackMatrix = canvas->getTotalMatrix(); | 97 fPlaybackMatrix = canvas->getTotalMatrix(); |
98 fCurrentMatrix = NULL; | 98 fCurrentMatrix = NULL; |
99 fPlaybackIndex = 0; | 99 fPlaybackIndex = 0; |
100 fSave = false; | 100 fSave = false; |
101 fValid = true; | 101 fValid = true; |
102 } | 102 } |
103 | 103 |
104 void SkPictureStateTree::Iterator::setCurrentMatrix(const SkMatrix* matrix) { | 104 void SkPictureStateTree::Iterator::setCurrentMatrix(const SkMatrix* matrix) { |
105 SkASSERT(NULL != matrix); | 105 SkASSERT(matrix); |
106 | 106 |
107 if (matrix == fCurrentMatrix) { | 107 if (matrix == fCurrentMatrix) { |
108 return; | 108 return; |
109 } | 109 } |
110 | 110 |
111 // The matrix is in recording space, but we also inherit | 111 // The matrix is in recording space, but we also inherit |
112 // a playback matrix from out target canvas. | 112 // a playback matrix from out target canvas. |
113 SkMatrix m = *matrix; | 113 SkMatrix m = *matrix; |
114 m.postConcat(fPlaybackMatrix); | 114 m.postConcat(fPlaybackMatrix); |
115 fCanvas->setMatrix(m); | 115 fCanvas->setMatrix(m); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 // If we got this far, the clip/saveLayer state is all set, so we can procee
d to set the matrix | 212 // If we got this far, the clip/saveLayer state is all set, so we can procee
d to set the matrix |
213 // for the draw, and return its offset. | 213 // for the draw, and return its offset. |
214 this->setCurrentMatrix(draw->fMatrix); | 214 this->setCurrentMatrix(draw->fMatrix); |
215 | 215 |
216 ++fPlaybackIndex; | 216 ++fPlaybackIndex; |
217 return draw->fOffset; | 217 return draw->fOffset; |
218 } | 218 } |
OLD | NEW |