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 #ifndef SkPictureStateTree_DEFINED | 9 #ifndef SkPictureStateTree_DEFINED |
10 #define SkPictureStateTree_DEFINED | 10 #define SkPictureStateTree_DEFINED |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 SkPictureStateTree(); | 44 SkPictureStateTree(); |
45 ~SkPictureStateTree(); | 45 ~SkPictureStateTree(); |
46 | 46 |
47 /** | 47 /** |
48 * Creates and returns a struct representing a draw at the given offset. | 48 * Creates and returns a struct representing a draw at the given offset. |
49 */ | 49 */ |
50 Draw* appendDraw(size_t offset); | 50 Draw* appendDraw(size_t offset); |
51 | 51 |
52 /** | 52 /** |
53 * Given a list of draws, and a canvas, returns an iterator that produces th
e correct sequence | 53 * Given a list of draws, and a canvas, initialize an iterator that produces
the correct |
54 * of offsets into the command buffer to carry out those calls with correct
matrix/clip state. | 54 * sequence of offsets into the command buffer to carry out those calls with
correct |
55 * This handles saves/restores, and does all necessary matrix setup. | 55 * matrix/clip state. This handles saves/restores, and does all necessary ma
trix setup. |
56 */ | 56 */ |
57 Iterator getIterator(const SkTDArray<void*>& draws, SkCanvas* canvas); | 57 void initIterator(SkPictureStateTree::Iterator* iter, |
| 58 const SkTDArray<void*>& draws, |
| 59 SkCanvas* canvas); |
58 | 60 |
59 void appendSave(); | 61 void appendSave(); |
60 void appendSaveLayer(size_t offset); | 62 void appendSaveLayer(size_t offset); |
61 void appendRestore(); | 63 void appendRestore(); |
62 void appendTransform(const SkMatrix& trans); | 64 void appendTransform(const SkMatrix& trans); |
63 void appendClip(size_t offset); | 65 void appendClip(size_t offset); |
64 | 66 |
65 /** | 67 /** |
66 * Call this immediately after an appendRestore call that is associated | 68 * Call this immediately after an appendRestore call that is associated |
67 * a save or saveLayer that was removed from the command stream | 69 * a save or saveLayer that was removed from the command stream |
68 * due to a command pattern optimization in SkPicture. | 70 * due to a command pattern optimization in SkPicture. |
69 */ | 71 */ |
70 void saveCollapsed(); | 72 void saveCollapsed(); |
71 | 73 |
72 /** | 74 /** |
73 * Playback helper | 75 * Playback helper |
74 */ | 76 */ |
75 class Iterator { | 77 class Iterator { |
76 public: | 78 public: |
77 /** Returns the next op offset needed to create the drawing state | 79 /** Returns the next op offset needed to create the drawing state |
78 required by the queued up draw operation or the offset of the queued | 80 required by the queued up draw operation or the offset of the queued |
79 up draw operation itself. In the latter case, the next draw operatio
n | 81 up draw operation itself. In the latter case, the next draw operatio
n |
80 will move into the queued up slot. | 82 will move into the queued up slot. |
81 It retuns kDrawComplete when done. | 83 It retuns kDrawComplete when done. |
82 TODO: this might be better named nextOp | 84 TODO: this might be better named nextOp |
83 */ | 85 */ |
84 uint32_t nextDraw(); | 86 uint32_t nextDraw(); |
85 static const uint32_t kDrawComplete = SK_MaxU32; | 87 static const uint32_t kDrawComplete = SK_MaxU32; |
86 Iterator() : fPlaybackMatrix(), fValid(false) { } | 88 Iterator() : fValid(false) { } |
87 bool isValid() const { return fValid; } | 89 bool isValid() const { return fValid; } |
88 | 90 |
89 private: | 91 private: |
90 Iterator(const SkTDArray<void*>& draws, SkCanvas* canvas, Node* root); | 92 void init(const SkTDArray<void*>& draws, SkCanvas* canvas, Node* root); |
91 | 93 |
92 void setCurrentMatrix(const SkMatrix*); | 94 void setCurrentMatrix(const SkMatrix*); |
93 | 95 |
94 // The draws this iterator is associated with | 96 // The draws this iterator is associated with |
95 const SkTDArray<void*>* fDraws; | 97 const SkTDArray<void*>* fDraws; |
96 | 98 |
97 // canvas this is playing into (so we can insert saves/restores as neces
sary) | 99 // canvas this is playing into (so we can insert saves/restores as neces
sary) |
98 SkCanvas* fCanvas; | 100 SkCanvas* fCanvas; |
99 | 101 |
100 // current state node | 102 // current state node |
101 Node* fCurrentNode; | 103 Node* fCurrentNode; |
102 | 104 |
103 // List of nodes whose state we need to apply to reach TargetNode | 105 // List of nodes whose state we need to apply to reach TargetNode |
104 SkTDArray<Node*> fNodes; | 106 SkTDArray<Node*> fNodes; |
105 | 107 |
106 // The matrix of the canvas we're playing back into | 108 // The matrix of the canvas we're playing back into |
107 const SkMatrix fPlaybackMatrix; | 109 SkMatrix fPlaybackMatrix; |
108 | 110 |
109 // Cache of current matrix, so we can avoid redundantly setting it | 111 // Cache of current matrix, so we can avoid redundantly setting it |
110 const SkMatrix* fCurrentMatrix; | 112 const SkMatrix* fCurrentMatrix; |
111 | 113 |
112 // current position in the array of draws | 114 // current position in the array of draws |
113 int fPlaybackIndex; | 115 int fPlaybackIndex; |
114 // Whether or not we need to do a save next iteration | 116 // Whether or not we need to do a save next iteration |
115 bool fSave; | 117 bool fSave; |
116 | 118 |
117 // Whether or not this is a valid iterator (the default public construct
or sets this false) | 119 // Whether or not this is a valid iterator (the default public construct
or sets this false) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 }; | 153 }; |
152 }; | 154 }; |
153 | 155 |
154 Node fRoot; | 156 Node fRoot; |
155 SkMatrix fRootMatrix; | 157 SkMatrix fRootMatrix; |
156 | 158 |
157 typedef SkRefCnt INHERITED; | 159 typedef SkRefCnt INHERITED; |
158 }; | 160 }; |
159 | 161 |
160 #endif | 162 #endif |
OLD | NEW |