summaryrefslogtreecommitdiffstats
path: root/libs/rs
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-11-03 13:58:36 -0800
committerJason Sams <rjsams@android.com>2009-11-03 14:15:28 -0800
commitefd9b6fb2e0f31b50db089352118e5daeb268879 (patch)
tree9b1099e2c01a1d1843093dbd2db74171e39028e9 /libs/rs
parent83665194abceeb7681cb7ac49a4b71aa6e96b1b1 (diff)
downloadframeworks_base-efd9b6fb2e0f31b50db089352118e5daeb268879.zip
frameworks_base-efd9b6fb2e0f31b50db089352118e5daeb268879.tar.gz
frameworks_base-efd9b6fb2e0f31b50db089352118e5daeb268879.tar.bz2
Support applications changing the surface attached to the RS.
Diffstat (limited to 'libs/rs')
-rw-r--r--libs/rs/rs.spec4
-rw-r--r--libs/rs/rsContext.cpp58
-rw-r--r--libs/rs/rsContext.h1
3 files changed, 42 insertions, 21 deletions
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index a393e2f..865e435 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -36,6 +36,10 @@ ContextPause {
ContextResume {
}
+ContextSetSurface {
+ param void *sur
+ }
+
AssignName {
param void *obj
param const char *name
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 2e6d7b0..3e4cc36 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -85,17 +85,6 @@ void Context::initEGL()
}
//eglChooseConfig(mEGL.mDisplay, configAttribs, &mEGL.mConfig, 1, &mEGL.mNumConfigs);
- if (mWndSurface) {
- mEGL.mSurface = eglCreateWindowSurface(mEGL.mDisplay, mEGL.mConfig, mWndSurface, NULL);
- } else {
- mEGL.mSurface = eglCreateWindowSurface(mEGL.mDisplay, mEGL.mConfig,
- android_createDisplaySurface(),
- NULL);
- }
- checkEglError("eglCreateWindowSurface");
- if (mEGL.mSurface == EGL_NO_SURFACE) {
- LOGE("eglCreateWindowSurface returned EGL_NO_SURFACE");
- }
mEGL.mContext = eglCreateContext(mEGL.mDisplay, mEGL.mConfig, EGL_NO_CONTEXT, NULL);
checkEglError("eglCreateContext");
@@ -104,10 +93,10 @@ void Context::initEGL()
}
gGLContextCount++;
- EGLBoolean ret = eglMakeCurrent(mEGL.mDisplay, mEGL.mSurface, mEGL.mSurface, mEGL.mContext);
- checkEglError("eglCreateContext", ret);
- if (mEGL.mContext == EGL_NO_CONTEXT) {
- LOGE("eglCreateContext returned EGL_NO_CONTEXT");
+ if (mWndSurface) {
+ setSurface(mWndSurface);
+ } else {
+ setSurface((Surface *)android_createDisplaySurface());
}
eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_WIDTH, &mEGL.mWidth);
@@ -134,12 +123,7 @@ void Context::initEGL()
void Context::deinitEGL()
{
- EGLBoolean ret = eglMakeCurrent(mEGL.mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- checkEglError("eglCreateContext", ret);
- if (mEGL.mContext == EGL_NO_CONTEXT) {
- LOGE("eglCreateContext returned EGL_NO_CONTEXT");
- }
-
+ setSurface(NULL);
eglDestroyContext(mEGL.mDisplay, mEGL.mContext);
checkEglError("eglDestroyContext");
@@ -311,6 +295,7 @@ void * Context::threadProc(void *vrsc)
while (!rsc->mExit) {
mDraw |= rsc->mIO.playCoreCommands(rsc, !mDraw);
mDraw &= (rsc->mRootScript.get() != NULL);
+ mDraw &= (rsc->mWndSurface != NULL);
if (mDraw) {
mDraw = rsc->runRootScript() && !rsc->mPaused;
@@ -441,6 +426,32 @@ Context::~Context()
objDestroyOOBDestroy();
}
+void Context::setSurface(Surface *sur)
+{
+ EGLBoolean ret;
+ if (mEGL.mSurface != NULL) {
+ ret = eglMakeCurrent(mEGL.mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ checkEglError("eglMakeCurrent", ret);
+
+ ret = eglDestroySurface(mEGL.mDisplay, mEGL.mSurface);
+ checkEglError("eglDestroySurface", ret);
+
+ mEGL.mSurface = NULL;
+ }
+
+ mWndSurface = sur;
+ if (mWndSurface != NULL) {
+ mEGL.mSurface = eglCreateWindowSurface(mEGL.mDisplay, mEGL.mConfig, mWndSurface, NULL);
+ checkEglError("eglCreateWindowSurface");
+ if (mEGL.mSurface == EGL_NO_SURFACE) {
+ LOGE("eglCreateWindowSurface returned EGL_NO_SURFACE");
+ }
+
+ ret = eglMakeCurrent(mEGL.mDisplay, mEGL.mSurface, mEGL.mSurface, mEGL.mContext);
+ checkEglError("eglMakeCurrent", ret);
+ }
+}
+
void Context::pause()
{
mPaused = true;
@@ -756,6 +767,11 @@ void rsi_ContextResume(Context *rsc)
rsc->resume();
}
+void rsi_ContextSetSurface(Context *rsc, void *sur)
+{
+ rsc->setSurface((Surface *)sur);
+}
+
}
}
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index c80fd5a..bffc55b 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -94,6 +94,7 @@ public:
void pause();
void resume();
+ void setSurface(Surface *sur);
void assignName(ObjectBase *obj, const char *name, uint32_t len);
void removeName(ObjectBase *obj);