| OLD | NEW |
| 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 "PictureRenderer.h" | 8 #include "PictureRenderer.h" |
| 9 #include "picture_utils.h" | 9 #include "picture_utils.h" |
| 10 #include "SamplePipeControllers.h" | 10 #include "SamplePipeControllers.h" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 BitmapAndDigest bitmapAndDigest(bitmap); | 290 BitmapAndDigest bitmapAndDigest(bitmap); |
| 291 | 291 |
| 292 SkString escapedInputFilename(inputFilename); | 292 SkString escapedInputFilename(inputFilename); |
| 293 replace_char(&escapedInputFilename, '.', '_'); | 293 replace_char(&escapedInputFilename, '.', '_'); |
| 294 | 294 |
| 295 // TODO(epoger): what about including the config type within outputFilename?
That way, | 295 // TODO(epoger): what about including the config type within outputFilename?
That way, |
| 296 // we could combine results of different config types without conflicting fi
lenames. | 296 // we could combine results of different config types without conflicting fi
lenames. |
| 297 SkString outputFilename; | 297 SkString outputFilename; |
| 298 const char *outputSubdirPtr = NULL; | 298 const char *outputSubdirPtr = NULL; |
| 299 if (useChecksumBasedFilenames) { | 299 if (useChecksumBasedFilenames) { |
| 300 const ImageDigest *imageDigestPtr = bitmapAndDigest.getImageDigestPtr(); | 300 ImageDigest *imageDigestPtr = bitmapAndDigest.getImageDigestPtr(); |
| 301 outputSubdirPtr = escapedInputFilename.c_str(); | 301 outputSubdirPtr = escapedInputFilename.c_str(); |
| 302 outputFilename.set(imageDigestPtr->getHashType()); | 302 outputFilename.set(imageDigestPtr->getHashType()); |
| 303 outputFilename.append("_"); | 303 outputFilename.append("_"); |
| 304 outputFilename.appendU64(imageDigestPtr->getHashValue()); | 304 outputFilename.appendU64(imageDigestPtr->getHashValue()); |
| 305 } else { | 305 } else { |
| 306 outputFilename.set(escapedInputFilename); | 306 outputFilename.set(escapedInputFilename); |
| 307 if (NULL != tileNumberPtr) { | 307 if (NULL != tileNumberPtr) { |
| 308 outputFilename.append("-tile"); | 308 outputFilename.append("-tile"); |
| 309 outputFilename.appendS32(*tileNumberPtr); | 309 outputFilename.appendS32(*tileNumberPtr); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 outputFilename.append(".png"); | 312 outputFilename.append(".png"); |
| 313 | 313 |
| 314 if (NULL != jsonSummaryPtr) { | 314 if (NULL != jsonSummaryPtr) { |
| 315 const ImageDigest *imageDigestPtr = bitmapAndDigest.getImageDigestPtr(); | 315 ImageDigest *imageDigestPtr = bitmapAndDigest.getImageDigestPtr(); |
| 316 SkString outputRelativePath; | 316 SkString outputRelativePath; |
| 317 if (outputSubdirPtr) { | 317 if (outputSubdirPtr) { |
| 318 outputRelativePath.set(outputSubdirPtr); | 318 outputRelativePath.set(outputSubdirPtr); |
| 319 outputRelativePath.append("/"); // always use "/", even on Windows | 319 outputRelativePath.append("/"); // always use "/", even on Windows |
| 320 outputRelativePath.append(outputFilename); | 320 outputRelativePath.append(outputFilename); |
| 321 } else { | 321 } else { |
| 322 outputRelativePath.set(outputFilename); | 322 outputRelativePath.set(outputFilename); |
| 323 } | 323 } |
| 324 | 324 |
| 325 jsonSummaryPtr->add(inputFilename.c_str(), outputRelativePath.c_str(), | 325 jsonSummaryPtr->add(inputFilename.c_str(), outputRelativePath.c_str(), |
| 326 *imageDigestPtr, tileNumberPtr); | 326 *imageDigestPtr, tileNumberPtr); |
| 327 if (!mismatchPath.isEmpty() && | 327 if (!mismatchPath.isEmpty() && |
| 328 !jsonSummaryPtr->matchesExpectation(inputFilename.c_str(), *imageDig
estPtr, | 328 !jsonSummaryPtr->getExpectation(inputFilename.c_str(), |
| 329 tileNumberPtr)) { | 329 tileNumberPtr).matches(*imageDigestP
tr)) { |
| 330 if (!write_bitmap_to_disk(bitmap, mismatchPath, outputSubdirPtr, out
putFilename)) { | 330 if (!write_bitmap_to_disk(bitmap, mismatchPath, outputSubdirPtr, out
putFilename)) { |
| 331 return false; | 331 return false; |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 | 335 |
| 336 if (writePath.isEmpty()) { | 336 if (writePath.isEmpty()) { |
| 337 return true; | 337 return true; |
| 338 } else { | 338 } else { |
| 339 return write_bitmap_to_disk(bitmap, writePath, outputSubdirPtr, outputFi
lename); | 339 return write_bitmap_to_disk(bitmap, writePath, outputSubdirPtr, outputFi
lename); |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options& opts) { | 776 PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options& opts) { |
| 777 return SkNEW_ARGS(GatherRenderer, (opts)); | 777 return SkNEW_ARGS(GatherRenderer, (opts)); |
| 778 } | 778 } |
| 779 #else | 779 #else |
| 780 PictureRenderer* CreateGatherPixelRefsRenderer() { | 780 PictureRenderer* CreateGatherPixelRefsRenderer() { |
| 781 return SkNEW(GatherRenderer); | 781 return SkNEW(GatherRenderer); |
| 782 } | 782 } |
| 783 #endif | 783 #endif |
| 784 | 784 |
| 785 } // namespace sk_tools | 785 } // namespace sk_tools |
| OLD | NEW |