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

Side by Side Diff: samplecode/SamplePictFile.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 | « samplecode/SamplePdfFileViewer.cpp ('k') | samplecode/SamplePicture.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkDumpCanvas.h" 9 #include "SkDumpCanvas.h"
10 #include "SkView.h" 10 #include "SkView.h"
(...skipping 28 matching lines...) Expand all
39 39
40 bool filter(SkPaint*, Type t) override { 40 bool filter(SkPaint*, Type t) override {
41 return --fCount >= 0; 41 return --fCount >= 0;
42 } 42 }
43 43
44 int fCount; 44 int fCount;
45 }; 45 };
46 46
47 class PictFileView : public SampleView { 47 class PictFileView : public SampleView {
48 public: 48 public:
49 PictFileView(const char name[] = NULL) 49 PictFileView(const char name[] = nullptr)
50 : fFilename(name) 50 : fFilename(name)
51 , fBBox(kNo_BBoxType) 51 , fBBox(kNo_BBoxType)
52 , fTileSize(SkSize::Make(0, 0)) { 52 , fTileSize(SkSize::Make(0, 0)) {
53 for (int i = 0; i < kBBoxTypeCount; ++i) { 53 for (int i = 0; i < kBBoxTypeCount; ++i) {
54 fPictures[i] = NULL; 54 fPictures[i] = nullptr;
55 } 55 }
56 fCount = 0; 56 fCount = 0;
57 } 57 }
58 58
59 virtual ~PictFileView() { 59 virtual ~PictFileView() {
60 for (int i = 0; i < kBBoxTypeCount; ++i) { 60 for (int i = 0; i < kBBoxTypeCount; ++i) {
61 SkSafeUnref(fPictures[i]); 61 SkSafeUnref(fPictures[i]);
62 } 62 }
63 } 63 }
64 64
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 if (!*picture) { 120 if (!*picture) {
121 *picture = LoadPicture(fFilename.c_str(), fBBox); 121 *picture = LoadPicture(fFilename.c_str(), fBBox);
122 } 122 }
123 if (*picture) { 123 if (*picture) {
124 SkCounterDrawFilter filter(fCount); 124 SkCounterDrawFilter filter(fCount);
125 if (fCount > 0) { 125 if (fCount > 0) {
126 canvas->setDrawFilter(&filter); 126 canvas->setDrawFilter(&filter);
127 } 127 }
128 canvas->drawPicture(*picture); 128 canvas->drawPicture(*picture);
129 canvas->setDrawFilter(NULL); 129 canvas->setDrawFilter(nullptr);
130 } 130 }
131 131
132 #ifdef SK_GLYPHCACHE_TRACK_HASH_STATS 132 #ifdef SK_GLYPHCACHE_TRACK_HASH_STATS
133 SkGlyphCache::Dump(); 133 SkGlyphCache::Dump();
134 SkDebugf("\n"); 134 SkDebugf("\n");
135 #endif 135 #endif
136 } 136 }
137 137
138 private: 138 private:
139 enum BBoxType { 139 enum BBoxType {
(...skipping 12 matching lines...) Expand all
152 152
153 SkPicture* LoadPicture(const char path[], BBoxType bbox) { 153 SkPicture* LoadPicture(const char path[], BBoxType bbox) {
154 SkAutoTUnref<SkPicture> pic; 154 SkAutoTUnref<SkPicture> pic;
155 155
156 SkBitmap bm; 156 SkBitmap bm;
157 if (SkImageDecoder::DecodeFile(path, &bm)) { 157 if (SkImageDecoder::DecodeFile(path, &bm)) {
158 bm.setImmutable(); 158 bm.setImmutable();
159 SkPictureRecorder recorder; 159 SkPictureRecorder recorder;
160 SkCanvas* can = recorder.beginRecording(SkIntToScalar(bm.width()), 160 SkCanvas* can = recorder.beginRecording(SkIntToScalar(bm.width()),
161 SkIntToScalar(bm.height()), 161 SkIntToScalar(bm.height()),
162 NULL, 0); 162 nullptr, 0);
163 can->drawBitmap(bm, 0, 0, NULL); 163 can->drawBitmap(bm, 0, 0, nullptr);
164 pic.reset(recorder.endRecording()); 164 pic.reset(recorder.endRecording());
165 } else { 165 } else {
166 SkFILEStream stream(path); 166 SkFILEStream stream(path);
167 if (stream.isValid()) { 167 if (stream.isValid()) {
168 pic.reset(SkPicture::CreateFromStream(&stream)); 168 pic.reset(SkPicture::CreateFromStream(&stream));
169 } else { 169 } else {
170 SkDebugf("coun't load picture at \"path\"\n", path); 170 SkDebugf("coun't load picture at \"path\"\n", path);
171 } 171 }
172 172
173 if (false) { // re-record 173 if (false) { // re-record
174 SkPictureRecorder recorder; 174 SkPictureRecorder recorder;
175 pic->playback(recorder.beginRecording(pic->cullRect().width(), 175 pic->playback(recorder.beginRecording(pic->cullRect().width(),
176 pic->cullRect().height(), 176 pic->cullRect().height(),
177 NULL, 0)); 177 nullptr, 0));
178 SkAutoTUnref<SkPicture> p2(recorder.endRecording()); 178 SkAutoTUnref<SkPicture> p2(recorder.endRecording());
179 179
180 SkString path2(path); 180 SkString path2(path);
181 path2.append(".new.skp"); 181 path2.append(".new.skp");
182 SkFILEWStream writer(path2.c_str()); 182 SkFILEWStream writer(path2.c_str());
183 p2->serialize(&writer); 183 p2->serialize(&writer);
184 } 184 }
185 } 185 }
186 186
187 if (NULL == pic) { 187 if (nullptr == pic) {
188 return NULL; 188 return nullptr;
189 } 189 }
190 190
191 SkAutoTDelete<SkBBHFactory> factory; 191 SkAutoTDelete<SkBBHFactory> factory;
192 switch (bbox) { 192 switch (bbox) {
193 case kNo_BBoxType: 193 case kNo_BBoxType:
194 // no bbox playback necessary 194 // no bbox playback necessary
195 return pic.detach(); 195 return pic.detach();
196 case kRTree_BBoxType: 196 case kRTree_BBoxType:
197 factory.reset(new SkRTreeFactory); 197 factory.reset(new SkRTreeFactory);
198 break; 198 break;
(...skipping 15 matching lines...) Expand all
214 SampleView* CreateSamplePictFileView(const char filename[]) { 214 SampleView* CreateSamplePictFileView(const char filename[]) {
215 return new PictFileView(filename); 215 return new PictFileView(filename);
216 } 216 }
217 217
218 ////////////////////////////////////////////////////////////////////////////// 218 //////////////////////////////////////////////////////////////////////////////
219 219
220 #if 0 220 #if 0
221 static SkView* MyFactory() { return new PictFileView; } 221 static SkView* MyFactory() { return new PictFileView; }
222 static SkViewRegister reg(MyFactory); 222 static SkViewRegister reg(MyFactory);
223 #endif 223 #endif
OLDNEW
« no previous file with comments | « samplecode/SamplePdfFileViewer.cpp ('k') | samplecode/SamplePicture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698