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

Unified Diff: tools/skimage_main.cpp

Issue 14672017: Use separate subset directories in skimage. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Respond to comments Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/skimage_main.cpp
diff --git a/tools/skimage_main.cpp b/tools/skimage_main.cpp
index 2041f7bbcc5a4991fc81791519b65f4de86ea068..e3a1c86543eddaa6494972e794b4bf6bdc5c3053 100644
--- a/tools/skimage_main.cpp
+++ b/tools/skimage_main.cpp
@@ -299,25 +299,55 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath)
write_expectations(bitmapFromDecodeSubset, subsetName.c_str());
if (writePath != NULL) {
- // Write the region to a file whose name includes the dimensions.
- SkString suffix = SkStringPrintf("_%s.png", subsetDim.c_str());
- SkString outPath;
- make_outname(&outPath, writePath->c_str(), srcPath, suffix.c_str());
- SkDEBUGCODE(bool success =)
- write_bitmap(outPath.c_str(), &bitmapFromDecodeSubset);
- SkASSERT(success);
- gSuccessfulSubsetDecodes.push_back().printf("\twrote %s", outPath.c_str());
- // Also use extractSubset from the original for visual comparison.
- SkBitmap extractedSubset;
- if (bitmap.extractSubset(&extractedSubset, rect)) {
- suffix.printf("_%s_extracted.png", subsetDim.c_str());
- make_outname(&outPath, writePath->c_str(), srcPath, suffix.c_str());
- SkDEBUGCODE(success =) write_bitmap(outPath.c_str(), &extractedSubset);
- SkASSERT(success);
+ // Create a subdirectory to hold the results of decodeSubset.
+ SkString dir(*writePath);
+ dir.appendf("%s%c", "subsets", SkPATH_SEPARATOR);
+ if (sk_mkdir(dir.c_str())) {
+ // Write the subset to a file whose name includes the dimensions.
+ SkString suffix = SkStringPrintf("_%s.png", subsetDim.c_str());
+ SkString outPath;
+ make_outname(&outPath, dir.c_str(), srcPath, suffix.c_str());
+ SkAssertResult(write_bitmap(outPath.c_str(), &bitmapFromDecodeSubset));
+ gSuccessfulSubsetDecodes.push_back().printf("\twrote %s",
+ outPath.c_str());
+ // Also use extractSubset from the original for visual comparison.
+ // Write the result to a file in a separate subdirectory.
+ SkBitmap extractedSubset;
+ if (bitmap.extractSubset(&extractedSubset, rect)) {
+ SkString dirExtracted(*writePath);
+ dirExtracted.appendf("%s%c", "extracted", SkPATH_SEPARATOR);
+ if (sk_mkdir(dirExtracted.c_str())) {
+ make_outname(&outPath, dirExtracted.c_str(), srcPath,
+ suffix.c_str());
+ SkAssertResult(write_bitmap(outPath.c_str(),
+ &extractedSubset));
+ } else {
+ gFailedSubsetDecodes.push_back().printf("Successfully decoded "
+ "%s from %s, but "
+ "failed to create a "
+ "directory for "
+ "extractSubset "
+ "comparison.",
+ subsetDim.c_str(),
+ filename);
+ }
+ } else {
+ gFailedSubsetDecodes.push_back().printf("Successfully decoded %s "
+ "from %s, but failed to "
+ "extract a similar subset "
+ "for comparison.",
+ subsetDim.c_str(),
+ filename);
+ }
+ } else {
+ gFailedSubsetDecodes.push_back().printf("Successfully decoded %s from "
epoger 2013/05/14 15:50:31 As we've discussed before, I think it's a lot clea
scroggo 2013/05/14 20:13:13 Done.
+ "%s, but failed to create a "
+ "directory to write to.",
+ subsetDim.c_str(), filename);
}
}
} else {
- gFailedSubsetDecodes.push_back().printf("Failed to decode region %s from %s\n",
+ gFailedSubsetDecodes.push_back().printf("Failed to decode region %s from %s",
subsetDim.c_str(), srcPath);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698