diff --git a/graphics/java/android/renderscript/RSSurfaceView.java b/graphics/java/android/renderscript/RSSurfaceView.java index 63994aba67640..53466cc5f0b97 100644 --- a/graphics/java/android/renderscript/RSSurfaceView.java +++ b/graphics/java/android/renderscript/RSSurfaceView.java @@ -45,7 +45,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback public RSSurfaceView(Context context) { super(context); init(); - Log.v(RenderScript.LOG_TAG, "RSSurfaceView"); + //Log.v(RenderScript.LOG_TAG, "RSSurfaceView"); } /** @@ -55,7 +55,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback public RSSurfaceView(Context context, AttributeSet attrs) { super(context, attrs); init(); - Log.v(RenderScript.LOG_TAG, "RSSurfaceView"); + //Log.v(RenderScript.LOG_TAG, "RSSurfaceView"); } private void init() { @@ -80,7 +80,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback */ public void surfaceDestroyed(SurfaceHolder holder) { // Surface will be destroyed when we return - Log.v(RenderScript.LOG_TAG, "surfaceDestroyed"); + //Log.v(RenderScript.LOG_TAG, "surfaceDestroyed"); } /** @@ -88,7 +88,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback * not normally called or subclassed by clients of RSSurfaceView. */ public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { - Log.v(RenderScript.LOG_TAG, "surfaceChanged"); + //Log.v(RenderScript.LOG_TAG, "surfaceChanged"); } /** @@ -101,7 +101,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback if(mRS != null) { mRS.pause(); } - Log.v(RenderScript.LOG_TAG, "onPause"); + //Log.v(RenderScript.LOG_TAG, "onPause"); } /** @@ -115,7 +115,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback if(mRS != null) { mRS.resume(); } - Log.v(RenderScript.LOG_TAG, "onResume"); + //Log.v(RenderScript.LOG_TAG, "onResume"); } /** @@ -125,7 +125,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback * @param r the runnable to be run on the GL rendering thread. */ public void queueEvent(Runnable r) { - Log.v(RenderScript.LOG_TAG, "queueEvent"); + //Log.v(RenderScript.LOG_TAG, "queueEvent"); } /** diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 6c18ddbd1ad21..653d42734ca30 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/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::runScript(Script *s, uint32_t launchID) bool Context::runRootScript() { - if (this->logTimes) { + if (props.mLogTimes) { timerSet(RS_TIMER_CLEAR_SWAP); } rsAssert(mRootScript->mEnviroment.mIsRoot); @@ -140,7 +138,7 @@ bool Context::runRootScript() 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 @@ void Context::setupCheck() 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 @@ void * Context::threadProc(void *vrsc) { Context *rsc = static_cast(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 @@ void * Context::threadProc(void *vrsc) 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/libs/rs/rsContext.h b/libs/rs/rsContext.h index 28a9de29a560a..cef421d73b141 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -143,7 +143,11 @@ public: 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/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp index acfc5ceede67e..83fa482a52f0f 100644 --- a/libs/rs/rsObjectBase.cpp +++ b/libs/rs/rsObjectBase.cpp @@ -65,10 +65,12 @@ void ObjectBase::incSysRef() const 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::remove() const 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/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index fc2744f7c6624..fb8180fc4de7e 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -130,8 +130,8 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s) 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 @@ static void appendElementBody(String8 *s, const Element *e) 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::appendVarDefines(String8 *str) -void ScriptCState::appendTypes(String8 *str) +void ScriptCState::appendTypes(const Context *rsc, String8 *str) { char buf[256]; String8 tmp; @@ -308,7 +310,9 @@ void ScriptCState::appendTypes(String8 *str) 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 @@ void ScriptCState::appendTypes(String8 *str) 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 @@ void ScriptCState::appendTypes(String8 *str) } s.append(mSlotNames[ct]); s.append(";\n"); - LOGD(s); + if (rsc->props.mLogScripts) { + LOGV(s); + } str->append(s); } } diff --git a/libs/rs/rsScriptC.h b/libs/rs/rsScriptC.h index 96161d8c01fb7..ae124b45e741d 100644 --- a/libs/rs/rsScriptC.h +++ b/libs/rs/rsScriptC.h @@ -77,8 +77,8 @@ public: 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/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp index 964901a0426dd..4d3d73a93bf1a 100644 --- a/libs/rs/rsThreadIO.cpp +++ b/libs/rs/rsThreadIO.cpp @@ -42,7 +42,7 @@ bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand) 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 @@ bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand) // exception occured, probably shutdown. return false; } - if (con->logTimes) { + if (con->props.mLogTimes) { con->timerSet(Context::RS_TIMER_INTERNAL); } waitForCommand = false;