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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/effects/SkLayerDrawLooper.cpp ('k') | src/effects/SkLightingImageFilter.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 18 matching lines...) Expand all
29 29
30 SkLayerRasterizer::SkLayerRasterizer(SkDeque* layers) : fLayers(layers) 30 SkLayerRasterizer::SkLayerRasterizer(SkDeque* layers) : fLayers(layers)
31 { 31 {
32 } 32 }
33 33
34 // Helper function to call destructors on SkPaints held by layers and delete lay ers. 34 // Helper function to call destructors on SkPaints held by layers and delete lay ers.
35 static void clean_up_layers(SkDeque* layers) { 35 static void clean_up_layers(SkDeque* layers) {
36 SkDeque::F2BIter iter(*layers); 36 SkDeque::F2BIter iter(*layers);
37 SkLayerRasterizer_Rec* rec; 37 SkLayerRasterizer_Rec* rec;
38 38
39 while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL) 39 while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != nullptr)
40 rec->fPaint.~SkPaint(); 40 rec->fPaint.~SkPaint();
41 41
42 delete layers; 42 delete layers;
43 } 43 }
44 44
45 SkLayerRasterizer::~SkLayerRasterizer() { 45 SkLayerRasterizer::~SkLayerRasterizer() {
46 SkASSERT(fLayers); 46 SkASSERT(fLayers);
47 clean_up_layers(const_cast<SkDeque*>(fLayers)); 47 clean_up_layers(const_cast<SkDeque*>(fLayers));
48 } 48 }
49 49
50 static bool compute_bounds(const SkDeque& layers, const SkPath& path, 50 static bool compute_bounds(const SkDeque& layers, const SkPath& path,
51 const SkMatrix& matrix, 51 const SkMatrix& matrix,
52 const SkIRect* clipBounds, SkIRect* bounds) { 52 const SkIRect* clipBounds, SkIRect* bounds) {
53 SkDeque::F2BIter iter(layers); 53 SkDeque::F2BIter iter(layers);
54 SkLayerRasterizer_Rec* rec; 54 SkLayerRasterizer_Rec* rec;
55 55
56 bounds->set(SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32); 56 bounds->set(SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32);
57 57
58 while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL) { 58 while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != nullptr) {
59 const SkPaint& paint = rec->fPaint; 59 const SkPaint& paint = rec->fPaint;
60 SkPath fillPath, devPath; 60 SkPath fillPath, devPath;
61 const SkPath* p = &path; 61 const SkPath* p = &path;
62 62
63 if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) { 63 if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) {
64 paint.getFillPath(path, &fillPath); 64 paint.getFillPath(path, &fillPath);
65 p = &fillPath; 65 p = &fillPath;
66 } 66 }
67 if (p->isEmpty()) { 67 if (p->isEmpty()) {
68 continue; 68 continue;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 -SkIntToScalar(mask->fBounds.fTop)); 129 -SkIntToScalar(mask->fBounds.fTop));
130 130
131 draw.fMatrix = &drawMatrix; 131 draw.fMatrix = &drawMatrix;
132 draw.fRC = &rectClip; 132 draw.fRC = &rectClip;
133 draw.fClip = &rectClip.bwRgn(); 133 draw.fClip = &rectClip.bwRgn();
134 // we set the matrixproc in the loop, as the matrix changes each time (p otentially) 134 // we set the matrixproc in the loop, as the matrix changes each time (p otentially)
135 135
136 SkDeque::F2BIter iter(*fLayers); 136 SkDeque::F2BIter iter(*fLayers);
137 SkLayerRasterizer_Rec* rec; 137 SkLayerRasterizer_Rec* rec;
138 138
139 while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL) { 139 while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != nullptr) {
140 drawMatrix = translatedMatrix; 140 drawMatrix = translatedMatrix;
141 drawMatrix.preTranslate(rec->fOffset.fX, rec->fOffset.fY); 141 drawMatrix.preTranslate(rec->fOffset.fX, rec->fOffset.fY);
142 draw.drawPath(path, rec->fPaint); 142 draw.drawPath(path, rec->fPaint);
143 } 143 }
144 } 144 }
145 return true; 145 return true;
146 } 146 }
147 147
148 SkFlattenable* SkLayerRasterizer::CreateProc(SkReadBuffer& buffer) { 148 SkFlattenable* SkLayerRasterizer::CreateProc(SkReadBuffer& buffer) {
149 return new SkLayerRasterizer(ReadLayers(buffer)); 149 return new SkLayerRasterizer(ReadLayers(buffer));
(...skipping 15 matching lines...) Expand all
165 165
166 void SkLayerRasterizer::flatten(SkWriteBuffer& buffer) const { 166 void SkLayerRasterizer::flatten(SkWriteBuffer& buffer) const {
167 this->INHERITED::flatten(buffer); 167 this->INHERITED::flatten(buffer);
168 168
169 SkASSERT(fLayers); 169 SkASSERT(fLayers);
170 buffer.writeInt(fLayers->count()); 170 buffer.writeInt(fLayers->count());
171 171
172 SkDeque::F2BIter iter(*fLayers); 172 SkDeque::F2BIter iter(*fLayers);
173 const SkLayerRasterizer_Rec* rec; 173 const SkLayerRasterizer_Rec* rec;
174 174
175 while ((rec = (const SkLayerRasterizer_Rec*)iter.next()) != NULL) { 175 while ((rec = (const SkLayerRasterizer_Rec*)iter.next()) != nullptr) {
176 buffer.writePaint(rec->fPaint); 176 buffer.writePaint(rec->fPaint);
177 buffer.writePoint(rec->fOffset); 177 buffer.writePoint(rec->fOffset);
178 } 178 }
179 } 179 }
180 180
181 SkLayerRasterizer::Builder::Builder() : fLayers(new SkDeque(sizeof(SkLayerRaster izer_Rec))) {} 181 SkLayerRasterizer::Builder::Builder() : fLayers(new SkDeque(sizeof(SkLayerRaster izer_Rec))) {}
182 182
183 SkLayerRasterizer::Builder::~Builder() 183 SkLayerRasterizer::Builder::~Builder()
184 { 184 {
185 if (fLayers != NULL) { 185 if (fLayers != nullptr) {
186 clean_up_layers(fLayers); 186 clean_up_layers(fLayers);
187 } 187 }
188 } 188 }
189 189
190 void SkLayerRasterizer::Builder::addLayer(const SkPaint& paint, SkScalar dx, 190 void SkLayerRasterizer::Builder::addLayer(const SkPaint& paint, SkScalar dx,
191 SkScalar dy) { 191 SkScalar dy) {
192 SkASSERT(fLayers); 192 SkASSERT(fLayers);
193 SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)fLayers->push_back(); 193 SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)fLayers->push_back();
194 194
195 new (&rec->fPaint) SkPaint(paint); 195 new (&rec->fPaint) SkPaint(paint);
196 rec->fOffset.set(dx, dy); 196 rec->fOffset.set(dx, dy);
197 } 197 }
198 198
199 SkLayerRasterizer* SkLayerRasterizer::Builder::detachRasterizer() { 199 SkLayerRasterizer* SkLayerRasterizer::Builder::detachRasterizer() {
200 SkLayerRasterizer* rasterizer; 200 SkLayerRasterizer* rasterizer;
201 if (0 == fLayers->count()) { 201 if (0 == fLayers->count()) {
202 rasterizer = NULL; 202 rasterizer = nullptr;
203 delete fLayers; 203 delete fLayers;
204 } else { 204 } else {
205 rasterizer = new SkLayerRasterizer(fLayers); 205 rasterizer = new SkLayerRasterizer(fLayers);
206 } 206 }
207 fLayers = NULL; 207 fLayers = nullptr;
208 return rasterizer; 208 return rasterizer;
209 } 209 }
210 210
211 SkLayerRasterizer* SkLayerRasterizer::Builder::snapshotRasterizer() const { 211 SkLayerRasterizer* SkLayerRasterizer::Builder::snapshotRasterizer() const {
212 if (0 == fLayers->count()) { 212 if (0 == fLayers->count()) {
213 return NULL; 213 return nullptr;
214 } 214 }
215 SkDeque* layers = new SkDeque(sizeof(SkLayerRasterizer_Rec), fLayers->count( )); 215 SkDeque* layers = new SkDeque(sizeof(SkLayerRasterizer_Rec), fLayers->count( ));
216 SkDeque::F2BIter iter(*fLayers); 216 SkDeque::F2BIter iter(*fLayers);
217 const SkLayerRasterizer_Rec* recOrig; 217 const SkLayerRasterizer_Rec* recOrig;
218 SkDEBUGCODE(int count = 0;) 218 SkDEBUGCODE(int count = 0;)
219 while ((recOrig = static_cast<SkLayerRasterizer_Rec*>(iter.next())) != NULL) { 219 while ((recOrig = static_cast<SkLayerRasterizer_Rec*>(iter.next())) != nullp tr) {
220 SkDEBUGCODE(count++); 220 SkDEBUGCODE(count++);
221 SkLayerRasterizer_Rec* recCopy = static_cast<SkLayerRasterizer_Rec*>(lay ers->push_back()); 221 SkLayerRasterizer_Rec* recCopy = static_cast<SkLayerRasterizer_Rec*>(lay ers->push_back());
222 new (&recCopy->fPaint) SkPaint(recOrig->fPaint); 222 new (&recCopy->fPaint) SkPaint(recOrig->fPaint);
223 recCopy->fOffset = recOrig->fOffset; 223 recCopy->fOffset = recOrig->fOffset;
224 } 224 }
225 SkASSERT(fLayers->count() == count); 225 SkASSERT(fLayers->count() == count);
226 SkASSERT(layers->count() == count); 226 SkASSERT(layers->count() == count);
227 SkLayerRasterizer* rasterizer = new SkLayerRasterizer(layers); 227 SkLayerRasterizer* rasterizer = new SkLayerRasterizer(layers);
228 return rasterizer; 228 return rasterizer;
229 } 229 }
OLDNEW
« no previous file with comments | « src/effects/SkLayerDrawLooper.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698