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

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

Issue 313653006: Return NULL when building empty LayerRasterizer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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 | « include/effects/SkLayerRasterizer.h ('k') | tests/LayerRasterizerTest.cpp » ('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 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 void SkLayerRasterizer::Builder::addLayer(const SkPaint& paint, SkScalar dx, 207 void SkLayerRasterizer::Builder::addLayer(const SkPaint& paint, SkScalar dx,
208 SkScalar dy) { 208 SkScalar dy) {
209 SkASSERT(fLayers); 209 SkASSERT(fLayers);
210 SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)fLayers->push_back(); 210 SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)fLayers->push_back();
211 211
212 SkNEW_PLACEMENT_ARGS(&rec->fPaint, SkPaint, (paint)); 212 SkNEW_PLACEMENT_ARGS(&rec->fPaint, SkPaint, (paint));
213 rec->fOffset.set(dx, dy); 213 rec->fOffset.set(dx, dy);
214 } 214 }
215 215
216 SkLayerRasterizer* SkLayerRasterizer::Builder::detachRasterizer() { 216 SkLayerRasterizer* SkLayerRasterizer::Builder::detachRasterizer() {
217 SkLayerRasterizer* rasterizer = SkNEW_ARGS(SkLayerRasterizer, (fLayers)); 217 SkLayerRasterizer* rasterizer;
218 if (0 == fLayers->count()) {
219 rasterizer = NULL;
220 SkDELETE(fLayers);
221 } else {
222 rasterizer = SkNEW_ARGS(SkLayerRasterizer, (fLayers));
223 }
218 fLayers = NULL; 224 fLayers = NULL;
219 return rasterizer; 225 return rasterizer;
220 } 226 }
221 227
222 SkLayerRasterizer* SkLayerRasterizer::Builder::snapshotRasterizer() const { 228 SkLayerRasterizer* SkLayerRasterizer::Builder::snapshotRasterizer() const {
229 if (0 == fLayers->count()) {
230 return NULL;
231 }
223 SkDeque* layers = SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec), fLayer s->count())); 232 SkDeque* layers = SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec), fLayer s->count()));
224 SkDeque::F2BIter iter(*fLayers); 233 SkDeque::F2BIter iter(*fLayers);
225 const SkLayerRasterizer_Rec* recOrig; 234 const SkLayerRasterizer_Rec* recOrig;
226 SkDEBUGCODE(int count = 0;) 235 SkDEBUGCODE(int count = 0;)
227 while ((recOrig = static_cast<SkLayerRasterizer_Rec*>(iter.next())) != NULL) { 236 while ((recOrig = static_cast<SkLayerRasterizer_Rec*>(iter.next())) != NULL) {
228 SkDEBUGCODE(count++); 237 SkDEBUGCODE(count++);
229 SkLayerRasterizer_Rec* recCopy = static_cast<SkLayerRasterizer_Rec*>(lay ers->push_back()); 238 SkLayerRasterizer_Rec* recCopy = static_cast<SkLayerRasterizer_Rec*>(lay ers->push_back());
230 SkNEW_PLACEMENT_ARGS(&recCopy->fPaint, SkPaint, (recOrig->fPaint)); 239 SkNEW_PLACEMENT_ARGS(&recCopy->fPaint, SkPaint, (recOrig->fPaint));
231 recCopy->fOffset = recOrig->fOffset; 240 recCopy->fOffset = recOrig->fOffset;
232 } 241 }
233 SkASSERT(fLayers->count() == count); 242 SkASSERT(fLayers->count() == count);
234 SkASSERT(layers->count() == count); 243 SkASSERT(layers->count() == count);
235 SkLayerRasterizer* rasterizer = SkNEW_ARGS(SkLayerRasterizer, (layers)); 244 SkLayerRasterizer* rasterizer = SkNEW_ARGS(SkLayerRasterizer, (layers));
236 return rasterizer; 245 return rasterizer;
237 } 246 }
OLDNEW
« no previous file with comments | « include/effects/SkLayerRasterizer.h ('k') | tests/LayerRasterizerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698