Allow bench_pictures to have its viewport set on the command line.
Instead of drawing the entire (potentially very large) picture, only
draw one viewport's worth.
example:
bench_pictures <skp directory> --viewport 640 480
BUG=https://code.google.com/p/skia/issues/detail?id=1007
Review URL: https://codereview.appspot.com/6943052
git-svn-id: http://skia.googlecode.com/svn/trunk@6799 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index 47844f9..ca63807 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -126,6 +126,7 @@
" [--pipe]\n"
" [--bbh bbhType]\n"
" [--multi numThreads]\n"
+" [--viewport width height]\n"
" [--device bitmap"
#if SK_SUPPORT_GPU
" | gpu"
@@ -179,6 +180,7 @@
SkDebugf(
" --multi numThreads : Set the number of threads for multi threaded drawing. Must be greater\n"
" than 1. Only works with tiled rendering.\n"
+" --viewport width height : Set the viewport.\n"
" --pipe: Benchmark SkGPipe rendering. Currently incompatible with \"mode\".\n");
SkDebugf(
" --bbh bbhType [width height]: Set the bounding box hierarchy type to\n"
@@ -289,6 +291,8 @@
sk_tools::PictureRenderer::kNone_BBoxHierarchyType;
sk_tools::PictureRenderer::DrawFilterFlags drawFilters[SkDrawFilter::kTypeCount];
sk_bzero(drawFilters, sizeof(drawFilters));
+ SkISize viewport;
+ viewport.setEmpty();
for (++argv; argv < stop; ++argv) {
if (0 == strcmp(*argv, "--repeat")) {
++argv;
@@ -423,6 +427,19 @@
gLogger.logError(err);
PRINT_USAGE_AND_EXIT;
}
+ } else if (0 == strcmp(*argv, "--viewport")) {
+ ++argv;
+ if (argv >= stop) {
+ gLogger.logError("Missing width for --viewport\n");
+ PRINT_USAGE_AND_EXIT;
+ }
+ viewport.fWidth = atoi(*argv);
+ ++argv;
+ if (argv >= stop) {
+ gLogger.logError("Missing height for --viewport\n");
+ PRINT_USAGE_AND_EXIT;
+ }
+ viewport.fHeight = atoi(*argv);
} else if (0 == strcmp(*argv, "--tiles")) {
++argv;
if (argv >= stop) {
@@ -697,6 +714,7 @@
renderer->setBBoxHierarchyType(bbhType);
renderer->setDrawFilters(drawFilters, filtersName(drawFilters));
renderer->setGridSize(gridWidth, gridHeight);
+ renderer->setViewport(viewport);
benchmark->setRenderer(renderer);
benchmark->setRepeats(repeats);
benchmark->setDeviceType(deviceType);