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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 void SkPictureStateTree::appendTransform(const SkMatrix& trans) { | 66 void SkPictureStateTree::appendTransform(const SkMatrix& trans) { |
67 SkMatrix* m = static_cast<SkMatrix*>(fAlloc.allocThrow(sizeof(SkMatrix))); | 67 SkMatrix* m = static_cast<SkMatrix*>(fAlloc.allocThrow(sizeof(SkMatrix))); |
68 *m = trans; | 68 *m = trans; |
69 fCurrentState.fMatrix = m; | 69 fCurrentState.fMatrix = m; |
70 } | 70 } |
71 | 71 |
72 void SkPictureStateTree::appendClip(size_t offset) { | 72 void SkPictureStateTree::appendClip(size_t offset) { |
73 this->appendNode(offset); | 73 this->appendNode(offset); |
74 } | 74 } |
75 | 75 |
76 SkPictureStateTree::Iterator SkPictureStateTree::getIterator(const SkTDArray<voi
d*>& draws, | 76 void SkPictureStateTree::initIterator(SkPictureStateTree::Iterator* iter, |
77 SkCanvas* canvas) { | 77 const SkTDArray<void*>& draws, |
78 return Iterator(draws, canvas, &fRoot); | 78 SkCanvas* canvas) { |
| 79 iter->init(draws, canvas, &fRoot); |
79 } | 80 } |
80 | 81 |
81 void SkPictureStateTree::appendNode(size_t offset) { | 82 void SkPictureStateTree::appendNode(size_t offset) { |
82 Node* n = static_cast<Node*>(fAlloc.allocThrow(sizeof(Node))); | 83 Node* n = static_cast<Node*>(fAlloc.allocThrow(sizeof(Node))); |
83 n->fOffset = SkToU32(offset); | 84 n->fOffset = SkToU32(offset); |
84 n->fFlags = 0; | 85 n->fFlags = 0; |
85 n->fParent = fCurrentState.fNode; | 86 n->fParent = fCurrentState.fNode; |
86 n->fLevel = fCurrentState.fNode->fLevel + 1; | 87 n->fLevel = fCurrentState.fNode->fLevel + 1; |
87 n->fMatrix = fCurrentState.fMatrix; | 88 n->fMatrix = fCurrentState.fMatrix; |
88 fCurrentState.fNode = n; | 89 fCurrentState.fNode = n; |
89 } | 90 } |
90 | 91 |
91 SkPictureStateTree::Iterator::Iterator(const SkTDArray<void*>& draws, SkCanvas*
canvas, Node* root) | 92 void SkPictureStateTree::Iterator::init(const SkTDArray<void*>& draws, SkCanvas*
canvas, Node* root) { |
92 : fDraws(&draws) | 93 SkASSERT(!fValid); |
93 , fCanvas(canvas) | 94 fDraws = &draws; |
94 , fCurrentNode(root) | 95 fCanvas = canvas; |
95 , fPlaybackMatrix(canvas->getTotalMatrix()) | 96 fCurrentNode = root; |
96 , fCurrentMatrix(NULL) | 97 fPlaybackMatrix = canvas->getTotalMatrix(); |
97 , fPlaybackIndex(0) | 98 fCurrentMatrix = NULL; |
98 , fSave(false) | 99 fPlaybackIndex = 0; |
99 , fValid(true) { | 100 fSave = false; |
| 101 fValid = true; |
100 } | 102 } |
101 | 103 |
102 void SkPictureStateTree::Iterator::setCurrentMatrix(const SkMatrix* matrix) { | 104 void SkPictureStateTree::Iterator::setCurrentMatrix(const SkMatrix* matrix) { |
103 SkASSERT(NULL != matrix); | 105 SkASSERT(NULL != matrix); |
104 | 106 |
105 if (matrix == fCurrentMatrix) { | 107 if (matrix == fCurrentMatrix) { |
106 return; | 108 return; |
107 } | 109 } |
108 | 110 |
109 // The matrix is in recording space, but we also inherit | 111 // The matrix is in recording space, but we also inherit |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 209 } |
208 } | 210 } |
209 | 211 |
210 // 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 |
211 // for the draw, and return its offset. | 213 // for the draw, and return its offset. |
212 this->setCurrentMatrix(draw->fMatrix); | 214 this->setCurrentMatrix(draw->fMatrix); |
213 | 215 |
214 ++fPlaybackIndex; | 216 ++fPlaybackIndex; |
215 return draw->fOffset; | 217 return draw->fOffset; |
216 } | 218 } |
OLD | NEW |