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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 * a save or saveLayer that was removed from the command stream | 67 * a save or saveLayer that was removed from the command stream |
68 * due to a command pattern optimization in SkPicture. | 68 * due to a command pattern optimization in SkPicture. |
69 */ | 69 */ |
70 void saveCollapsed(); | 70 void saveCollapsed(); |
71 | 71 |
72 /** | 72 /** |
73 * Playback helper | 73 * Playback helper |
74 */ | 74 */ |
75 class Iterator { | 75 class Iterator { |
76 public: | 76 public: |
77 /** Returns the next offset into the picture stream, or kDrawComplete if
complete. */ | 77 /** 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
|
| 79 up draw operation itself. In the latter case, the next draw operatio
n |
| 80 will move into the queued up slot. |
| 81 It retuns kDrawComplete when done. |
| 82 TODO: this might be better named nextOp |
| 83 */ |
78 uint32_t nextDraw(); | 84 uint32_t nextDraw(); |
| 85 /** Peek at the currently queued up draw op's offset. Note that this can |
| 86 be different then what 'nextDraw' would return b.c. it is |
| 87 the offset of the next _draw_ op while 'nextDraw' can return |
| 88 the offsets to saveLayer and clip ops while it is creating the prope
r |
| 89 drawing context for the queued up draw op. |
| 90 */ |
| 91 uint32_t peekDraw(); |
| 92 /** Stop trying to create the drawing context for the currently queued |
| 93 up _draw_ operation and queue up the next one. This call returns |
| 94 the offset of the skipped _draw_ operation. Obviously (since the |
| 95 correct drawing context has not been established), the skipped |
| 96 _draw_ operation should not be issued. Returns kDrawComplete if |
| 97 the end of the draw operations is reached. |
| 98 */ |
| 99 uint32_t skipDraw(); |
79 static const uint32_t kDrawComplete = SK_MaxU32; | 100 static const uint32_t kDrawComplete = SK_MaxU32; |
80 Iterator() : fPlaybackMatrix(), fValid(false) { } | 101 Iterator() : fPlaybackMatrix(), fValid(false) { } |
81 bool isValid() const { return fValid; } | 102 bool isValid() const { return fValid; } |
82 | 103 |
83 private: | 104 private: |
84 Iterator(const SkTDArray<void*>& draws, SkCanvas* canvas, Node* root); | 105 Iterator(const SkTDArray<void*>& draws, SkCanvas* canvas, Node* root); |
85 | 106 |
86 void setCurrentMatrix(const SkMatrix*); | 107 void setCurrentMatrix(const SkMatrix*); |
87 | 108 |
88 // The draws this iterator is associated with | 109 // The draws this iterator is associated with |
(...skipping 15 matching lines...) Expand all Loading... |
104 const SkMatrix* fCurrentMatrix; | 125 const SkMatrix* fCurrentMatrix; |
105 | 126 |
106 // current position in the array of draws | 127 // current position in the array of draws |
107 int fPlaybackIndex; | 128 int fPlaybackIndex; |
108 // Whether or not we need to do a save next iteration | 129 // Whether or not we need to do a save next iteration |
109 bool fSave; | 130 bool fSave; |
110 | 131 |
111 // Whether or not this is a valid iterator (the default public construct
or sets this false) | 132 // Whether or not this is a valid iterator (the default public construct
or sets this false) |
112 bool fValid; | 133 bool fValid; |
113 | 134 |
| 135 uint32_t finish(); |
| 136 |
114 friend class SkPictureStateTree; | 137 friend class SkPictureStateTree; |
115 }; | 138 }; |
116 | 139 |
117 private: | 140 private: |
118 | 141 |
119 void appendNode(size_t offset); | 142 void appendNode(size_t offset); |
120 | 143 |
121 SkChunkAlloc fAlloc; | 144 SkChunkAlloc fAlloc; |
122 // Needed by saveCollapsed() because nodes do not currently store | 145 // Needed by saveCollapsed() because nodes do not currently store |
123 // references to their children. If they did, we could just retrieve the | 146 // references to their children. If they did, we could just retrieve the |
(...skipping 19 matching lines...) Expand all Loading... |
143 }; | 166 }; |
144 }; | 167 }; |
145 | 168 |
146 Node fRoot; | 169 Node fRoot; |
147 SkMatrix fRootMatrix; | 170 SkMatrix fRootMatrix; |
148 | 171 |
149 typedef SkRefCnt INHERITED; | 172 typedef SkRefCnt INHERITED; |
150 }; | 173 }; |
151 | 174 |
152 #endif | 175 #endif |
OLD | NEW |