diff options
author | Jason Sams <rjsams@android.com> | 2009-11-13 10:51:39 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-11-13 10:51:39 -0800 |
commit | d7bc5e9891c8515437533d940b602bc9b288dcc2 (patch) | |
tree | 082496c2e7e8c4b5f263b7d87d870f25ca621fdb /libs/rs | |
parent | ec76a23c98a29d33d2be46e0626fa74540282fbe (diff) | |
parent | 8dcb4233fcb043f82774768d3e5bee86d867b852 (diff) | |
download | frameworks_base-d7bc5e9891c8515437533d940b602bc9b288dcc2.zip frameworks_base-d7bc5e9891c8515437533d940b602bc9b288dcc2.tar.gz frameworks_base-d7bc5e9891c8515437533d940b602bc9b288dcc2.tar.bz2 |
am 8dcb4233: am 4834887e: am 4dd6fee7: Merge change Ieb4b0318 into eclair
Merge commit '8dcb4233fcb043f82774768d3e5bee86d867b852'
* commit '8dcb4233fcb043f82774768d3e5bee86d867b852':
Make default vertex program correctly track surface size.
Diffstat (limited to 'libs/rs')
-rw-r--r-- | libs/rs/java/Fountain/src/com/android/fountain/FountainView.java | 28 | ||||
-rw-r--r-- | libs/rs/rsContext.cpp | 1 | ||||
-rw-r--r-- | libs/rs/rsProgramVertex.cpp | 9 | ||||
-rw-r--r-- | libs/rs/rsProgramVertex.h | 1 |
4 files changed, 21 insertions, 18 deletions
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java index cda005e..1e7c5a2 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java @@ -48,29 +48,25 @@ public class FountainView extends RSSurfaceView { private RenderScript mRS; private FountainRS mRender; - private void destroyRS() { - if(mRS != null) { - mRS = null; - destroyRenderScript(); - } - java.lang.System.gc(); - } - public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { super.surfaceChanged(holder, format, w, h); - destroyRS(); - mRS = createRenderScript(false, true); - mRender = new FountainRS(); - mRender.init(mRS, getResources(), w, h); + if (mRS == null) { + mRS = createRenderScript(false, true); + mRS.contextSetSurface(w, h, holder.getSurface()); + mRender = new FountainRS(); + mRender.init(mRS, getResources(), w, h); + } } - public void surfaceDestroyed(SurfaceHolder holder) { - // Surface will be destroyed when we return - destroyRS(); + @Override + protected void onDetachedFromWindow() { + if(mRS != null) { + mRS = null; + destroyRenderScript(); + } } - @Override public boolean onTouchEvent(MotionEvent ev) { diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 9d43562..1a999cf 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -443,6 +443,7 @@ void Context::setSurface(uint32_t w, uint32_t h, Surface *sur) 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); diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index eea8b3b..68f589f 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -157,12 +157,17 @@ void ProgramVertexState::init(Context *rsc, int32_t w, int32_t h) pv->bindAllocation(alloc); + updateSize(rsc, w, h); +} + +void ProgramVertexState::updateSize(Context *rsc, int32_t w, int32_t h) +{ Matrix m; m.loadOrtho(0,w, h,0, -1,1); - alloc->subData(RS_PROGRAM_VERTEX_PROJECTION_OFFSET, 16, &m.m[0], 16*4); + mDefaultAlloc->subData(RS_PROGRAM_VERTEX_PROJECTION_OFFSET, 16, &m.m[0], 16*4); m.loadIdentity(); - alloc->subData(RS_PROGRAM_VERTEX_MODELVIEW_OFFSET, 16, &m.m[0], 16*4); + mDefaultAlloc->subData(RS_PROGRAM_VERTEX_MODELVIEW_OFFSET, 16, &m.m[0], 16*4); } void ProgramVertexState::deinit(Context *rsc) diff --git a/libs/rs/rsProgramVertex.h b/libs/rs/rsProgramVertex.h index 493668c..a97ba38 100644 --- a/libs/rs/rsProgramVertex.h +++ b/libs/rs/rsProgramVertex.h @@ -63,6 +63,7 @@ public: void init(Context *rsc, int32_t w, int32_t h); void deinit(Context *rsc); + void updateSize(Context *rsc, int32_t w, int32_t h); ObjectBaseRef<ProgramVertex> mDefault; ObjectBaseRef<ProgramVertex> mLast; |