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

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

Issue 261663003: First pass at pre-rendering saveLayers for GPU (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Reduce size of PlaybackReplacements in SkPicturePlayback.h Created 6 years, 7 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/gpu/GrPictureUtils.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"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 // The matrix is in recording space, but we also inherit 109 // The matrix is in recording space, but we also inherit
110 // a playback matrix from out target canvas. 110 // a playback matrix from out target canvas.
111 SkMatrix m = *matrix; 111 SkMatrix m = *matrix;
112 m.postConcat(fPlaybackMatrix); 112 m.postConcat(fPlaybackMatrix);
113 fCanvas->setMatrix(m); 113 fCanvas->setMatrix(m);
114 fCurrentMatrix = matrix; 114 fCurrentMatrix = matrix;
115 } 115 }
116 116
117 uint32_t SkPictureStateTree::Iterator::peekDraw() {
118 SkASSERT(this->isValid());
119 if (fPlaybackIndex >= fDraws->count()) {
120 return kDrawComplete;
121 }
122
123 Draw* draw = static_cast<Draw*>((*fDraws)[fPlaybackIndex]);
124 return draw->fOffset;
125 }
126
127 uint32_t SkPictureStateTree::Iterator::skipDraw() {
128 SkASSERT(this->isValid());
129 if (fPlaybackIndex >= fDraws->count()) {
130 return this->finish();
131 }
132
133 Draw* draw = static_cast<Draw*>((*fDraws)[fPlaybackIndex]);
134
135 if (fSave) {
136 fCanvas->save();
137 fSave = false;
138 }
139
140 fNodes.rewind();
141
142 ++fPlaybackIndex;
143 return draw->fOffset;
144 }
145
146 uint32_t SkPictureStateTree::Iterator::finish() {
147 if (fCurrentNode->fFlags & Node::kSaveLayer_Flag) {
148 fCanvas->restore();
149 }
150
151 for (fCurrentNode = fCurrentNode->fParent; fCurrentNode;
152 fCurrentNode = fCurrentNode->fParent) {
153 // Note: we call restore() twice when both flags are set.
154 if (fCurrentNode->fFlags & Node::kSave_Flag) {
155 fCanvas->restore();
156 }
157 if (fCurrentNode->fFlags & Node::kSaveLayer_Flag) {
158 fCanvas->restore();
159 }
160 }
161
162 fCanvas->setMatrix(fPlaybackMatrix);
163 fCurrentMatrix = NULL;
164 return kDrawComplete;
165 }
166
117 uint32_t SkPictureStateTree::Iterator::nextDraw() { 167 uint32_t SkPictureStateTree::Iterator::nextDraw() {
118 SkASSERT(this->isValid()); 168 SkASSERT(this->isValid());
119 if (fPlaybackIndex >= fDraws->count()) { 169 if (fPlaybackIndex >= fDraws->count()) {
120 if (fCurrentNode->fFlags & Node::kSaveLayer_Flag) { 170 return this->finish();
121 fCanvas->restore();
122 }
123
124 for (fCurrentNode = fCurrentNode->fParent; fCurrentNode;
125 fCurrentNode = fCurrentNode->fParent) {
126 // Note: we call restore() twice when both flags are set.
127 if (fCurrentNode->fFlags & Node::kSave_Flag) {
128 fCanvas->restore();
129 }
130 if (fCurrentNode->fFlags & Node::kSaveLayer_Flag) {
131 fCanvas->restore();
132 }
133 }
134
135 fCanvas->setMatrix(fPlaybackMatrix);
136 fCurrentMatrix = NULL;
137 return kDrawComplete;
138 } 171 }
139 172
140 Draw* draw = static_cast<Draw*>((*fDraws)[fPlaybackIndex]); 173 Draw* draw = static_cast<Draw*>((*fDraws)[fPlaybackIndex]);
141 Node* targetNode = draw->fNode; 174 Node* targetNode = draw->fNode;
142 175
143 if (fSave) { 176 if (fSave) {
144 fCanvas->save(); 177 fCanvas->save();
145 fSave = false; 178 fSave = false;
146 } 179 }
147 180
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 236 }
204 } 237 }
205 238
206 // If we got this far, the clip/saveLayer state is all set, so we can procee d to set the matrix 239 // If we got this far, the clip/saveLayer state is all set, so we can procee d to set the matrix
207 // for the draw, and return its offset. 240 // for the draw, and return its offset.
208 this->setCurrentMatrix(draw->fMatrix); 241 this->setCurrentMatrix(draw->fMatrix);
209 242
210 ++fPlaybackIndex; 243 ++fPlaybackIndex;
211 return draw->fOffset; 244 return draw->fOffset;
212 } 245 }
OLDNEW
« no previous file with comments | « src/core/SkPictureStateTree.h ('k') | src/gpu/GrPictureUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698