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

Unified Diff: gm/gmmain.cpp

Issue 17365002: GM: add --writeChecksumBasedFilenames option (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: assembling_correct_path_but_need_mkdirs Created 7 years, 6 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 | « gm/gm_expectations.cpp ('k') | gm/tests/outputs/checksum-based-filenames/output-expected/command_line » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gmmain.cpp
===================================================================
--- gm/gmmain.cpp (revision 9460)
+++ gm/gmmain.cpp (working copy)
@@ -188,7 +188,8 @@
class GMMain {
public:
- GMMain() : fUseFileHierarchy(false), fIgnorableErrorTypes(kDefaultIgnorableErrorTypes),
+ GMMain() : fUseFileHierarchy(false), fWriteChecksumBasedFilenames(false),
+ fIgnorableErrorTypes(kDefaultIgnorableErrorTypes),
fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {}
/**
@@ -225,6 +226,31 @@
return SkOSPath::SkPathJoin(path, filename.c_str());
}
+ /**
+ * Assemble filename suitable for writing out an SkBitmap.
+ */
+ SkString make_bitmap_filename(const char *path,
+ const char *shortName,
+ const char *configName,
+ const char *renderModeDescriptor,
+ const GmResultDigest &bitmapDigest) {
+ if (fWriteChecksumBasedFilenames) {
epoger 2013/06/18 06:58:38 At patchset 3, we are assembling the desired outpu
+ SkString completePath(path);
+ completePath.appendUnichar(SkPATH_SEPARATOR);
+ completePath.append(bitmapDigest.getHashType());
+ completePath.appendUnichar(SkPATH_SEPARATOR);
+ completePath.append(shortName);
+ completePath.appendUnichar(SkPATH_SEPARATOR);
+ completePath.append(bitmapDigest.getDigestValue());
+ completePath.appendUnichar('.');
+ completePath.append(kPNG_FileExtension);
+ return completePath;
+ } else {
+ return make_filename(path, shortName, configName, renderModeDescriptor,
+ kPNG_FileExtension);
+ }
+ }
+
/* since PNG insists on unpremultiplying our alpha, we take no
precision chances and force all pixels to be 100% opaque,
otherwise on compare we may not get a perfect match.
@@ -253,6 +279,8 @@
}
}
+ // EPOGER: make sure to create any directories needed along the path
+ // EPOGER: make sure this works even if the destination file already exists -- just overwrite it
static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) {
// TODO(epoger): Now that we have removed force_all_opaque()
// from this method, we should be able to get rid of the
@@ -635,6 +663,7 @@
ErrorCombination write_reference_image(const ConfigData& gRec, const char writePath [],
const char renderModeDescriptor [],
const char *shortName, SkBitmap& bitmap,
+ GmResultDigest& bitmapDigest,
SkDynamicMemoryWStream* document) {
SkString path;
bool success = false;
@@ -642,8 +671,8 @@
gRec.fBackend == kGPU_Backend ||
(gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) {
- path = make_filename(writePath, shortName, gRec.fName, renderModeDescriptor,
- kPNG_FileExtension);
+ path = make_bitmap_filename(writePath, shortName, gRec.fName, renderModeDescriptor,
+ bitmapDigest);
success = write_bitmap(path, bitmap);
}
if (kPDF_Backend == gRec.fBackend) {
@@ -741,6 +770,7 @@
*
* @param expectations what expectations to compare actualBitmap against
* @param actualBitmap the image we actually generated
+ * @param actualResultDigest GmResultDigest of actualBitmap
* @param shortName name of test, e.g. "selftest1"
* @param configName name of config, e.g. "8888"
* @param renderModeDescriptor e.g., "-rtree", "-deferred"
@@ -753,11 +783,11 @@
*/
ErrorCombination compare_to_expectations(Expectations expectations,
const SkBitmap& actualBitmap,
+ const GmResultDigest& actualResultDigest,
const char *shortName, const char *configName,
const char *renderModeDescriptor,
bool addToJsonSummary) {
ErrorCombination errors;
- GmResultDigest actualResultDigest(actualBitmap);
SkString shortNamePlusConfig = make_shortname_plus_config(shortName, configName);
SkString completeNameString(shortNamePlusConfig);
completeNameString.append(renderModeDescriptor);
@@ -780,9 +810,8 @@
// Write out the "actuals" for any mismatches, if we have
// been directed to do so.
if (fMismatchPath) {
- SkString path =
- make_filename(fMismatchPath, shortName, configName, renderModeDescriptor,
- kPNG_FileExtension);
+ SkString path = make_bitmap_filename(fMismatchPath, shortName, configName,
+ renderModeDescriptor, actualResultDigest);
write_bitmap(path, actualBitmap);
}
@@ -871,6 +900,7 @@
GM* gm, const ConfigData& gRec, const char writePath[],
SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) {
+ GmResultDigest actualResultDigest(actualBitmap);
SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName(), gRec.fName);
SkString nameWithExtension(shortNamePlusConfig);
nameWithExtension.append(".");
@@ -893,12 +923,11 @@
* See comments above complete_bitmap() for more detail.
*/
Expectations expectations = expectationsSource->get(nameWithExtension.c_str());
- errors.add(compare_to_expectations(expectations, actualBitmap,
+ errors.add(compare_to_expectations(expectations, actualBitmap, actualResultDigest,
gm->shortName(), gRec.fName, "", true));
} else {
// If we are running without expectations, we still want to
// record the actual results.
- GmResultDigest actualResultDigest(actualBitmap);
add_actual_results_to_json_summary(nameWithExtension.c_str(), actualResultDigest,
ErrorCombination(kMissingExpectations_ErrorType),
false);
@@ -912,7 +941,7 @@
// renderModes of all tests! That would be a lot of files.
if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
errors.add(write_reference_image(gRec, writePath, "", gm->shortName(),
- actualBitmap, pdf));
+ actualBitmap, actualResultDigest, pdf));
}
return errors;
@@ -933,7 +962,8 @@
SkASSERT(referenceBitmap);
Expectations expectations(*referenceBitmap);
- return compare_to_expectations(expectations, actualBitmap, shortName,
+ GmResultDigest actualResultDigest(actualBitmap);
+ return compare_to_expectations(expectations, actualBitmap, actualResultDigest, shortName,
configName, renderModeDescriptor, false);
}
@@ -1143,7 +1173,7 @@
// They are public for now, to allow easier setting by tool_main().
//
- bool fUseFileHierarchy;
+ bool fUseFileHierarchy, fWriteChecksumBasedFilenames;
ErrorCombination fIgnorableErrorTypes;
const char* fMismatchPath;
@@ -1303,9 +1333,11 @@
DEFINE_bool(tileGrid, true, "Exercise the tile grid variant of SkPicture.");
DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point scale "
"factors to be used for tileGrid playback testing. Default value: 1.0");
-DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary to this file.");
DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more info about "
"each test).");
+DEFINE_bool(writeChecksumBasedFilenames, false, "When writing out actual images, use checksum-"
+ "based filenames, as rebaseline.py will use when downloading them from Google Storage");
+DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary to this file.");
DEFINE_string2(writePath, w, "", "Write rendered images into this directory.");
DEFINE_string2(writePicturePath, p, "", "Write .skp files into this directory.");
DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, "
@@ -1762,6 +1794,7 @@
SkCommandLineFlags::Parse(argc, argv);
gmmain.fUseFileHierarchy = FLAGS_hierarchy;
+ gmmain.fWriteChecksumBasedFilenames = FLAGS_writeChecksumBasedFilenames;
if (FLAGS_mismatchPath.count() == 1) {
gmmain.fMismatchPath = FLAGS_mismatchPath[0];
}
« no previous file with comments | « gm/gm_expectations.cpp ('k') | gm/tests/outputs/checksum-based-filenames/output-expected/command_line » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698