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

Side by Side Diff: tools/render_pictures_main.cpp

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 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 | « tools/picture_utils.cpp ('k') | tools/skdiff_image.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 2012 Google Inc. 2 * Copyright 2012 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 "LazyDecodeBitmap.h" 8 #include "LazyDecodeBitmap.h"
9 #include "CopyTilesRenderer.h" 9 #include "CopyTilesRenderer.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 /** 139 /**
140 * Called only by render_picture(). 140 * Called only by render_picture().
141 */ 141 */
142 static bool render_picture_internal(const SkString& inputPath, const SkString* w ritePath, 142 static bool render_picture_internal(const SkString& inputPath, const SkString* w ritePath,
143 const SkString* mismatchPath, 143 const SkString* mismatchPath,
144 sk_tools::PictureRenderer& renderer, 144 sk_tools::PictureRenderer& renderer,
145 SkBitmap** out) { 145 SkBitmap** out) {
146 SkString inputFilename = SkOSPath::Basename(inputPath.c_str()); 146 SkString inputFilename = SkOSPath::Basename(inputPath.c_str());
147 SkString writePathString; 147 SkString writePathString;
148 if (NULL != writePath && writePath->size() > 0 && !FLAGS_writeEncodedImages) { 148 if (writePath && writePath->size() > 0 && !FLAGS_writeEncodedImages) {
149 writePathString.set(*writePath); 149 writePathString.set(*writePath);
150 } 150 }
151 SkString mismatchPathString; 151 SkString mismatchPathString;
152 if (NULL != mismatchPath && mismatchPath->size() > 0) { 152 if (mismatchPath && mismatchPath->size() > 0) {
153 mismatchPathString.set(*mismatchPath); 153 mismatchPathString.set(*mismatchPath);
154 } 154 }
155 155
156 SkFILEStream inputStream; 156 SkFILEStream inputStream;
157 inputStream.setPath(inputPath.c_str()); 157 inputStream.setPath(inputPath.c_str());
158 if (!inputStream.isValid()) { 158 if (!inputStream.isValid()) {
159 SkDebugf("Could not open file %s\n", inputPath.c_str()); 159 SkDebugf("Could not open file %s\n", inputPath.c_str());
160 return false; 160 return false;
161 } 161 }
162 162
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 SkDebugf("drawing... [%f %f %f %f] %s\n", 201 SkDebugf("drawing... [%f %f %f %f] %s\n",
202 picture->cullRect().fLeft, picture->cullRect().fTop, 202 picture->cullRect().fLeft, picture->cullRect().fTop,
203 picture->cullRect().fRight, picture->cullRect().fBottom, 203 picture->cullRect().fRight, picture->cullRect().fBottom,
204 inputPath.c_str()); 204 inputPath.c_str());
205 205
206 renderer.init(picture, &writePathString, &mismatchPathString, &inputFilename , 206 renderer.init(picture, &writePathString, &mismatchPathString, &inputFilename ,
207 FLAGS_writeChecksumBasedFilenames); 207 FLAGS_writeChecksumBasedFilenames);
208 208
209 if (FLAGS_preprocess) { 209 if (FLAGS_preprocess) {
210 if (NULL != renderer.getCanvas()) { 210 if (renderer.getCanvas()) {
211 renderer.getCanvas()->EXPERIMENTAL_optimize(renderer.getPicture()); 211 renderer.getCanvas()->EXPERIMENTAL_optimize(renderer.getPicture());
212 } 212 }
213 } 213 }
214 214
215 renderer.setup(); 215 renderer.setup();
216 renderer.enableWrites(); 216 renderer.enableWrites();
217 217
218 bool success = renderer.render(out); 218 bool success = renderer.render(out);
219 if (!success) { 219 if (!success) {
220 SkDebugf("Failed to render %s\n", inputFilename.c_str()); 220 SkDebugf("Failed to render %s\n", inputFilename.c_str());
(...skipping 22 matching lines...) Expand all
243 } 243 }
244 244
245 void set(sk_tools::PictureRenderer* renderer, 245 void set(sk_tools::PictureRenderer* renderer,
246 sk_tools::PictureRenderer::BBoxHierarchyType bbhType) { 246 sk_tools::PictureRenderer::BBoxHierarchyType bbhType) {
247 fRenderer = renderer; 247 fRenderer = renderer;
248 fSavedBbhType = renderer->getBBoxHierarchyType(); 248 fSavedBbhType = renderer->getBBoxHierarchyType();
249 renderer->setBBoxHierarchyType(bbhType); 249 renderer->setBBoxHierarchyType(bbhType);
250 } 250 }
251 251
252 ~AutoRestoreBbhType() { 252 ~AutoRestoreBbhType() {
253 if (NULL != fRenderer) { 253 if (fRenderer) {
254 fRenderer->setBBoxHierarchyType(fSavedBbhType); 254 fRenderer->setBBoxHierarchyType(fSavedBbhType);
255 } 255 }
256 } 256 }
257 257
258 private: 258 private:
259 sk_tools::PictureRenderer* fRenderer; 259 sk_tools::PictureRenderer* fRenderer;
260 sk_tools::PictureRenderer::BBoxHierarchyType fSavedBbhType; 260 sk_tools::PictureRenderer::BBoxHierarchyType fSavedBbhType;
261 }; 261 };
262 262
263 /** 263 /**
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } 362 }
363 363
364 if (FLAGS_writeWholeImage) { 364 if (FLAGS_writeWholeImage) {
365 sk_tools::force_all_opaque(*bitmap); 365 sk_tools::force_all_opaque(*bitmap);
366 366
367 SkString inputFilename = SkOSPath::Basename(inputPath.c_str()); 367 SkString inputFilename = SkOSPath::Basename(inputPath.c_str());
368 SkString outputFilename(inputFilename); 368 SkString outputFilename(inputFilename);
369 sk_tools::replace_char(&outputFilename, '.', '_'); 369 sk_tools::replace_char(&outputFilename, '.', '_');
370 outputFilename.append(".png"); 370 outputFilename.append(".png");
371 371
372 if (NULL != jsonSummaryPtr) { 372 if (jsonSummaryPtr) {
373 sk_tools::ImageDigest imageDigest(*bitmap); 373 sk_tools::ImageDigest imageDigest(*bitmap);
374 jsonSummaryPtr->add(inputFilename.c_str(), outputFilename.c_str(), i mageDigest); 374 jsonSummaryPtr->add(inputFilename.c_str(), outputFilename.c_str(), i mageDigest);
375 if ((NULL != mismatchPath) && !mismatchPath->isEmpty() && 375 if ((mismatchPath) && !mismatchPath->isEmpty() &&
376 !jsonSummaryPtr->getExpectation(inputFilename.c_str()).matches(i mageDigest)) { 376 !jsonSummaryPtr->getExpectation(inputFilename.c_str()).matches(i mageDigest)) {
377 success &= sk_tools::write_bitmap_to_disk(*bitmap, *mismatchPath , NULL, 377 success &= sk_tools::write_bitmap_to_disk(*bitmap, *mismatchPath , NULL,
378 outputFilename); 378 outputFilename);
379 } 379 }
380 } 380 }
381 381
382 if ((NULL != writePath) && !writePath->isEmpty()) { 382 if ((writePath) && !writePath->isEmpty()) {
383 success &= sk_tools::write_bitmap_to_disk(*bitmap, *writePath, NULL, outputFilename); 383 success &= sk_tools::write_bitmap_to_disk(*bitmap, *writePath, NULL, outputFilename);
384 } 384 }
385 } 385 }
386 SkDELETE(bitmap); 386 SkDELETE(bitmap);
387 387
388 return success; 388 return success;
389 } 389 }
390 390
391 391
392 static int process_input(const char* input, const SkString* writePath, 392 static int process_input(const char* input, const SkString* writePath,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); 511 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]);
512 } 512 }
513 return 0; 513 return 0;
514 } 514 }
515 515
516 #if !defined SK_BUILD_FOR_IOS 516 #if !defined SK_BUILD_FOR_IOS
517 int main(int argc, char * const argv[]) { 517 int main(int argc, char * const argv[]) {
518 return tool_main(argc, (char**) argv); 518 return tool_main(argc, (char**) argv);
519 } 519 }
520 #endif 520 #endif
OLDNEW
« no previous file with comments | « tools/picture_utils.cpp ('k') | tools/skdiff_image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698