summaryrefslogtreecommitdiffstats
path: root/libs/rs
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-11-17 07:31:07 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2009-11-17 07:31:07 -0800
commit41301259fb0a6bc0aa9da861e876c18d3bf719c4 (patch)
tree18cbb97fd0e92ea809d9ad20f9f8455957148384 /libs/rs
parente4c4843c71917c8734a02669bc8f7c38a85845ee (diff)
parent234e509a67eb32606f3051d21eb3ea25b272d80d (diff)
downloadframeworks_base-41301259fb0a6bc0aa9da861e876c18d3bf719c4.zip
frameworks_base-41301259fb0a6bc0aa9da861e876c18d3bf719c4.tar.gz
frameworks_base-41301259fb0a6bc0aa9da861e876c18d3bf719c4.tar.bz2
am 234e509a: am 22186a2c: am ec8178eb: Merge change I9c1bad53 into eclair
Merge commit '234e509a67eb32606f3051d21eb3ea25b272d80d' * commit '234e509a67eb32606f3051d21eb3ea25b272d80d': Add setPriority to allow wallpapers to run at lower cpu priority than default.
Diffstat (limited to 'libs/rs')
-rw-r--r--libs/rs/rs.spec2
-rw-r--r--libs/rs/rsContext.cpp34
-rw-r--r--libs/rs/rsContext.h2
3 files changed, 32 insertions, 6 deletions
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index da25a27..be988e7 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -43,7 +43,7 @@ ContextSetSurface {
}
ContextSetPriority {
- param uint32_t priority
+ param int32_t priority
}
AssignName {
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 1a999cf..0bfbd24 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -20,11 +20,16 @@
#include <ui/FramebufferNativeWindow.h>
#include <ui/EGLUtils.h>
+#include <sys/types.h>
+#include <sys/resource.h>
+
#include <cutils/properties.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
+#include <cutils/sched_policy.h>
+
using namespace android;
using namespace android::renderscript;
@@ -234,6 +239,9 @@ static bool getProp(const char *str)
void * Context::threadProc(void *vrsc)
{
Context *rsc = static_cast<Context *>(vrsc);
+ rsc->mNativeThreadId = gettid();
+
+ setpriority(PRIO_PROCESS, rsc->mNativeThreadId, ANDROID_PRIORITY_DISPLAY);
rsc->props.mLogTimes = getProp("debug.rs.profile");
rsc->props.mLogScripts = getProp("debug.rs.script");
@@ -316,6 +324,25 @@ void * Context::threadProc(void *vrsc)
return NULL;
}
+void Context::setPriority(int32_t p)
+{
+ // Note: If we put this in the proper "background" policy
+ // the wallpapers can become completly unresponsive at times.
+ // This is probably not what we want for something the user is actively
+ // looking at.
+#if 0
+ SchedPolicy pol = SP_FOREGROUND;
+ if (p > 0) {
+ pol = SP_BACKGROUND;
+ }
+ if (!set_sched_policy(mNativeThreadId, pol)) {
+ // success; reset the priority as well
+ }
+#else
+ setpriority(PRIO_PROCESS, mNativeThreadId, p);
+#endif
+}
+
Context::Context(Device *dev, bool useDepth)
{
pthread_mutex_lock(&gInitMutex);
@@ -351,10 +378,6 @@ Context::Context(Device *dev, bool useDepth)
return;
}
- sched_param sparam;
- sparam.sched_priority = ANDROID_PRIORITY_DISPLAY;
- pthread_attr_setschedparam(&threadAttr, &sparam);
-
mWndSurface = NULL;
objDestroyOOBInit();
@@ -783,8 +806,9 @@ void rsi_ContextSetSurface(Context *rsc, uint32_t w, uint32_t h, void *sur)
rsc->setSurface(w, h, (Surface *)sur);
}
-void rsi_ContextSetPriority(Context *rsc, uint32_t p)
+void rsi_ContextSetPriority(Context *rsc, int32_t p)
{
+ rsc->setPriority(p);
}
}
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index e1efbb1..07cb7ba 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -94,6 +94,7 @@ public:
void pause();
void resume();
void setSurface(uint32_t w, uint32_t h, Surface *sur);
+ void setPriority(int32_t p);
void assignName(ObjectBase *obj, const char *name, uint32_t len);
void removeName(ObjectBase *obj);
@@ -197,6 +198,7 @@ protected:
bool mPaused;
pthread_t mThreadId;
+ pid_t mNativeThreadId;
ObjectBaseRef<Script> mRootScript;
ObjectBaseRef<ProgramFragment> mFragment;