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

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: 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..cb69e1e81ac81e9fdd66c4393ba58a8f92306268 100644
--- a/tools/skimage_main.cpp
+++ b/tools/skimage_main.cpp
@@ -299,21 +299,33 @@ 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);
+ // 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())) {
epoger 2013/05/09 17:45:40 What happens if the mkdir fails? Does it pretend
scroggo 2013/05/13 17:34:12 Now it will provide an error.
+ // 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());
+ SkDEBUGCODE(bool success =)
+ write_bitmap(outPath.c_str(), &bitmapFromDecodeSubset);
epoger 2013/05/09 17:45:40 Instead of the 3 lines, I think you can do it like
scroggo 2013/05/13 17:34:12 Done.
SkASSERT(success);
+ 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());
+ SkDEBUGCODE(success =)
+ write_bitmap(outPath.c_str(), &extractedSubset);
+ SkASSERT(success);
+ }
+ }
}
}
} else {
« 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