render_pictures and bench_pictures now use a --mode parameter.

This replaces the --tile, --pipe, etc. options from before as they are mutually exclusive.

Review URL: https://codereview.appspot.com/6443076

git-svn-id: http://skia.googlecode.com/svn/trunk@4930 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
keyar@chromium.org 2012-08-02 18:57:53 +00:00
parent 1554360a95
commit 795cd47342
2 changed files with 115 additions and 67 deletions

View File

@ -21,30 +21,32 @@ static void usage(const char* argv0) {
SkDebugf("\n"
"Usage: \n"
" %s <inputDir>...\n"
" [--repeat] [--tile width height]"
" [--repeat] \n"
" [--mode pipe | record | simple | tile width[%] height[%] | unflatten]"
, argv0);
SkDebugf("\n\n");
SkDebugf(
" inputDir: A list of directories and files to use as input.\n"
" Files are expected to have the .skp extension.\n\n");
" inputDir: A list of directories and files to use as input. Files are\n"
" expected to have the .skp extension.\n\n");
SkDebugf(
" --pipe : "
"Set to use piping."
" Default is to not use piping.\n");
" --mode pipe | record | simple | tile width[%] height[%] | unflatten: Run\n"
" in the corresponding mode. Default is simple.\n");
SkDebugf(
" --record : "
"Set to do a picture recording benchmark. Default is not to do this.\n");
" pipe, Benchmark SkGPipe rendering.\n");
SkDebugf(
" record, Benchmark picture to picture recording.\n");
SkDebugf(
" simple, Benchmark a simple rendering.\n");
SkDebugf(
" tile width[%] height[%], Benchmark simple rendering using\n"
" tiles with the given dimensions.\n");
SkDebugf(
" unflatten, Benchmark picture unflattening.\n");
SkDebugf("\n");
SkDebugf(
" --repeat: "
"Set the number of times to repeat each test."
" Default is %i.\n", DEFAULT_REPEATS);
SkDebugf(
" --tile width[%] height[%]: "
"Set to use the tiling size and specify the dimensions of each tile.\n"
" Default is to not use tiling\n");
SkDebugf(
" --unflatten: "
"Set to do a picture unflattening benchmark. Default is not to do this.\n");
}
static void run_single_benchmark(const SkString& inputPath,
@ -90,61 +92,81 @@ static void parse_commandline(int argc, char* const argv[], SkTArray<SkString>*
usage(argv0);
exit(-1);
}
} else if (0 == strcmp(*argv, "--tile")) {
sk_tools::TiledPictureBenchmark* tileBenchmark = SkNEW(sk_tools::TiledPictureBenchmark);
} else if (0 == strcmp(*argv, "--mode")) {
SkDELETE(benchmark);
++argv;
if (argv < stop) {
if (argv >= stop) {
SkDebugf("Missing mode for --mode\n");
usage(argv0);
exit(-1);
}
if (0 == strcmp(*argv, "pipe")) {
benchmark = SkNEW(sk_tools::PipePictureBenchmark);
} else if (0 == strcmp(*argv, "record")) {
benchmark = SkNEW(sk_tools::RecordPictureBenchmark);
} else if (0 == strcmp(*argv, "simple")) {
benchmark = SkNEW(sk_tools::SimplePictureBenchmark);
} else if (0 == strcmp(*argv, "tile")) {
sk_tools::TiledPictureBenchmark* tileBenchmark =
SkNEW(sk_tools::TiledPictureBenchmark);
++argv;
if (argv >= stop) {
SkDELETE(tileBenchmark);
SkDebugf("Missing width for --mode tile\n");
usage(argv0);
exit(-1);
}
if (sk_tools::is_percentage(*argv)) {
tileBenchmark->setTileWidthPercentage(atof(*argv));
if (!(tileBenchmark->getTileWidthPercentage() > 0)) {
SkDELETE(tileBenchmark);
SkDebugf("--tile must be given a width percentage > 0\n");
SkDebugf("--mode tile must be given a width percentage > 0\n");
exit(-1);
}
} else {
tileBenchmark->setTileWidth(atoi(*argv));
if (!(tileBenchmark->getTileWidth() > 0)) {
SkDELETE(tileBenchmark);
SkDebugf("--tile must be given a width > 0\n");
SkDebugf("--mode tile must be given a width > 0\n");
exit(-1);
}
}
} else {
++argv;
if (argv >= stop) {
SkDELETE(tileBenchmark);
SkDebugf("Missing width for --tile\n");
SkDebugf("Missing height for --mode tile\n");
usage(argv0);
exit(-1);
}
++argv;
if (argv < stop) {
if (sk_tools::is_percentage(*argv)) {
tileBenchmark->setTileHeightPercentage(atof(*argv));
if (!(tileBenchmark->getTileHeightPercentage() > 0)) {
SkDELETE(tileBenchmark);
SkDebugf("--tile must be given a height percentage > 0\n");
SkDebugf("--mode tile must be given a height percentage > 0\n");
exit(-1);
}
} else {
tileBenchmark->setTileHeight(atoi(*argv));
if (!(tileBenchmark->getTileHeight() > 0)) {
SkDELETE(tileBenchmark);
SkDebugf("--tile must be given a height > 0\n");
SkDebugf("--mode tile must be given a height > 0\n");
exit(-1);
}
}
benchmark = tileBenchmark;
} else if (0 == strcmp(*argv, "unflatten")) {
benchmark = SkNEW(sk_tools::UnflattenPictureBenchmark);
} else {
SkDELETE(tileBenchmark);
SkDebugf("Missing height for --tile\n");
SkDebugf("%s is not a valid mode for --mode\n", *argv);
usage(argv0);
exit(-1);
}
benchmark = tileBenchmark;
} else if (0 == strcmp(*argv, "--pipe")) {
benchmark = SkNEW(sk_tools::PipePictureBenchmark);
} else if (0 == strcmp(*argv, "--record")) {
benchmark = SkNEW(sk_tools::RecordPictureBenchmark);
} else if (0 == strcmp(*argv, "--unflatten")) {
benchmark = SkNEW(sk_tools::UnflattenPictureBenchmark);
} else if (0 == strcmp(*argv, "--help") || 0 == strcmp(*argv, "-h")) {
SkDELETE(benchmark);
usage(argv0);

View File

@ -23,18 +23,24 @@ static void usage(const char* argv0) {
SkDebugf("\n"
"Usage: \n"
" %s <input>... <outputDir> \n"
" [--pipe | --tile width[%] height[%]]"
" [--mode pipe | simple | tile width[%] height[%]]"
, argv0);
SkDebugf("\n\n");
SkDebugf(
" input: A list of directories and files to use as input.\n"
" Files are expected to have the .skp extension.\n");
" input: A list of directories and files to use as input. Files are\n"
" expected to have the .skp extension.\n\n");
SkDebugf(
" outputDir: directory to write the rendered images.\n");
" outputDir: directory to write the rendered images.\n\n");
SkDebugf(
" --pipe : Render using a SkGPipe\n");
" --mode pipe | simple | tile width[%] height[%]: Run in the\n"
" corresponding mode. Default is simple.\n");
SkDebugf(
" --tile width[%] height[%]: Render using tiles with the given dimensions.\n");
" pipe, Render using a SkGPipe.\n");
SkDebugf(
" simple, Render using the default rendering method.\n");
SkDebugf(
" tile width[%] height[%], Do a simple render using tiles\n"
" with the given dimensions.\n");
}
static void make_output_filepath(SkString* path, const SkString& dir,
@ -120,58 +126,78 @@ static void parse_commandline(int argc, char* const argv[], SkTArray<SkString>*
char* const* stop = argv + argc;
for (++argv; argv < stop; ++argv) {
if (0 == strcmp(*argv, "--pipe")) {
renderer = SkNEW(sk_tools::PipePictureRenderer);
} else if (0 == strcmp(*argv, "--tile")) {
sk_tools::TiledPictureRenderer* tileRenderer = SkNEW(sk_tools::TiledPictureRenderer);
if (0 == strcmp(*argv, "--mode")) {
SkDELETE(renderer);
++argv;
if (argv < stop) {
if (argv >= stop) {
SkDebugf("Missing mode for --mode\n");
usage(argv0);
exit(-1);
}
if (0 == strcmp(*argv, "pipe")) {
renderer = SkNEW(sk_tools::PipePictureRenderer);
} else if (0 == strcmp(*argv, "simple")) {
renderer = SkNEW(sk_tools::SimplePictureRenderer);
} else if (0 == strcmp(*argv, "tile")) {
sk_tools::TiledPictureRenderer* tileRenderer =
SkNEW(sk_tools::TiledPictureRenderer);
++argv;
if (argv >= stop) {
SkDELETE(tileRenderer);
SkDebugf("Missing width for --mode tile\n");
usage(argv0);
exit(-1);
}
if (sk_tools::is_percentage(*argv)) {
tileRenderer->setTileWidthPercentage(atof(*argv));
if (!(tileRenderer->getTileWidthPercentage() > 0)) {
SkDELETE(tileRenderer);
SkDebugf("--tile must be given a width percentage > 0\n");
SkDebugf("--mode tile must be given a width percentage > 0\n");
exit(-1);
}
} else {
tileRenderer->setTileWidth(atoi(*argv));
if (!(tileRenderer->getTileWidth() > 0)) {
SkDELETE(tileRenderer);
SkDebugf("--tile must be given a width > 0\n");
SkDebugf("--mode tile must be given a width > 0\n");
exit(-1);
}
}
} else {
++argv;
if (argv >= stop) {
SkDELETE(tileRenderer);
SkDebugf("Missing width for --tile\n");
SkDebugf("Missing height for --mode tile\n");
usage(argv0);
exit(-1);
}
++argv;
if (argv < stop) {
if (sk_tools::is_percentage(*argv)) {
tileRenderer->setTileHeightPercentage(atof(*argv));
if (!(tileRenderer->getTileHeightPercentage() > 0)) {
SkDELETE(tileRenderer);
SkDebugf(
"--tile must be given a height percentage > 0\n");
"--mode tile must be given a height percentage > 0\n");
exit(-1);
}
} else {
tileRenderer->setTileHeight(atoi(*argv));
if (!(tileRenderer->getTileHeight() > 0)) {
SkDELETE(tileRenderer);
SkDebugf("--tile must be given a height > 0\n");
SkDebugf("--mode tile must be given a height > 0\n");
exit(-1);
}
}
renderer = tileRenderer;
} else {
SkDELETE(tileRenderer);
SkDebugf("Missing height for --tile\n");
SkDebugf("%s is not a valid mode for --mode\n", *argv);
usage(argv0);
exit(-1);
}
renderer = tileRenderer;
} else if ((0 == strcmp(*argv, "-h")) || (0 == strcmp(*argv, "--help"))) {
SkDELETE(renderer);
usage(argv0);