Implement pause/resume for the RS thread.
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index 8cdf2b7..a393e2f 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -30,6 +30,12 @@
param int32_t value
}
+ContextPause {
+ }
+
+ContextResume {
+ }
+
AssignName {
param void *obj
param const char *name
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index e3236c4..2fe762c 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -251,7 +251,7 @@
mDraw &= (rsc->mRootScript.get() != NULL);
if (mDraw) {
- mDraw = rsc->runRootScript();
+ mDraw = rsc->runRootScript() && !rsc->mPaused;
if (rsc->logTimes) {
rsc->timerSet(RS_TIMER_CLEAR_SWAP);
}
@@ -285,6 +285,7 @@
mRunning = false;
mExit = false;
mUseDepth = useDepth;
+ mPaused = false;
int status;
pthread_attr_t threadAttr;
@@ -328,6 +329,7 @@
{
LOGV("Context::~Context");
mExit = true;
+ mPaused = false;
void *res;
mIO.shutdown();
@@ -342,6 +344,16 @@
objDestroyOOBDestroy();
}
+void Context::pause()
+{
+ mPaused = true;
+}
+
+void Context::resume()
+{
+ mPaused = false;
+}
+
void Context::setRootScript(Script *s)
{
mRootScript.set(s);
@@ -578,6 +590,16 @@
rsc->addFloatDefine(name, value);
}
+void rsi_ContextPause(Context *rsc)
+{
+ rsc->pause();
+}
+
+void rsi_ContextResume(Context *rsc)
+{
+ rsc->resume();
+}
+
}
}
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index 8cabf87..0a886cd 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -88,6 +88,9 @@
void setupCheck();
void allocationCheck(const Allocation *);
+ void pause();
+ void resume();
+
void assignName(ObjectBase *obj, const char *name, uint32_t len);
void removeName(ObjectBase *obj);
ObjectBase * lookupName(const char *name) const;
@@ -171,6 +174,7 @@
bool mRunning;
bool mExit;
bool mUseDepth;
+ bool mPaused;
pthread_t mThreadId;