Reduce debugging spew and add props to selectivly re-enable it.

change-id: Ib59ed5d7a9d479ccd1af456029735dbc65ae1efe
diff --git a/rsContext.cpp b/rsContext.cpp
index 6c18ddb..653d427 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -28,8 +28,6 @@
 using namespace android;
 using namespace android::renderscript;
 
-bool g_logTimes = -1;
-
 pthread_key_t Context::gThreadTLSKey = 0;
 
 void Context::initEGL()
@@ -117,7 +115,7 @@
 
 bool Context::runRootScript()
 {
-    if (this->logTimes) {
+    if (props.mLogTimes) {
         timerSet(RS_TIMER_CLEAR_SWAP);
     }
     rsAssert(mRootScript->mEnviroment.mIsRoot);
@@ -140,7 +138,7 @@
         glClear(GL_COLOR_BUFFER_BIT);
     }
 
-    if (this->logTimes) {
+    if (this->props.mLogTimes) {
         timerSet(RS_TIMER_SCRIPT);
     }
     bool ret = runScript(mRootScript.get(), 0);
@@ -208,10 +206,10 @@
     mVertex->setupGL(this, &mStateVertex);
 }
 
-static bool get_log_times()
+static bool getProp(const char *str)
 {
     char buf[PROPERTY_VALUE_MAX];
-    property_get("debug.rs.profile", buf, "0");
+    property_get(str, buf, "0");
     return 0 != strcmp(buf, "0");
 }
 
@@ -219,7 +217,9 @@
 {
      Context *rsc = static_cast<Context *>(vrsc);
 
-     rsc->logTimes = get_log_times();
+     rsc->props.mLogTimes = getProp("debug.rs.profile");
+     rsc->props.mLogScripts = getProp("debug.rs.script");
+     rsc->props.mLogObjects = getProp("debug.rs.objects");
 
      rsc->initEGL();
 
@@ -252,11 +252,11 @@
 
          if (mDraw) {
              mDraw = rsc->runRootScript() && !rsc->mPaused;
-             if (rsc->logTimes) {
+             if (rsc->props.mLogTimes) {
                  rsc->timerSet(RS_TIMER_CLEAR_SWAP);
              }
              eglSwapBuffers(rsc->mEGL.mDisplay, rsc->mEGL.mSurface);
-             if (rsc->logTimes) {
+             if (rsc->props.mLogTimes) {
                  rsc->timerFrame();
                  rsc->timerSet(RS_TIMER_INTERNAL);
                  rsc->timerPrint();
diff --git a/rsContext.h b/rsContext.h
index 28a9de2..cef421d 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -143,7 +143,11 @@
     bool checkVersion1_1() const {return (mGL.mMajorVersion > 1) || (mGL.mMinorVersion >= 1); }
     bool checkVersion2_0() const {return mGL.mMajorVersion >= 2; }
 
-    bool logTimes;
+    struct {
+        bool mLogTimes;
+        bool mLogScripts;
+        bool mLogObjects;
+    } props;
 
     mutable const ObjectBase * mObjHead;
 
diff --git a/rsObjectBase.cpp b/rsObjectBase.cpp
index acfc5ce..83fa482 100644
--- a/rsObjectBase.cpp
+++ b/rsObjectBase.cpp
@@ -65,10 +65,12 @@
 bool ObjectBase::checkDelete() const
 {
     if (!(mSysRefCount | mUserRefCount)) {
-        if (mName) {
-            LOGV("Deleting RS object %p, name %s", this, mName);
-        } else {
-            LOGV("Deleting RS object %p, no name", this);
+        if (mRSC && mRSC->props.mLogObjects) {
+            if (mName) {
+                LOGV("Deleting RS object %p, name %s", this, mName);
+            } else {
+                LOGV("Deleting RS object %p, no name", this);
+            }
         }
         delete this;
         return true;
@@ -155,7 +157,9 @@
 
 void ObjectBase::zeroAllUserRef(Context *rsc)
 {
-    LOGV("Forcing release of all outstanding user refs.");
+    if (rsc->props.mLogObjects) {
+        LOGV("Forcing release of all outstanding user refs.");
+    }
 
     // This operation can be slow, only to be called during context cleanup.
     const ObjectBase * o = rsc->mObjHead;
diff --git a/rsScriptC.cpp b/rsScriptC.cpp
index fc2744f..fb8180f 100644
--- a/rsScriptC.cpp
+++ b/rsScriptC.cpp
@@ -130,8 +130,8 @@
     rsc->appendNameDefines(&tmp);
     appendDecls(&tmp);
     rsc->appendVarDefines(&tmp);
-    appendVarDefines(&tmp);
-    appendTypes(&tmp);
+    appendVarDefines(rsc, &tmp);
+    appendTypes(rsc, &tmp);
     tmp.append("#line 1\n");
 
     const char* scriptSource[] = {tmp.string(), s->mEnviroment.mScriptText};
@@ -260,11 +260,13 @@
     s->append("}");
 }
 
-void ScriptCState::appendVarDefines(String8 *str)
+void ScriptCState::appendVarDefines(const Context *rsc, String8 *str)
 {
     char buf[256];
-    LOGD("appendVarDefines mInt32Defines.size()=%d mFloatDefines.size()=%d\n",
-            mInt32Defines.size(), mFloatDefines.size());
+    if (rsc->props.mLogScripts) {
+        LOGD("appendVarDefines mInt32Defines.size()=%d mFloatDefines.size()=%d\n",
+                mInt32Defines.size(), mFloatDefines.size());
+    }
     for (size_t ct=0; ct < mInt32Defines.size(); ct++) {
         str->append("#define ");
         str->append(mInt32Defines.keyAt(ct));
@@ -283,7 +285,7 @@
 
 
 
-void ScriptCState::appendTypes(String8 *str)
+void ScriptCState::appendTypes(const Context *rsc, String8 *str)
 {
     char buf[256];
     String8 tmp;
@@ -308,7 +310,9 @@
             s.append("_t struct struct_");
             s.append(e->getName());
             s.append("\n\n");
-            LOGD(s);
+            if (rsc->props.mLogScripts) {
+                LOGV(s);
+            }
             str->append(s);
         }
 
@@ -321,7 +325,9 @@
                 tmp.append(c->getComponentName());
                 sprintf(buf, " %i\n", ct2);
                 tmp.append(buf);
-                LOGD(tmp);
+                if (rsc->props.mLogScripts) {
+                    LOGV(tmp);
+                }
                 str->append(tmp);
             }
         }
@@ -351,7 +357,9 @@
             }
             s.append(mSlotNames[ct]);
             s.append(";\n");
-            LOGD(s);
+            if (rsc->props.mLogScripts) {
+                LOGV(s);
+            }
             str->append(s);
         }
     }
diff --git a/rsScriptC.h b/rsScriptC.h
index 96161d8..ae124b4 100644
--- a/rsScriptC.h
+++ b/rsScriptC.h
@@ -77,8 +77,8 @@
 
     void clear();
     void runCompiler(Context *rsc, ScriptC *s);
-    void appendVarDefines(String8 *str);
-    void appendTypes(String8 *str);
+    void appendVarDefines(const Context *rsc, String8 *str);
+    void appendTypes(const Context *rsc, String8 *str);
 
     struct SymbolTable_t {
         const char * mName;
diff --git a/rsThreadIO.cpp b/rsThreadIO.cpp
index 964901a..4d3d73a 100644
--- a/rsThreadIO.cpp
+++ b/rsThreadIO.cpp
@@ -42,7 +42,7 @@
         uint32_t cmdID = 0;
         uint32_t cmdSize = 0;
         ret = true;
-        if (con->logTimes) {
+        if (con->props.mLogTimes) {
             con->timerSet(Context::RS_TIMER_IDLE);
         }
         const void * data = mToCore.get(&cmdID, &cmdSize);
@@ -50,7 +50,7 @@
             // exception occured, probably shutdown.
             return false;
         }
-        if (con->logTimes) {
+        if (con->props.mLogTimes) {
             con->timerSet(Context::RS_TIMER_INTERNAL);
         }
         waitForCommand = false;