diff options
Diffstat (limited to 'libs/rs/rsContext.cpp')
-rw-r--r-- | libs/rs/rsContext.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 6a30b17..bffe3c0 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -245,20 +245,32 @@ void * Context::threadProc(void *vrsc) { rsc->mRunning = true; bool mDraw = true; + bool doWait = true; + + uint64_t targetTime = rsc->getTime(); while (!rsc->mExit) { - mDraw |= rsc->mIO.playCoreCommands(rsc, !mDraw); + uint64_t waitTime = 0; + uint64_t now = rsc->getTime(); + if (now < targetTime) { + waitTime = targetTime - now; + } else { + doWait = false; + } + + mDraw |= rsc->mIO.playCoreCommands(rsc, doWait, waitTime); mDraw &= (rsc->mRootScript.get() != NULL); mDraw &= rsc->mHasSurface; - uint32_t targetTime = 0; if (mDraw && rsc->mIsGraphicsContext) { - targetTime = rsc->runRootScript(); + uint64_t delay = rsc->runRootScript() * 1000000; + targetTime = rsc->getTime() + delay; + doWait = delay != 0; if (rsc->props.mLogVisual) { rsc->displayDebugStats(); } - mDraw = targetTime && !rsc->mPaused; + mDraw = !rsc->mPaused; rsc->timerSet(RS_TIMER_CLEAR_SWAP); rsc->mHal.funcs.swap(rsc); rsc->timerFrame(); @@ -266,12 +278,6 @@ void * Context::threadProc(void *vrsc) { rsc->timerPrint(); rsc->timerReset(); } - if (targetTime > 1) { - int32_t t = (targetTime - (int32_t)(rsc->mTimeMSLastScript + rsc->mTimeMSLastSwap)) * 1000; - if (t > 0) { - usleep(t); - } - } } LOGV("%p, RS Thread exiting", rsc); |