| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 */ | 56 */ |
| 57 Iterator getIterator(const SkTDArray<void*>& draws, SkCanvas* canvas); | 57 Iterator getIterator(const SkTDArray<void*>& draws, SkCanvas* canvas); |
| 58 | 58 |
| 59 void appendSave(); | 59 void appendSave(); |
| 60 void appendSaveLayer(uint32_t offset); | 60 void appendSaveLayer(uint32_t offset); |
| 61 void appendRestore(); | 61 void appendRestore(); |
| 62 void appendTransform(const SkMatrix& trans); | 62 void appendTransform(const SkMatrix& trans); |
| 63 void appendClip(uint32_t offset); | 63 void appendClip(uint32_t offset); |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * Call this immediately after an appendRestore call that is associated |
| 67 * a save or saveLayer that was removed from the command stream |
| 68 * due to a command pattern optimization in SkPicture. |
| 69 */ |
| 70 void saveCollapsed(); |
| 71 |
| 72 /** |
| 66 * Playback helper | 73 * Playback helper |
| 67 */ | 74 */ |
| 68 class Iterator { | 75 class Iterator { |
| 69 public: | 76 public: |
| 70 /** Returns the next offset into the picture stream, or kDrawComplete if
complete. */ | 77 /** Returns the next offset into the picture stream, or kDrawComplete if
complete. */ |
| 71 uint32_t draw(); | 78 uint32_t draw(); |
| 72 static const uint32_t kDrawComplete = SK_MaxU32; | 79 static const uint32_t kDrawComplete = SK_MaxU32; |
| 73 Iterator() : fPlaybackMatrix(), fValid(false) { } | 80 Iterator() : fPlaybackMatrix(), fValid(false) { } |
| 74 bool isValid() const { return fValid; } | 81 bool isValid() const { return fValid; } |
| 75 private: | 82 private: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 102 | 109 |
| 103 friend class SkPictureStateTree; | 110 friend class SkPictureStateTree; |
| 104 }; | 111 }; |
| 105 | 112 |
| 106 private: | 113 private: |
| 107 | 114 |
| 108 void appendNode(uint32_t offset); | 115 void appendNode(uint32_t offset); |
| 109 | 116 |
| 110 SkChunkAlloc fAlloc; | 117 SkChunkAlloc fAlloc; |
| 111 Node* fRoot; | 118 Node* fRoot; |
| 119 // Needed by saveCollapsed() because nodes do not currently store |
| 120 // references to their children. If they did, we could just retrieve the |
| 121 // last added child. |
| 122 Node* fLastRestoredNode; |
| 112 | 123 |
| 113 // The currently active state | 124 // The currently active state |
| 114 Draw fCurrentState; | 125 Draw fCurrentState; |
| 115 // A stack of states for tracking save/restores | 126 // A stack of states for tracking save/restores |
| 116 SkDeque fStateStack; | 127 SkDeque fStateStack; |
| 117 | 128 |
| 118 // Represents a notable piece of state that requires an offset into the comm
and buffer, | 129 // Represents a notable piece of state that requires an offset into the comm
and buffer, |
| 119 // corresponding to a clip/saveLayer/etc call, to apply. | 130 // corresponding to a clip/saveLayer/etc call, to apply. |
| 120 struct Node { | 131 struct Node { |
| 121 Node* fParent; | 132 Node* fParent; |
| 122 uint32_t fOffset; | 133 uint32_t fOffset; |
| 123 uint16_t fLevel; | 134 uint16_t fLevel; |
| 124 uint16_t fFlags; | 135 uint16_t fFlags; |
| 125 SkMatrix* fMatrix; | 136 SkMatrix* fMatrix; |
| 126 enum Flags { | 137 enum Flags { |
| 127 kSave_Flag = 0x1, | 138 kSave_Flag = 0x1, |
| 128 kSaveLayer_Flag = 0x2 | 139 kSaveLayer_Flag = 0x2 |
| 129 }; | 140 }; |
| 130 }; | 141 }; |
| 131 | 142 |
| 132 typedef SkRefCnt INHERITED; | 143 typedef SkRefCnt INHERITED; |
| 133 }; | 144 }; |
| 134 | 145 |
| 135 #endif | 146 #endif |
| OLD | NEW |