summaryrefslogtreecommitdiffstats
path: root/libs/rs/rsContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/rs/rsContext.cpp')
-rw-r--r--libs/rs/rsContext.cpp101
1 files changed, 20 insertions, 81 deletions
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index d8a9a99..f99e5f2 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -131,7 +131,7 @@ uint32_t Context::runScript(Script *s, uint32_t launchID)
{
ObjectBaseRef<ProgramFragment> frag(mFragment);
ObjectBaseRef<ProgramVertex> vtx(mVertex);
- ObjectBaseRef<ProgramFragmentStore> store(mFragmentStore);
+ ObjectBaseRef<ProgramStore> store(mFragmentStore);
ObjectBaseRef<ProgramRaster> raster(mRaster);
uint32_t ret = s->run(this, launchID);
@@ -153,25 +153,7 @@ void Context::checkError(const char *msg) const
uint32_t Context::runRootScript()
{
- timerSet(RS_TIMER_CLEAR_SWAP);
- rsAssert(mRootScript->mEnviroment.mIsRoot);
-
- eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_WIDTH, &mEGL.mWidth);
- eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight);
- glViewport(0, 0, mEGL.mWidth, mEGL.mHeight);
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-
- glClearColor(mRootScript->mEnviroment.mClearColor[0],
- mRootScript->mEnviroment.mClearColor[1],
- mRootScript->mEnviroment.mClearColor[2],
- mRootScript->mEnviroment.mClearColor[3]);
- if (mUseDepth) {
- glDepthMask(GL_TRUE);
- glClearDepthf(mRootScript->mEnviroment.mClearDepth);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- } else {
- glClear(GL_COLOR_BUFFER_BIT);
- }
+ glViewport(0, 0, mWidth, mHeight);
timerSet(RS_TIMER_SCRIPT);
mStateFragmentStore.mLast.clear();
@@ -300,13 +282,13 @@ void * Context::threadProc(void *vrsc)
}
if (rsc->mIsGraphicsContext) {
- rsc->mStateRaster.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
+ rsc->mStateRaster.init(rsc);
rsc->setRaster(NULL);
- rsc->mStateVertex.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
+ rsc->mStateVertex.init(rsc);
rsc->setVertex(NULL);
- rsc->mStateFragment.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
+ rsc->mStateFragment.init(rsc);
rsc->setFragment(NULL);
- rsc->mStateFragmentStore.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
+ rsc->mStateFragmentStore.init(rsc);
rsc->setFragmentStore(NULL);
rsc->mStateVertexArray.init(rsc);
}
@@ -486,14 +468,14 @@ void Context::setSurface(uint32_t w, uint32_t h, android_native_window_t *sur)
checkEglError("eglDestroySurface", ret);
mEGL.mSurface = NULL;
- mEGL.mWidth = 0;
- mEGL.mHeight = 0;
mWidth = 0;
mHeight = 0;
}
mWndSurface = sur;
if (mWndSurface != NULL) {
+ mWidth = w;
+ mHeight = h;
bool first = false;
if (!mEGL.mContext) {
first = true;
@@ -511,15 +493,7 @@ void Context::setSurface(uint32_t w, uint32_t h, android_native_window_t *sur)
ret = eglMakeCurrent(mEGL.mDisplay, mEGL.mSurface, mEGL.mSurface, mEGL.mContext);
checkEglError("eglMakeCurrent", ret);
- eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_WIDTH, &mEGL.mWidth);
- eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight);
- mWidth = w;
- mHeight = h;
- mStateVertex.updateSize(this, w, h);
-
- if ((int)mWidth != mEGL.mWidth || (int)mHeight != mEGL.mHeight) {
- LOGE("EGL/Surface mismatch EGL (%i x %i) SF (%i x %i)", mEGL.mWidth, mEGL.mHeight, mWidth, mHeight);
- }
+ mStateVertex.updateSize(this);
if (first) {
mGL.mVersion = glGetString(GL_VERSION);
@@ -583,7 +557,7 @@ void Context::setRootScript(Script *s)
mRootScript.set(s);
}
-void Context::setFragmentStore(ProgramFragmentStore *pfs)
+void Context::setFragmentStore(ProgramStore *pfs)
{
rsAssert(mIsGraphicsContext);
if (pfs == NULL) {
@@ -640,32 +614,9 @@ void Context::removeName(ObjectBase *obj)
}
}
-ObjectBase * Context::lookupName(const char *name) const
-{
- for(size_t ct=0; ct < mNames.size(); ct++) {
- if (!strcmp(name, mNames[ct]->getName())) {
- return mNames[ct];
- }
- }
- return NULL;
-}
-
-void Context::appendNameDefines(String8 *str) const
-{
- char buf[256];
- for (size_t ct=0; ct < mNames.size(); ct++) {
- str->append("#define NAMED_");
- str->append(mNames[ct]->getName());
- str->append(" ");
- sprintf(buf, "%i\n", (int)mNames[ct]);
- str->append(buf);
- }
-}
-
bool Context::objDestroyOOBInit()
{
- int status = pthread_mutex_init(&mObjDestroy.mMutex, NULL);
- if (status) {
+ if (!mObjDestroy.mMutex.init()) {
LOGE("Context::ObjDestroyOOBInit mutex init failure");
return false;
}
@@ -675,9 +626,8 @@ bool Context::objDestroyOOBInit()
void Context::objDestroyOOBRun()
{
if (mObjDestroy.mNeedToEmpty) {
- int status = pthread_mutex_lock(&mObjDestroy.mMutex);
- if (status) {
- LOGE("Context::ObjDestroyOOBRun: error %i locking for OOBRun.", status);
+ if (!mObjDestroy.mMutex.lock()) {
+ LOGE("Context::ObjDestroyOOBRun: error locking for OOBRun.");
return;
}
@@ -686,35 +636,25 @@ void Context::objDestroyOOBRun()
}
mObjDestroy.mDestroyList.clear();
mObjDestroy.mNeedToEmpty = false;
-
- status = pthread_mutex_unlock(&mObjDestroy.mMutex);
- if (status) {
- LOGE("Context::ObjDestroyOOBRun: error %i unlocking for set condition.", status);
- }
+ mObjDestroy.mMutex.unlock();
}
}
void Context::objDestroyOOBDestroy()
{
rsAssert(!mObjDestroy.mNeedToEmpty);
- pthread_mutex_destroy(&mObjDestroy.mMutex);
}
void Context::objDestroyAdd(ObjectBase *obj)
{
- int status = pthread_mutex_lock(&mObjDestroy.mMutex);
- if (status) {
- LOGE("Context::ObjDestroyOOBRun: error %i locking for OOBRun.", status);
+ if (!mObjDestroy.mMutex.lock()) {
+ LOGE("Context::ObjDestroyOOBRun: error locking for OOBRun.");
return;
}
mObjDestroy.mNeedToEmpty = true;
mObjDestroy.mDestroyList.add(obj);
-
- status = pthread_mutex_unlock(&mObjDestroy.mMutex);
- if (status) {
- LOGE("Context::ObjDestroyOOBRun: error %i unlocking for set condition.", status);
- }
+ mObjDestroy.mMutex.unlock();
}
uint32_t Context::getMessageToClient(void *data, size_t *receiveLen, size_t bufferLen, bool wait)
@@ -799,8 +739,7 @@ void Context::dumpDebug() const
LOGE("RS Context debug");
LOGE(" EGL ver %i %i", mEGL.mMajorVersion, mEGL.mMinorVersion);
- LOGE(" EGL context %p surface %p, w=%i h=%i Display=%p", mEGL.mContext,
- mEGL.mSurface, mEGL.mWidth, mEGL.mHeight, mEGL.mDisplay);
+ LOGE(" EGL context %p surface %p, Display=%p", mEGL.mContext, mEGL.mSurface, mEGL.mDisplay);
LOGE(" GL vendor: %s", mGL.mVendor);
LOGE(" GL renderer: %s", mGL.mRenderer);
LOGE(" GL Version: %s", mGL.mVersion);
@@ -841,9 +780,9 @@ void rsi_ContextBindSampler(Context *rsc, uint32_t slot, RsSampler vs)
s->bindToContext(&rsc->mStateSampler, slot);
}
-void rsi_ContextBindProgramFragmentStore(Context *rsc, RsProgramFragmentStore vpfs)
+void rsi_ContextBindProgramStore(Context *rsc, RsProgramStore vpfs)
{
- ProgramFragmentStore *pfs = static_cast<ProgramFragmentStore *>(vpfs);
+ ProgramStore *pfs = static_cast<ProgramStore *>(vpfs);
rsc->setFragmentStore(pfs);
}