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

Side by Side Diff: tools/render_pictures_main.cpp

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 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 | « tools/render_pdfs_main.cpp ('k') | tools/sk_tool_utils_font.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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 SkBitmap* bitmap = NULL; 266 SkBitmap* bitmap = NULL;
267 renderer.setJsonSummaryPtr(jsonSummaryPtr); 267 renderer.setJsonSummaryPtr(jsonSummaryPtr);
268 bool success = render_picture_internal(inputPath, 268 bool success = render_picture_internal(inputPath,
269 FLAGS_writeWholeImage ? NULL : writePath, 269 FLAGS_writeWholeImage ? NULL : writePath,
270 FLAGS_writeWholeImage ? NULL : mismatchPath, 270 FLAGS_writeWholeImage ? NULL : mismatchPath,
271 renderer, 271 renderer,
272 FLAGS_validate || FLAGS_writeWholeImage ? &bitmap : NULL); 272 FLAGS_validate || FLAGS_writeWholeImage ? &bitmap : NULL);
273 273
274 if (!success || ((FLAGS_validate || FLAGS_writeWholeImage) && bitmap == NULL )) { 274 if (!success || ((FLAGS_validate || FLAGS_writeWholeImage) && bitmap == NULL )) {
275 SkDebugf("Failed to draw the picture.\n"); 275 SkDebugf("Failed to draw the picture.\n");
276 SkDELETE(bitmap); 276 delete bitmap;
277 return false; 277 return false;
278 } 278 }
279 279
280 if (FLAGS_validate) { 280 if (FLAGS_validate) {
281 SkBitmap* referenceBitmap = NULL; 281 SkBitmap* referenceBitmap = NULL;
282 sk_tools::PictureRenderer* referenceRenderer; 282 sk_tools::PictureRenderer* referenceRenderer;
283 // If the renderer uses a BBoxHierarchy, then the reference renderer 283 // If the renderer uses a BBoxHierarchy, then the reference renderer
284 // will be the same renderer, without the bbh. 284 // will be the same renderer, without the bbh.
285 AutoRestoreBbhType arbbh; 285 AutoRestoreBbhType arbbh;
286 if (sk_tools::PictureRenderer::kNone_BBoxHierarchyType != 286 if (sk_tools::PictureRenderer::kNone_BBoxHierarchyType !=
287 renderer.getBBoxHierarchyType()) { 287 renderer.getBBoxHierarchyType()) {
288 referenceRenderer = &renderer; 288 referenceRenderer = &renderer;
289 referenceRenderer->ref(); // to match auto unref below 289 referenceRenderer->ref(); // to match auto unref below
290 arbbh.set(referenceRenderer, sk_tools::PictureRenderer::kNone_BBoxHi erarchyType); 290 arbbh.set(referenceRenderer, sk_tools::PictureRenderer::kNone_BBoxHi erarchyType);
291 } else { 291 } else {
292 #if SK_SUPPORT_GPU 292 #if SK_SUPPORT_GPU
293 referenceRenderer = SkNEW_ARGS(sk_tools::SimplePictureRenderer, 293 referenceRenderer = new sk_tools::SimplePictureRenderer(renderer.get GrContextOptions());
294 (renderer.getGrContextOptions()));
295 #else 294 #else
296 referenceRenderer = SkNEW(sk_tools::SimplePictureRenderer); 295 referenceRenderer = new sk_tools::SimplePictureRenderer;
297 #endif 296 #endif
298 } 297 }
299 SkAutoTUnref<sk_tools::PictureRenderer> aurReferenceRenderer(referenceRe nderer); 298 SkAutoTUnref<sk_tools::PictureRenderer> aurReferenceRenderer(referenceRe nderer);
300 299
301 success = render_picture_internal(inputPath, NULL, NULL, *referenceRende rer, 300 success = render_picture_internal(inputPath, NULL, NULL, *referenceRende rer,
302 &referenceBitmap); 301 &referenceBitmap);
303 302
304 if (!success || NULL == referenceBitmap || NULL == referenceBitmap->getP ixels()) { 303 if (!success || NULL == referenceBitmap || NULL == referenceBitmap->getP ixels()) {
305 SkDebugf("Failed to draw the reference picture.\n"); 304 SkDebugf("Failed to draw the reference picture.\n");
306 SkDELETE(bitmap); 305 delete bitmap;
307 SkDELETE(referenceBitmap); 306 delete referenceBitmap;
308 return false; 307 return false;
309 } 308 }
310 309
311 if (success && (bitmap->width() != referenceBitmap->width())) { 310 if (success && (bitmap->width() != referenceBitmap->width())) {
312 SkDebugf("Expected image width: %i, actual image width %i.\n", 311 SkDebugf("Expected image width: %i, actual image width %i.\n",
313 referenceBitmap->width(), bitmap->width()); 312 referenceBitmap->width(), bitmap->width());
314 SkDELETE(bitmap); 313 delete bitmap;
315 SkDELETE(referenceBitmap); 314 delete referenceBitmap;
316 return false; 315 return false;
317 } 316 }
318 if (success && (bitmap->height() != referenceBitmap->height())) { 317 if (success && (bitmap->height() != referenceBitmap->height())) {
319 SkDebugf("Expected image height: %i, actual image height %i", 318 SkDebugf("Expected image height: %i, actual image height %i",
320 referenceBitmap->height(), bitmap->height()); 319 referenceBitmap->height(), bitmap->height());
321 SkDELETE(bitmap); 320 delete bitmap;
322 SkDELETE(referenceBitmap); 321 delete referenceBitmap;
323 return false; 322 return false;
324 } 323 }
325 324
326 for (int y = 0; success && y < bitmap->height(); y++) { 325 for (int y = 0; success && y < bitmap->height(); y++) {
327 for (int x = 0; success && x < bitmap->width(); x++) { 326 for (int x = 0; success && x < bitmap->width(); x++) {
328 int diff = MaxByteDiff(*referenceBitmap->getAddr32(x, y), 327 int diff = MaxByteDiff(*referenceBitmap->getAddr32(x, y),
329 *bitmap->getAddr32(x, y)); 328 *bitmap->getAddr32(x, y));
330 SkASSERT(diff >= 0 && diff <= 255); 329 SkASSERT(diff >= 0 && diff <= 255);
331 diffs[diff]++; 330 diffs[diff]++;
332 331
333 if (diff > FLAGS_maxComponentDiff) { 332 if (diff > FLAGS_maxComponentDiff) {
334 SkDebugf("Expected pixel at (%i %i) exceedds maximum " 333 SkDebugf("Expected pixel at (%i %i) exceedds maximum "
335 "component diff of %i: 0x%x, actual 0x%x\n", 334 "component diff of %i: 0x%x, actual 0x%x\n",
336 x, y, FLAGS_maxComponentDiff, 335 x, y, FLAGS_maxComponentDiff,
337 *referenceBitmap->getAddr32(x, y), 336 *referenceBitmap->getAddr32(x, y),
338 *bitmap->getAddr32(x, y)); 337 *bitmap->getAddr32(x, y));
339 SkDELETE(bitmap); 338 delete bitmap;
340 SkDELETE(referenceBitmap); 339 delete referenceBitmap;
341 return false; 340 return false;
342 } 341 }
343 } 342 }
344 } 343 }
345 SkDELETE(referenceBitmap); 344 delete referenceBitmap;
346 345
347 for (int i = 1; i <= 255; ++i) { 346 for (int i = 1; i <= 255; ++i) {
348 if(diffs[i] > 0) { 347 if(diffs[i] > 0) {
349 SkDebugf("Number of pixels with max diff of %i is %i\n", i, diff s[i]); 348 SkDebugf("Number of pixels with max diff of %i is %i\n", i, diff s[i]);
350 } 349 }
351 } 350 }
352 } 351 }
353 352
354 if (FLAGS_writeWholeImage) { 353 if (FLAGS_writeWholeImage) {
355 sk_tools::force_all_opaque(*bitmap); 354 sk_tools::force_all_opaque(*bitmap);
(...skipping 10 matching lines...) Expand all
366 !jsonSummaryPtr->getExpectation(inputFilename.c_str()).matches(i mageDigest)) { 365 !jsonSummaryPtr->getExpectation(inputFilename.c_str()).matches(i mageDigest)) {
367 success &= sk_tools::write_bitmap_to_disk(*bitmap, *mismatchPath , NULL, 366 success &= sk_tools::write_bitmap_to_disk(*bitmap, *mismatchPath , NULL,
368 outputFilename); 367 outputFilename);
369 } 368 }
370 } 369 }
371 370
372 if ((writePath) && !writePath->isEmpty()) { 371 if ((writePath) && !writePath->isEmpty()) {
373 success &= sk_tools::write_bitmap_to_disk(*bitmap, *writePath, NULL, outputFilename); 372 success &= sk_tools::write_bitmap_to_disk(*bitmap, *writePath, NULL, outputFilename);
374 } 373 }
375 } 374 }
376 SkDELETE(bitmap); 375 delete bitmap;
377 376
378 return success; 377 return success;
379 } 378 }
380 379
381 380
382 static int process_input(const char* input, const SkString* writePath, 381 static int process_input(const char* input, const SkString* writePath,
383 const SkString* mismatchPath, sk_tools::PictureRenderer & renderer, 382 const SkString* mismatchPath, sk_tools::PictureRenderer & renderer,
384 sk_tools::ImageResultsAndExpectations *jsonSummaryPtr) { 383 sk_tools::ImageResultsAndExpectations *jsonSummaryPtr) {
385 SkOSFile::Iter iter(input, "skp"); 384 SkOSFile::Iter iter(input, "skp");
386 SkString inputFilename; 385 SkString inputFilename;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); 502 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]);
504 } 503 }
505 return 0; 504 return 0;
506 } 505 }
507 506
508 #if !defined SK_BUILD_FOR_IOS 507 #if !defined SK_BUILD_FOR_IOS
509 int main(int argc, char * const argv[]) { 508 int main(int argc, char * const argv[]) {
510 return tool_main(argc, (char**) argv); 509 return tool_main(argc, (char**) argv);
511 } 510 }
512 #endif 511 #endif
OLDNEW
« no previous file with comments | « tools/render_pdfs_main.cpp ('k') | tools/sk_tool_utils_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698