summaryrefslogtreecommitdiff
path: root/libs/rs/rsContext.cpp
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2009-06-05 15:45:39 -0700
committer Mathias Agopian <mathias@google.com> 2009-06-05 15:45:39 -0700
commit51c8a3e00e6cffe42d25d1ac87d417e925d8a84d (patch)
treea3c8e8f3c90fd0c1aeb661bcf9fa32a2d43649cc /libs/rs/rsContext.cpp
parenteb22c5b358af775a5f1192fc248594c7a0025d56 (diff)
parente583a4ea8c90105eee9b408d39bca3a4af6a2569 (diff)
Merge commit 'goog/master' into merge_master
Diffstat (limited to 'libs/rs/rsContext.cpp')
-rw-r--r--libs/rs/rsContext.cpp51
1 files changed, 28 insertions, 23 deletions
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index abc5f456f8ea..ec4a30928d52 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -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;
}
@@ -179,7 +172,20 @@ Context::Context(Device *dev, Surface *sur)
gCon = this;
LOGE("CC 2");
- int status = pthread_create(&mThreadId, NULL, threadProc, this);
+ int status;
+ pthread_attr_t threadAttr;
+
+ status = pthread_attr_init(&threadAttr);
+ if (status) {
+ LOGE("Failed to init thread attribute.");
+ return;
+ }
+
+ sched_param sparam;
+ sparam.sched_priority = ANDROID_PRIORITY_DISPLAY;
+ pthread_attr_setschedparam(&threadAttr, &sparam);
+
+ status = pthread_create(&mThreadId, &threadAttr, threadProc, this);
if (status) {
LOGE("Failed to start rs context thread.");
}
@@ -191,8 +197,7 @@ Context::Context(Device *dev, Surface *sur)
}
LOGE("CC 4");
-
-
+ pthread_attr_destroy(&threadAttr);
}
Context::~Context()
@@ -245,7 +250,7 @@ void Context::setVertex(ProgramVertex *pv)
}
///////////////////////////////////////////////////////////////////////////////////////////
-//
+//
namespace android {
namespace renderscript {