#include "picture_utils.h"
// Flags used by this file, alphabetically:
-DEFINE_int32(clone, 0, "Clone the picture n times before rendering.");
+DEFINE_bool(bench_record, false, "If true, drop into an infinite loop of recording the picture.");
DECLARE_bool(deferImageDecoding);
+DEFINE_string(descriptions, "", "one or more key=value pairs to add to the descriptions section "
+ "of the JSON summary.");
DEFINE_int32(maxComponentDiff, 256, "Maximum diff on a component, 0 - 256. Components that differ "
"by more than this amount are considered errors, though all diffs are reported. "
"Requires --validate.");
DEFINE_string(mismatchPath, "", "Write images for tests that failed due to "
"pixel mismatches into this directory.");
+DEFINE_bool(preprocess, false, "If true, perform device specific preprocessing before rendering.");
DEFINE_string(readJsonSummaryPath, "", "JSON file to read image expectations from.");
DECLARE_string(readPath);
DEFINE_bool(writeChecksumBasedFilenames, false,
"the picture rendered in simple mode. When used in conjunction with --bbh, results "
"are validated against the picture rendered in the same mode, but without the bbh.");
-DEFINE_bool(bench_record, false, "If true, drop into an infinite loop of recording the picture.");
-
-DEFINE_bool(preprocess, false, "If true, perform device specific preprocessing before rendering.");
-
////////////////////////////////////////////////////////////////////////////////////////////////////
/**
SkString name = SkStringPrintf("%s_%d%s", gInputFileName.c_str(), gImageNo++,
get_suffix_from_format(format));
SkString dir(FLAGS_writePath[0]);
- outPath = SkOSPath::SkPathJoin(dir.c_str(), name.c_str());
+ outPath = SkOSPath::Join(dir.c_str(), name.c_str());
SkFILEWStream fileStream(outPath.c_str());
if (!(fileStream.isValid() && fileStream.write(buffer, size))) {
SkDebugf("Failed to write encoded data to \"%s\"\n", outPath.c_str());
const SkString* mismatchPath,
sk_tools::PictureRenderer& renderer,
SkBitmap** out) {
- SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str());
+ SkString inputFilename = SkOSPath::Basename(inputPath.c_str());
SkString writePathString;
if (NULL != writePath && writePath->size() > 0 && !FLAGS_writeEncodedImages) {
writePathString.set(*writePath);
SkDebugf("deserializing... %s\n", inputPath.c_str());
- SkPicture* picture = SkPicture::CreateFromStream(&inputStream, proc);
+ SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc));
if (NULL == picture) {
SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str());
return false;
}
- while (FLAGS_bench_record) {
+ if (FLAGS_preprocess) {
+ // Because the GPU preprocessing step relies on the in-memory picture
+ // statistics we need to rerecord the picture here
SkPictureRecorder recorder;
picture->draw(recorder.beginRecording(picture->width(), picture->height(), NULL, 0));
- SkAutoTUnref<SkPicture> other(recorder.endRecording());
+ picture.reset(recorder.endRecording());
}
- for (int i = 0; i < FLAGS_clone; ++i) {
- SkPicture* clone = picture->clone();
- SkDELETE(picture);
- picture = clone;
+ while (FLAGS_bench_record) {
+ SkPictureRecorder recorder;
+ picture->draw(recorder.beginRecording(picture->width(), picture->height(), NULL, 0));
+ SkAutoTUnref<SkPicture> other(recorder.endRecording());
}
SkDebugf("drawing... [%i %i] %s\n", picture->width(), picture->height(),
renderer.end();
- SkDELETE(picture);
return success;
}
if (FLAGS_writeWholeImage) {
sk_tools::force_all_opaque(*bitmap);
- SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str());
+ SkString inputFilename = SkOSPath::Basename(inputPath.c_str());
SkString outputFilename(inputFilename);
sk_tools::replace_char(&outputFilename, '.', '_');
outputFilename.append(".png");
SkDebugf("process_input, %s\n", input);
if (iter.next(&inputFilename)) {
do {
- SkString inputPath = SkOSPath::SkPathJoin(input, inputFilename.c_str());
+ SkString inputPath = SkOSPath::Join(input, inputFilename.c_str());
if (!render_picture(inputPath, writePath, mismatchPath, renderer, jsonSummaryPtr)) {
++failures;
}
exit(-1);
}
- if (FLAGS_clone < 0) {
- SkDebugf("--clone must be >= 0. Was %i\n", FLAGS_clone);
- exit(-1);
- }
-
if (FLAGS_writeEncodedImages) {
if (FLAGS_writePath.isEmpty()) {
SkDebugf("--writeEncodedImages requires --writePath\n");
#endif
#endif
if (FLAGS_writeJsonSummaryPath.count() == 1) {
+ // If there were any descriptions on the command line, insert them now.
+ for (int i=0; i<FLAGS_descriptions.count(); i++) {
+ SkTArray<SkString> tokens;
+ SkStrSplit(FLAGS_descriptions[i], "=", &tokens);
+ SkASSERT(tokens.count() == 2);
+ jsonSummary.addDescription(tokens[0].c_str(), tokens[1].c_str());
+ }
jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]);
}
return 0;