diff options
author | Jason Sams <rjsams@android.com> | 2009-11-03 16:27:39 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-11-03 16:27:39 -0800 |
commit | bd98f10764045adbdca506c2e7518adcc31e1c0e (patch) | |
tree | f004e60e3e753a421d9e6b700da009e974c6d2a6 /libs/rs | |
parent | c064a3677065d9570795b9e3ddb5ac4f7d150c4d (diff) | |
parent | eb7e27e8007d1b27d3e01c376b6747dc885db517 (diff) | |
download | frameworks_base-bd98f10764045adbdca506c2e7518adcc31e1c0e.zip frameworks_base-bd98f10764045adbdca506c2e7518adcc31e1c0e.tar.gz frameworks_base-bd98f10764045adbdca506c2e7518adcc31e1c0e.tar.bz2 |
am eb7e27e8: am a1c3681f: am decc139b: Merge change I7a824efc into eclair
Merge commit 'eb7e27e8007d1b27d3e01c376b6747dc885db517'
* commit 'eb7e27e8007d1b27d3e01c376b6747dc885db517':
Support applications changing the surface attached to the RS.
Diffstat (limited to 'libs/rs')
-rw-r--r-- | libs/rs/rs.spec | 4 | ||||
-rw-r--r-- | libs/rs/rsContext.cpp | 58 | ||||
-rw-r--r-- | libs/rs/rsContext.h | 1 |
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 dbe50de..3e14a8e 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; @@ -748,6 +759,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 a919983..ac3a80a 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -93,6 +93,7 @@ public: void pause(); void resume(); + void setSurface(Surface *sur); void assignName(ObjectBase *obj, const char *name, uint32_t len); void removeName(ObjectBase *obj); |