Merge change 3261
* changes: Add support for scripts to return an animation flag. This allows them to indicate they are generating changing content and the rs thread to sleep if the content is static.
This commit is contained in:
@@ -87,7 +87,7 @@ typedef struct {
|
||||
void (*drawRect)(void *con, int32_t x1, int32_t x2, int32_t y1, int32_t y2);
|
||||
} rsc_FunctionTable;
|
||||
|
||||
typedef void (*rsc_RunScript)(void *con, const rsc_FunctionTable *, uint32_t launchID);
|
||||
typedef int (*rsc_RunScript)(void *con, const rsc_FunctionTable *, uint32_t launchID);
|
||||
|
||||
|
||||
/* EnableCap */
|
||||
|
||||
@@ -65,7 +65,7 @@ main(con, ft, launchID) {
|
||||
|
||||
if (life) {
|
||||
if (posy < (480 << 16)) {
|
||||
dstIdx = ct * 3 * 3;
|
||||
dstIdx = drawCount * 9;
|
||||
c = 0xffafcf | ((life >> lifeShift) << 24);
|
||||
|
||||
storeU32(con, 1, dstIdx, c);
|
||||
@@ -79,8 +79,6 @@ main(con, ft, launchID) {
|
||||
storeU32(con, 1, dstIdx + 6, c);
|
||||
storeI32(con, 1, dstIdx + 7, posx - 0x10000);
|
||||
storeI32(con, 1, dstIdx + 8, posy + dy * 4);
|
||||
|
||||
vertPtr = vertPtr + 36;
|
||||
drawCount ++;
|
||||
} else {
|
||||
if (dy > 0) {
|
||||
@@ -102,4 +100,5 @@ main(con, ft, launchID) {
|
||||
}
|
||||
|
||||
drawTriangleArray(con, loadI32(con, 0, 5), drawCount);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -57,17 +57,19 @@ void Context::initEGL()
|
||||
|
||||
LOGE("EGL 5");
|
||||
mContext = eglCreateContext(mDisplay, mConfig, NULL, NULL);
|
||||
eglMakeCurrent(mDisplay, mSurface, mSurface, mContext);
|
||||
eglMakeCurrent(mDisplay, mSurface, mSurface, mContext);
|
||||
eglQuerySurface(mDisplay, mSurface, EGL_WIDTH, &mWidth);
|
||||
eglQuerySurface(mDisplay, mSurface, EGL_HEIGHT, &mHeight);
|
||||
LOGE("EGL 9");
|
||||
|
||||
}
|
||||
|
||||
void Context::runRootScript()
|
||||
bool Context::runRootScript()
|
||||
{
|
||||
rsAssert(mRootScript->mIsRoot);
|
||||
|
||||
glColor4f(1,1,1,1);
|
||||
glEnable(GL_LIGHT0);
|
||||
glViewport(0, 0, 320, 480);
|
||||
float aspectH = 480.f / 320.f;
|
||||
|
||||
@@ -91,7 +93,7 @@ void Context::runRootScript()
|
||||
glDepthMask(GL_TRUE);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
||||
glClearColor(mRootScript->mClearColor[0],
|
||||
glClearColor(mRootScript->mClearColor[0],
|
||||
mRootScript->mClearColor[1],
|
||||
mRootScript->mClearColor[2],
|
||||
mRootScript->mClearColor[3]);
|
||||
@@ -99,8 +101,7 @@ void Context::runRootScript()
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
mRootScript->run(this, 0);
|
||||
|
||||
return mRootScript->run(this, 0);
|
||||
}
|
||||
|
||||
void Context::setupCheck()
|
||||
@@ -133,24 +134,19 @@ void * Context::threadProc(void *vrsc)
|
||||
LOGE("TP 2");
|
||||
|
||||
rsc->mRunning = true;
|
||||
bool mDraw = true;
|
||||
while (!rsc->mExit) {
|
||||
gIO->playCoreCommands(rsc);
|
||||
mDraw |= gIO->playCoreCommands(rsc);
|
||||
|
||||
if (!rsc->mRootScript.get()) {
|
||||
if (!mDraw || !rsc->mRootScript.get()) {
|
||||
usleep(10000);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
glColor4f(1,1,1,1);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
if (rsc->mRootScript.get()) {
|
||||
rsc->runRootScript();
|
||||
mDraw = rsc->runRootScript();
|
||||
eglSwapBuffers(rsc->mDisplay, rsc->mSurface);
|
||||
}
|
||||
|
||||
eglSwapBuffers(rsc->mDisplay, rsc->mSurface);
|
||||
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
LOGE("TP 6");
|
||||
@@ -158,9 +154,6 @@ void * Context::threadProc(void *vrsc)
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
eglSwapBuffers(rsc->mDisplay, rsc->mSurface);
|
||||
eglTerminate(rsc->mDisplay);
|
||||
|
||||
LOGE("TP 7");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -257,7 +250,7 @@ void Context::setVertex(ProgramVertex *pv)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
namespace android {
|
||||
namespace renderscript {
|
||||
|
||||
@@ -108,7 +108,7 @@ private:
|
||||
|
||||
void initEGL();
|
||||
|
||||
void runRootScript();
|
||||
bool runRootScript();
|
||||
|
||||
static void * threadProc(void *);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
ObjectBaseRef<Allocation> mSlots[16];
|
||||
|
||||
virtual void run(Context *, uint32_t launchID) = 0;
|
||||
virtual bool run(Context *, uint32_t launchID) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -387,10 +387,10 @@ static rsc_FunctionTable scriptCPtrTable = {
|
||||
};
|
||||
|
||||
|
||||
void ScriptC::run(Context *rsc, uint32_t launchID)
|
||||
bool ScriptC::run(Context *rsc, uint32_t launchID)
|
||||
{
|
||||
Env e = {rsc, this};
|
||||
mScript(&e, &scriptCPtrTable, launchID);
|
||||
return mScript(&e, &scriptCPtrTable, launchID) != 0;
|
||||
}
|
||||
|
||||
ScriptCState::ScriptCState()
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
virtual ~ScriptC();
|
||||
|
||||
|
||||
virtual void run(Context *, uint32_t launchID);
|
||||
virtual bool run(Context *, uint32_t launchID);
|
||||
|
||||
|
||||
ACCscript* mAccScript;
|
||||
|
||||
@@ -34,12 +34,14 @@ ThreadIO::~ThreadIO()
|
||||
{
|
||||
}
|
||||
|
||||
void ThreadIO::playCoreCommands(Context *con)
|
||||
bool ThreadIO::playCoreCommands(Context *con)
|
||||
{
|
||||
//LOGE("playCoreCommands 1");
|
||||
uint32_t cmdID = 0;
|
||||
uint32_t cmdSize = 0;
|
||||
bool ret = false;
|
||||
while(!mToCore.isEmpty()) {
|
||||
ret = true;
|
||||
//LOGE("playCoreCommands 2");
|
||||
const void * data = mToCore.get(&cmdID, &cmdSize);
|
||||
//LOGE("playCoreCommands 3 %i %i", cmdID, cmdSize);
|
||||
@@ -50,6 +52,7 @@ void ThreadIO::playCoreCommands(Context *con)
|
||||
mToCore.next();
|
||||
//LOGE("playCoreCommands 5");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@ public:
|
||||
ThreadIO();
|
||||
~ThreadIO();
|
||||
|
||||
void playCoreCommands(Context *con);
|
||||
// Plays back commands from the client.
|
||||
// Returns true if any commands were processed.
|
||||
bool playCoreCommands(Context *con);
|
||||
|
||||
|
||||
LocklessCommandFifo mToCore;
|
||||
|
||||
Reference in New Issue
Block a user