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/tests/skia_test.cpp b/tests/skia_test.cpp
index 26a7701..d489972 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -32,6 +32,7 @@
 DEFINE_string2(tmpDir, t, NULL, "tmp directory for tests to use.");
 DEFINE_string2(resourcePath, i, "resources", "directory for test resources.");
 DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps.");
+DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects.");
 DEFINE_bool2(single, z, false, "run tests on a single thread internally.");
 DEFINE_bool2(verbose, v, false, "enable verbose output.");
 DEFINE_int32(threads, SkThreadPool::kThreadPerCore,
@@ -129,7 +130,9 @@
     SkCommandLineFlags::Parse(argc, argv);
 
 #if SK_ENABLE_INST_COUNT
-    gPrintInstCount = true;
+    if (FLAGS_leaks) {
+        gPrintInstCount = true;
+    }
 #endif
 
     SkGraphics::Init();