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:
parent
1554360a95
commit
795cd47342
@ -21,30 +21,32 @@ static void usage(const char* argv0) {
|
|||||||
SkDebugf("\n"
|
SkDebugf("\n"
|
||||||
"Usage: \n"
|
"Usage: \n"
|
||||||
" %s <inputDir>...\n"
|
" %s <inputDir>...\n"
|
||||||
" [--repeat] [--tile width height]"
|
" [--repeat] \n"
|
||||||
|
" [--mode pipe | record | simple | tile width[%] height[%] | unflatten]"
|
||||||
, argv0);
|
, argv0);
|
||||||
SkDebugf("\n\n");
|
SkDebugf("\n\n");
|
||||||
SkDebugf(
|
SkDebugf(
|
||||||
" inputDir: A list of directories and files to use as input.\n"
|
" inputDir: A list of directories and files to use as input. Files are\n"
|
||||||
" Files are expected to have the .skp extension.\n\n");
|
" expected to have the .skp extension.\n\n");
|
||||||
SkDebugf(
|
SkDebugf(
|
||||||
" --pipe : "
|
" --mode pipe | record | simple | tile width[%] height[%] | unflatten: Run\n"
|
||||||
"Set to use piping."
|
" in the corresponding mode. Default is simple.\n");
|
||||||
" Default is to not use piping.\n");
|
|
||||||
SkDebugf(
|
SkDebugf(
|
||||||
" --record : "
|
" pipe, Benchmark SkGPipe rendering.\n");
|
||||||
"Set to do a picture recording benchmark. Default is not to do this.\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(
|
SkDebugf(
|
||||||
" --repeat: "
|
" --repeat: "
|
||||||
"Set the number of times to repeat each test."
|
"Set the number of times to repeat each test."
|
||||||
" Default is %i.\n", DEFAULT_REPEATS);
|
" 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,
|
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);
|
usage(argv0);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
} else if (0 == strcmp(*argv, "--tile")) {
|
} else if (0 == strcmp(*argv, "--mode")) {
|
||||||
sk_tools::TiledPictureBenchmark* tileBenchmark = SkNEW(sk_tools::TiledPictureBenchmark);
|
SkDELETE(benchmark);
|
||||||
|
|
||||||
++argv;
|
++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)) {
|
if (sk_tools::is_percentage(*argv)) {
|
||||||
tileBenchmark->setTileWidthPercentage(atof(*argv));
|
tileBenchmark->setTileWidthPercentage(atof(*argv));
|
||||||
if (!(tileBenchmark->getTileWidthPercentage() > 0)) {
|
if (!(tileBenchmark->getTileWidthPercentage() > 0)) {
|
||||||
SkDELETE(tileBenchmark);
|
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);
|
exit(-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tileBenchmark->setTileWidth(atoi(*argv));
|
tileBenchmark->setTileWidth(atoi(*argv));
|
||||||
if (!(tileBenchmark->getTileWidth() > 0)) {
|
if (!(tileBenchmark->getTileWidth() > 0)) {
|
||||||
SkDELETE(tileBenchmark);
|
SkDELETE(tileBenchmark);
|
||||||
SkDebugf("--tile must be given a width > 0\n");
|
SkDebugf("--mode tile must be given a width > 0\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
++argv;
|
||||||
|
if (argv >= stop) {
|
||||||
SkDELETE(tileBenchmark);
|
SkDELETE(tileBenchmark);
|
||||||
SkDebugf("Missing width for --tile\n");
|
SkDebugf("Missing height for --mode tile\n");
|
||||||
usage(argv0);
|
usage(argv0);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
++argv;
|
|
||||||
if (argv < stop) {
|
|
||||||
if (sk_tools::is_percentage(*argv)) {
|
if (sk_tools::is_percentage(*argv)) {
|
||||||
tileBenchmark->setTileHeightPercentage(atof(*argv));
|
tileBenchmark->setTileHeightPercentage(atof(*argv));
|
||||||
if (!(tileBenchmark->getTileHeightPercentage() > 0)) {
|
if (!(tileBenchmark->getTileHeightPercentage() > 0)) {
|
||||||
SkDELETE(tileBenchmark);
|
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);
|
exit(-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tileBenchmark->setTileHeight(atoi(*argv));
|
tileBenchmark->setTileHeight(atoi(*argv));
|
||||||
if (!(tileBenchmark->getTileHeight() > 0)) {
|
if (!(tileBenchmark->getTileHeight() > 0)) {
|
||||||
SkDELETE(tileBenchmark);
|
SkDELETE(tileBenchmark);
|
||||||
SkDebugf("--tile must be given a height > 0\n");
|
SkDebugf("--mode tile must be given a height > 0\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
benchmark = tileBenchmark;
|
||||||
|
} else if (0 == strcmp(*argv, "unflatten")) {
|
||||||
|
benchmark = SkNEW(sk_tools::UnflattenPictureBenchmark);
|
||||||
} else {
|
} else {
|
||||||
SkDELETE(tileBenchmark);
|
SkDebugf("%s is not a valid mode for --mode\n", *argv);
|
||||||
SkDebugf("Missing height for --tile\n");
|
|
||||||
usage(argv0);
|
usage(argv0);
|
||||||
exit(-1);
|
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")) {
|
} else if (0 == strcmp(*argv, "--help") || 0 == strcmp(*argv, "-h")) {
|
||||||
SkDELETE(benchmark);
|
SkDELETE(benchmark);
|
||||||
usage(argv0);
|
usage(argv0);
|
||||||
|
@ -23,18 +23,24 @@ static void usage(const char* argv0) {
|
|||||||
SkDebugf("\n"
|
SkDebugf("\n"
|
||||||
"Usage: \n"
|
"Usage: \n"
|
||||||
" %s <input>... <outputDir> \n"
|
" %s <input>... <outputDir> \n"
|
||||||
" [--pipe | --tile width[%] height[%]]"
|
" [--mode pipe | simple | tile width[%] height[%]]"
|
||||||
, argv0);
|
, argv0);
|
||||||
SkDebugf("\n\n");
|
SkDebugf("\n\n");
|
||||||
SkDebugf(
|
SkDebugf(
|
||||||
" input: A list of directories and files to use as input.\n"
|
" input: A list of directories and files to use as input. Files are\n"
|
||||||
" Files are expected to have the .skp extension.\n");
|
" expected to have the .skp extension.\n\n");
|
||||||
SkDebugf(
|
SkDebugf(
|
||||||
" outputDir: directory to write the rendered images.\n");
|
" outputDir: directory to write the rendered images.\n\n");
|
||||||
SkDebugf(
|
SkDebugf(
|
||||||
" --pipe : Render using a SkGPipe\n");
|
" --mode pipe | simple | tile width[%] height[%]: Run in the\n"
|
||||||
|
" corresponding mode. Default is simple.\n");
|
||||||
SkDebugf(
|
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,
|
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;
|
char* const* stop = argv + argc;
|
||||||
|
|
||||||
for (++argv; argv < stop; ++argv) {
|
for (++argv; argv < stop; ++argv) {
|
||||||
if (0 == strcmp(*argv, "--pipe")) {
|
if (0 == strcmp(*argv, "--mode")) {
|
||||||
renderer = SkNEW(sk_tools::PipePictureRenderer);
|
SkDELETE(renderer);
|
||||||
} else if (0 == strcmp(*argv, "--tile")) {
|
|
||||||
sk_tools::TiledPictureRenderer* tileRenderer = SkNEW(sk_tools::TiledPictureRenderer);
|
|
||||||
++argv;
|
++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)) {
|
if (sk_tools::is_percentage(*argv)) {
|
||||||
tileRenderer->setTileWidthPercentage(atof(*argv));
|
tileRenderer->setTileWidthPercentage(atof(*argv));
|
||||||
if (!(tileRenderer->getTileWidthPercentage() > 0)) {
|
if (!(tileRenderer->getTileWidthPercentage() > 0)) {
|
||||||
SkDELETE(tileRenderer);
|
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);
|
exit(-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tileRenderer->setTileWidth(atoi(*argv));
|
tileRenderer->setTileWidth(atoi(*argv));
|
||||||
if (!(tileRenderer->getTileWidth() > 0)) {
|
if (!(tileRenderer->getTileWidth() > 0)) {
|
||||||
SkDELETE(tileRenderer);
|
SkDELETE(tileRenderer);
|
||||||
SkDebugf("--tile must be given a width > 0\n");
|
SkDebugf("--mode tile must be given a width > 0\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
++argv;
|
||||||
|
if (argv >= stop) {
|
||||||
SkDELETE(tileRenderer);
|
SkDELETE(tileRenderer);
|
||||||
SkDebugf("Missing width for --tile\n");
|
SkDebugf("Missing height for --mode tile\n");
|
||||||
usage(argv0);
|
usage(argv0);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
++argv;
|
|
||||||
if (argv < stop) {
|
|
||||||
if (sk_tools::is_percentage(*argv)) {
|
if (sk_tools::is_percentage(*argv)) {
|
||||||
tileRenderer->setTileHeightPercentage(atof(*argv));
|
tileRenderer->setTileHeightPercentage(atof(*argv));
|
||||||
if (!(tileRenderer->getTileHeightPercentage() > 0)) {
|
if (!(tileRenderer->getTileHeightPercentage() > 0)) {
|
||||||
SkDELETE(tileRenderer);
|
SkDELETE(tileRenderer);
|
||||||
SkDebugf(
|
SkDebugf(
|
||||||
"--tile must be given a height percentage > 0\n");
|
"--mode tile must be given a height percentage > 0\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tileRenderer->setTileHeight(atoi(*argv));
|
tileRenderer->setTileHeight(atoi(*argv));
|
||||||
if (!(tileRenderer->getTileHeight() > 0)) {
|
if (!(tileRenderer->getTileHeight() > 0)) {
|
||||||
SkDELETE(tileRenderer);
|
SkDELETE(tileRenderer);
|
||||||
SkDebugf("--tile must be given a height > 0\n");
|
SkDebugf("--mode tile must be given a height > 0\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderer = tileRenderer;
|
||||||
} else {
|
} else {
|
||||||
SkDELETE(tileRenderer);
|
SkDebugf("%s is not a valid mode for --mode\n", *argv);
|
||||||
SkDebugf("Missing height for --tile\n");
|
|
||||||
usage(argv0);
|
usage(argv0);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
renderer = tileRenderer;
|
|
||||||
} else if ((0 == strcmp(*argv, "-h")) || (0 == strcmp(*argv, "--help"))) {
|
} else if ((0 == strcmp(*argv, "-h")) || (0 == strcmp(*argv, "--help"))) {
|
||||||
SkDELETE(renderer);
|
SkDELETE(renderer);
|
||||||
usage(argv0);
|
usage(argv0);
|
||||||
|
Loading…
Reference in New Issue
Block a user