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

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

Issue 12817011: Fixing SkPicture command pattern optimizations to make them work correctly with bounding box hierar… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkPictureStateTree.h ('k') | src/core/SkRTree.h » ('j') | 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"
11 11
12 SK_DEFINE_INST_COUNT(SkPictureStateTree) 12 SK_DEFINE_INST_COUNT(SkPictureStateTree)
13 13
14 SkPictureStateTree::SkPictureStateTree() 14 SkPictureStateTree::SkPictureStateTree()
15 : fAlloc(2048) 15 : fAlloc(2048)
16 , fRoot(NULL) 16 , fRoot(NULL)
17 , fLastRestoredNode(NULL)
17 , fStateStack(sizeof(Draw), 16) { 18 , fStateStack(sizeof(Draw), 16) {
18 SkMatrix* identity = static_cast<SkMatrix*>(fAlloc.allocThrow(sizeof(SkMatri x))); 19 SkMatrix* identity = static_cast<SkMatrix*>(fAlloc.allocThrow(sizeof(SkMatri x)));
19 identity->reset(); 20 identity->reset();
20 fRoot = static_cast<Node*>(fAlloc.allocThrow(sizeof(Node))); 21 fRoot = static_cast<Node*>(fAlloc.allocThrow(sizeof(Node)));
21 fRoot->fParent = NULL; 22 fRoot->fParent = NULL;
22 fRoot->fMatrix = identity; 23 fRoot->fMatrix = identity;
23 fRoot->fFlags = Node::kSave_Flag; 24 fRoot->fFlags = Node::kSave_Flag;
24 fRoot->fOffset = 0; 25 fRoot->fOffset = 0;
25 fRoot->fLevel = 0; 26 fRoot->fLevel = 0;
26 fCurrentState.fNode = fRoot; 27 fCurrentState.fNode = fRoot;
(...skipping 15 matching lines...) Expand all
42 *static_cast<Draw*>(fStateStack.push_back()) = fCurrentState; 43 *static_cast<Draw*>(fStateStack.push_back()) = fCurrentState;
43 fCurrentState.fNode->fFlags |= Node::kSave_Flag; 44 fCurrentState.fNode->fFlags |= Node::kSave_Flag;
44 } 45 }
45 46
46 void SkPictureStateTree::appendSaveLayer(uint32_t offset) { 47 void SkPictureStateTree::appendSaveLayer(uint32_t offset) {
47 *static_cast<Draw*>(fStateStack.push_back()) = fCurrentState; 48 *static_cast<Draw*>(fStateStack.push_back()) = fCurrentState;
48 this->appendNode(offset); 49 this->appendNode(offset);
49 fCurrentState.fNode->fFlags |= Node::kSaveLayer_Flag; 50 fCurrentState.fNode->fFlags |= Node::kSaveLayer_Flag;
50 } 51 }
51 52
53 void SkPictureStateTree::saveCollapsed() {
54 SkASSERT(NULL != fLastRestoredNode);
55 SkASSERT(SkToBool(fLastRestoredNode->fFlags & \
56 (Node::kSaveLayer_Flag | Node::kSave_Flag)));
57 SkASSERT(fLastRestoredNode->fParent == fCurrentState.fNode);
58 // The structure of the tree is not modified here. We just turn off
59 // the save or saveLayer flag to prevent the iterator from making state
60 // changing calls on the playback canvas when traversing a save or
61 // saveLayerNode node.
62 fLastRestoredNode->fFlags = 0;
63 }
64
52 void SkPictureStateTree::appendRestore() { 65 void SkPictureStateTree::appendRestore() {
66 fLastRestoredNode = fCurrentState.fNode;
53 fCurrentState = *static_cast<Draw*>(fStateStack.back()); 67 fCurrentState = *static_cast<Draw*>(fStateStack.back());
54 fStateStack.pop_back(); 68 fStateStack.pop_back();
55 } 69 }
56 70
57 void SkPictureStateTree::appendTransform(const SkMatrix& trans) { 71 void SkPictureStateTree::appendTransform(const SkMatrix& trans) {
58 SkMatrix* m = static_cast<SkMatrix*>(fAlloc.allocThrow(sizeof(SkMatrix))); 72 SkMatrix* m = static_cast<SkMatrix*>(fAlloc.allocThrow(sizeof(SkMatrix)));
59 *m = trans; 73 *m = trans;
60 fCurrentState.fMatrix = m; 74 fCurrentState.fMatrix = m;
61 } 75 }
62 76
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if (fCurrentMatrix != draw->fMatrix) { 182 if (fCurrentMatrix != draw->fMatrix) {
169 SkMatrix tmp = *draw->fMatrix; 183 SkMatrix tmp = *draw->fMatrix;
170 tmp.postConcat(fPlaybackMatrix); 184 tmp.postConcat(fPlaybackMatrix);
171 fCanvas->setMatrix(tmp); 185 fCanvas->setMatrix(tmp);
172 fCurrentMatrix = draw->fMatrix; 186 fCurrentMatrix = draw->fMatrix;
173 } 187 }
174 188
175 ++fPlaybackIndex; 189 ++fPlaybackIndex;
176 return draw->fOffset; 190 return draw->fOffset;
177 } 191 }
OLDNEW
« no previous file with comments | « src/core/SkPictureStateTree.h ('k') | src/core/SkRTree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698