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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 117 } |
118 fCurrentNode = fCurrentNode->fParent; | 118 fCurrentNode = fCurrentNode->fParent; |
119 } | 119 } |
120 return kDrawComplete; | 120 return kDrawComplete; |
121 } | 121 } |
122 | 122 |
123 Draw* draw = static_cast<Draw*>((*fDraws)[fPlaybackIndex]); | 123 Draw* draw = static_cast<Draw*>((*fDraws)[fPlaybackIndex]); |
124 Node* targetNode = draw->fNode; | 124 Node* targetNode = draw->fNode; |
125 | 125 |
126 if (fSave) { | 126 if (fSave) { |
127 fCanvas->save(SkCanvas::kClip_SaveFlag); | 127 fCanvas->save(); |
128 fSave = false; | 128 fSave = false; |
129 } | 129 } |
130 | 130 |
131 if (fCurrentNode != targetNode) { | 131 if (fCurrentNode != targetNode) { |
132 // If we're not at the target and we don't have a list of nodes to get t
here, we need to | 132 // If we're not at the target and we don't have a list of nodes to get t
here, we need to |
133 // figure out the path from our current node, to the target | 133 // figure out the path from our current node, to the target |
134 if (fNodes.count() == 0) { | 134 if (fNodes.count() == 0) { |
135 // Trace back up to a common ancestor, restoring to get our current
state to match that | 135 // Trace back up to a common ancestor, restoring to get our current
state to match that |
136 // of the ancestor, and saving a list of nodes whose state we need t
o apply to get to | 136 // of the ancestor, and saving a list of nodes whose state we need t
o apply to get to |
137 // the target (we can restore up to the ancestor immediately, but we
'll need to return | 137 // the target (we can restore up to the ancestor immediately, but we
'll need to return |
(...skipping 17 matching lines...) Expand all Loading... |
155 fNodes.push(ancestor); | 155 fNodes.push(ancestor); |
156 ancestor = ancestor->fParent; | 156 ancestor = ancestor->fParent; |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 if (ancestor->fFlags & Node::kSave_Flag) { | 160 if (ancestor->fFlags & Node::kSave_Flag) { |
161 if (fCurrentNode != ancestor) { | 161 if (fCurrentNode != ancestor) { |
162 fCanvas->restore(); | 162 fCanvas->restore(); |
163 } | 163 } |
164 if (targetNode != ancestor) { | 164 if (targetNode != ancestor) { |
| 165 // FIXME: the save below depends on soon-to-be-deprecated |
| 166 // SaveFlags behavior: it relies on matrix changes persistin
g |
| 167 // after restore. |
165 fCanvas->save(SkCanvas::kClip_SaveFlag); | 168 fCanvas->save(SkCanvas::kClip_SaveFlag); |
166 } | 169 } |
167 } | 170 } |
168 fCurrentNode = ancestor; | 171 fCurrentNode = ancestor; |
169 } | 172 } |
170 | 173 |
171 // If we're not at the target node yet, we'll need to return an offset t
o make the caller | 174 // If we're not at the target node yet, we'll need to return an offset t
o make the caller |
172 // apply the next clip or saveLayer. | 175 // apply the next clip or saveLayer. |
173 if (fCurrentNode != targetNode) { | 176 if (fCurrentNode != targetNode) { |
174 if (fCurrentMatrix != fNodes.top()->fMatrix) { | 177 if (fCurrentMatrix != fNodes.top()->fMatrix) { |
(...skipping 16 matching lines...) Expand all Loading... |
191 if (fCurrentMatrix != draw->fMatrix) { | 194 if (fCurrentMatrix != draw->fMatrix) { |
192 SkMatrix tmp = *draw->fMatrix; | 195 SkMatrix tmp = *draw->fMatrix; |
193 tmp.postConcat(fPlaybackMatrix); | 196 tmp.postConcat(fPlaybackMatrix); |
194 fCanvas->setMatrix(tmp); | 197 fCanvas->setMatrix(tmp); |
195 fCurrentMatrix = draw->fMatrix; | 198 fCurrentMatrix = draw->fMatrix; |
196 } | 199 } |
197 | 200 |
198 ++fPlaybackIndex; | 201 ++fPlaybackIndex; |
199 return draw->fOffset; | 202 return draw->fOffset; |
200 } | 203 } |
OLD | NEW |