add leaks flag to show unref'd insts

Leaks are shown optionally instead of always for tests, gm, and bench.
The current display does not show actual leaks necessarily, but
shows global objects that were not deleted when the test ended.
To enable the end-of-run leak display, pass --leaks or -l.

BUG=skia:
R=mtklein@google.com

Author: caryclark@google.com

Review URL: https://codereview.chromium.org/143943009

git-svn-id: http://skia.googlecode.com/svn/trunk@13151 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index f6bca71..b4bb279 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -252,6 +252,7 @@
 DEFINE_int32(gpuCacheBytes, -1, "GPU cache size limit in bytes.  0 to disable cache.");
 DEFINE_int32(gpuCacheCount, -1, "GPU cache size limit in object count.  0 to disable cache.");
 
+DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects.");
 DEFINE_string(match, "",  "[~][^]substring[$] [...] of test name to run.\n"
                           "Multiple matches may be separated by spaces.\n"
                           "~ causes a matching test to always be skipped\n"
@@ -291,11 +292,13 @@
 
 int tool_main(int argc, char** argv);
 int tool_main(int argc, char** argv) {
+    SkCommandLineFlags::Parse(argc, argv);
 #if SK_ENABLE_INST_COUNT
-    gPrintInstCount = true;
+    if (FLAGS_leaks) {
+        gPrintInstCount = true;
+    }
 #endif
     SkAutoGraphics ag;
-    SkCommandLineFlags::Parse(argc, argv);
 
     // First, parse some flags.
     SkBenchLogger logger;