Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: src/core/SkPictureStateTree.cpp

Issue 378343002: Refactor SkPicturePlayback for SkPictureReplacementPlayback (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Move StepIterator to be next to SkipIterTo Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkPictureStateTree.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « src/core/SkPictureStateTree.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698