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

Side by Side Diff: src/effects/SkLayerRasterizer.cpp

Issue 395603002: Simplify flattening to just write enough to call the factory (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
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 9
10 #include "SkLayerRasterizer.h" 10 #include "SkLayerRasterizer.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL) { 153 while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL) {
154 drawMatrix = translatedMatrix; 154 drawMatrix = translatedMatrix;
155 drawMatrix.preTranslate(rec->fOffset.fX, rec->fOffset.fY); 155 drawMatrix.preTranslate(rec->fOffset.fX, rec->fOffset.fY);
156 draw.drawPath(path, rec->fPaint); 156 draw.drawPath(path, rec->fPaint);
157 } 157 }
158 } 158 }
159 return true; 159 return true;
160 } 160 }
161 161
162 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
162 SkLayerRasterizer::SkLayerRasterizer(SkReadBuffer& buffer) 163 SkLayerRasterizer::SkLayerRasterizer(SkReadBuffer& buffer)
163 : SkRasterizer(buffer), fLayers(ReadLayers(buffer)) {} 164 : SkRasterizer(buffer), fLayers(ReadLayers(buffer)) {}
165 #endif
166
167 SkFlattenable* SkLayerRasterizer::CreateProc(SkReadBuffer& buffer) {
168 return SkNEW_ARGS(SkLayerRasterizer, (ReadLayers(buffer)));
169 }
164 170
165 SkDeque* SkLayerRasterizer::ReadLayers(SkReadBuffer& buffer) { 171 SkDeque* SkLayerRasterizer::ReadLayers(SkReadBuffer& buffer) {
166 int count = buffer.readInt(); 172 int count = buffer.readInt();
167 173
168 SkDeque* layers = SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec))); 174 SkDeque* layers = SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec)));
169 for (int i = 0; i < count; i++) { 175 for (int i = 0; i < count; i++) {
170 SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)layers->push_back() ; 176 SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)layers->push_back() ;
171 177
172 SkNEW_PLACEMENT(&rec->fPaint, SkPaint); 178 SkNEW_PLACEMENT(&rec->fPaint, SkPaint);
173 buffer.readPaint(&rec->fPaint); 179 buffer.readPaint(&rec->fPaint);
174 buffer.readPoint(&rec->fOffset); 180 buffer.readPoint(&rec->fOffset);
175 } 181 }
176 return layers; 182 return layers;
177 } 183 }
178 184
179 void SkLayerRasterizer::flatten(SkWriteBuffer& buffer) const { 185 void SkLayerRasterizer::flatten(SkWriteBuffer& buffer) const {
180 this->INHERITED::flatten(buffer); 186 this->INHERITED::flatten(buffer);
181 187
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 SkDEBUGCODE(count++); 242 SkDEBUGCODE(count++);
237 SkLayerRasterizer_Rec* recCopy = static_cast<SkLayerRasterizer_Rec*>(lay ers->push_back()); 243 SkLayerRasterizer_Rec* recCopy = static_cast<SkLayerRasterizer_Rec*>(lay ers->push_back());
238 SkNEW_PLACEMENT_ARGS(&recCopy->fPaint, SkPaint, (recOrig->fPaint)); 244 SkNEW_PLACEMENT_ARGS(&recCopy->fPaint, SkPaint, (recOrig->fPaint));
239 recCopy->fOffset = recOrig->fOffset; 245 recCopy->fOffset = recOrig->fOffset;
240 } 246 }
241 SkASSERT(fLayers->count() == count); 247 SkASSERT(fLayers->count() == count);
242 SkASSERT(layers->count() == count); 248 SkASSERT(layers->count() == count);
243 SkLayerRasterizer* rasterizer = SkNEW_ARGS(SkLayerRasterizer, (layers)); 249 SkLayerRasterizer* rasterizer = SkNEW_ARGS(SkLayerRasterizer, (layers));
244 return rasterizer; 250 return rasterizer;
245 } 251 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698