Merge change I9c1bad53 into eclair
* changes: Add setPriority to allow wallpapers to run at lower cpu priority than default.
This commit is contained in:
@ -67,6 +67,7 @@ public class RenderScript {
|
|||||||
native int nContextCreate(int dev, int ver, boolean useDepth);
|
native int nContextCreate(int dev, int ver, boolean useDepth);
|
||||||
native void nContextDestroy(int con);
|
native void nContextDestroy(int con);
|
||||||
native void nContextSetSurface(int w, int h, Surface sur);
|
native void nContextSetSurface(int w, int h, Surface sur);
|
||||||
|
native void nContextSetPriority(int p);
|
||||||
|
|
||||||
native void nContextBindRootScript(int script);
|
native void nContextBindRootScript(int script);
|
||||||
native void nContextBindSampler(int sampler, int slot);
|
native void nContextBindSampler(int sampler, int slot);
|
||||||
@ -218,6 +219,7 @@ public class RenderScript {
|
|||||||
Element mElement_XY_F32;
|
Element mElement_XY_F32;
|
||||||
Element mElement_XYZ_F32;
|
Element mElement_XYZ_F32;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -229,6 +231,20 @@ public class RenderScript {
|
|||||||
}
|
}
|
||||||
public RSMessage mMessageCallback = null;
|
public RSMessage mMessageCallback = null;
|
||||||
|
|
||||||
|
public enum Priority {
|
||||||
|
LOW (5), //ANDROID_PRIORITY_BACKGROUND + 5
|
||||||
|
NORMAL (-4); //ANDROID_PRIORITY_DISPLAY
|
||||||
|
|
||||||
|
int mID;
|
||||||
|
Priority(int id) {
|
||||||
|
mID = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void contextSetPriority(Priority p) {
|
||||||
|
nContextSetPriority(p.mID);
|
||||||
|
}
|
||||||
|
|
||||||
private static class MessageThread extends Thread {
|
private static class MessageThread extends Thread {
|
||||||
RenderScript mRS;
|
RenderScript mRS;
|
||||||
boolean mRun = true;
|
boolean mRun = true;
|
||||||
|
@ -157,6 +157,16 @@ nContextCreate(JNIEnv *_env, jobject _this, jint dev, jint ver, jboolean useDept
|
|||||||
return (jint)rsContextCreate((RsDevice)dev, ver, useDepth);
|
return (jint)rsContextCreate((RsDevice)dev, ver, useDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nContextSetPriority(JNIEnv *_env, jobject _this, jint p)
|
||||||
|
{
|
||||||
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
|
LOG_API("ContextSetPriority, con(%p), priority(%i)", con, p);
|
||||||
|
rsContextSetPriority(con, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nContextSetSurface(JNIEnv *_env, jobject _this, jint width, jint height, jobject wnd)
|
nContextSetSurface(JNIEnv *_env, jobject _this, jint width, jint height, jobject wnd)
|
||||||
{
|
{
|
||||||
@ -1333,6 +1343,7 @@ static JNINativeMethod methods[] = {
|
|||||||
{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy },
|
{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy },
|
||||||
{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig },
|
{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig },
|
||||||
{"nContextCreate", "(IIZ)I", (void*)nContextCreate },
|
{"nContextCreate", "(IIZ)I", (void*)nContextCreate },
|
||||||
|
{"nContextSetPriority", "(I)V", (void*)nContextSetPriority },
|
||||||
{"nContextSetSurface", "(IILandroid/view/Surface;)V", (void*)nContextSetSurface },
|
{"nContextSetSurface", "(IILandroid/view/Surface;)V", (void*)nContextSetSurface },
|
||||||
{"nContextDestroy", "(I)V", (void*)nContextDestroy },
|
{"nContextDestroy", "(I)V", (void*)nContextDestroy },
|
||||||
{"nContextPause", "()V", (void*)nContextPause },
|
{"nContextPause", "()V", (void*)nContextPause },
|
||||||
|
@ -43,7 +43,7 @@ ContextSetSurface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ContextSetPriority {
|
ContextSetPriority {
|
||||||
param uint32_t priority
|
param int32_t priority
|
||||||
}
|
}
|
||||||
|
|
||||||
AssignName {
|
AssignName {
|
||||||
|
@ -20,11 +20,16 @@
|
|||||||
#include <ui/FramebufferNativeWindow.h>
|
#include <ui/FramebufferNativeWindow.h>
|
||||||
#include <ui/EGLUtils.h>
|
#include <ui/EGLUtils.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
#include <cutils/properties.h>
|
#include <cutils/properties.h>
|
||||||
|
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
#include <GLES/glext.h>
|
#include <GLES/glext.h>
|
||||||
|
|
||||||
|
#include <cutils/sched_policy.h>
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
@ -234,6 +239,9 @@ static bool getProp(const char *str)
|
|||||||
void * Context::threadProc(void *vrsc)
|
void * Context::threadProc(void *vrsc)
|
||||||
{
|
{
|
||||||
Context *rsc = static_cast<Context *>(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.mLogTimes = getProp("debug.rs.profile");
|
||||||
rsc->props.mLogScripts = getProp("debug.rs.script");
|
rsc->props.mLogScripts = getProp("debug.rs.script");
|
||||||
@ -316,6 +324,25 @@ void * Context::threadProc(void *vrsc)
|
|||||||
return NULL;
|
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)
|
Context::Context(Device *dev, bool useDepth)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&gInitMutex);
|
pthread_mutex_lock(&gInitMutex);
|
||||||
@ -351,10 +378,6 @@ Context::Context(Device *dev, bool useDepth)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sched_param sparam;
|
|
||||||
sparam.sched_priority = ANDROID_PRIORITY_DISPLAY;
|
|
||||||
pthread_attr_setschedparam(&threadAttr, &sparam);
|
|
||||||
|
|
||||||
mWndSurface = NULL;
|
mWndSurface = NULL;
|
||||||
|
|
||||||
objDestroyOOBInit();
|
objDestroyOOBInit();
|
||||||
@ -791,8 +814,9 @@ void rsi_ContextSetSurface(Context *rsc, uint32_t w, uint32_t h, void *sur)
|
|||||||
rsc->setSurface(w, h, (Surface *)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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ public:
|
|||||||
void pause();
|
void pause();
|
||||||
void resume();
|
void resume();
|
||||||
void setSurface(uint32_t w, uint32_t h, Surface *sur);
|
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 assignName(ObjectBase *obj, const char *name, uint32_t len);
|
||||||
void removeName(ObjectBase *obj);
|
void removeName(ObjectBase *obj);
|
||||||
@ -198,6 +199,7 @@ protected:
|
|||||||
bool mPaused;
|
bool mPaused;
|
||||||
|
|
||||||
pthread_t mThreadId;
|
pthread_t mThreadId;
|
||||||
|
pid_t mNativeThreadId;
|
||||||
|
|
||||||
ObjectBaseRef<Script> mRootScript;
|
ObjectBaseRef<Script> mRootScript;
|
||||||
ObjectBaseRef<ProgramFragment> mFragment;
|
ObjectBaseRef<ProgramFragment> mFragment;
|
||||||
|
Reference in New Issue
Block a user