Merge change Ieb4b0318 into eclair
* changes: Make default vertex program correctly track surface size.
This commit is contained in:
@@ -48,28 +48,24 @@ public class FountainView extends RSSurfaceView {
|
|||||||
private RenderScript mRS;
|
private RenderScript mRS;
|
||||||
private FountainRS mRender;
|
private FountainRS mRender;
|
||||||
|
|
||||||
private void destroyRS() {
|
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||||
|
super.surfaceChanged(holder, format, w, h);
|
||||||
|
if (mRS == null) {
|
||||||
|
mRS = createRenderScript(false, true);
|
||||||
|
mRS.contextSetSurface(w, h, holder.getSurface());
|
||||||
|
mRender = new FountainRS();
|
||||||
|
mRender.init(mRS, getResources(), w, h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDetachedFromWindow() {
|
||||||
if(mRS != null) {
|
if(mRS != null) {
|
||||||
mRS = null;
|
mRS = null;
|
||||||
destroyRenderScript();
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
|
||||||
// Surface will be destroyed when we return
|
|
||||||
destroyRS();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent ev)
|
public boolean onTouchEvent(MotionEvent ev)
|
||||||
|
|||||||
@@ -443,6 +443,7 @@ void Context::setSurface(uint32_t w, uint32_t h, Surface *sur)
|
|||||||
eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight);
|
eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight);
|
||||||
mWidth = w;
|
mWidth = w;
|
||||||
mHeight = h;
|
mHeight = h;
|
||||||
|
mStateVertex.updateSize(this, w, h);
|
||||||
|
|
||||||
if ((int)mWidth != mEGL.mWidth || (int)mHeight != mEGL.mHeight) {
|
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);
|
LOGE("EGL/Surface mismatch EGL (%i x %i) SF (%i x %i)", mEGL.mWidth, mEGL.mHeight, mWidth, mHeight);
|
||||||
|
|||||||
@@ -157,12 +157,17 @@ void ProgramVertexState::init(Context *rsc, int32_t w, int32_t h)
|
|||||||
|
|
||||||
pv->bindAllocation(alloc);
|
pv->bindAllocation(alloc);
|
||||||
|
|
||||||
|
updateSize(rsc, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgramVertexState::updateSize(Context *rsc, int32_t w, int32_t h)
|
||||||
|
{
|
||||||
Matrix m;
|
Matrix m;
|
||||||
m.loadOrtho(0,w, h,0, -1,1);
|
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();
|
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)
|
void ProgramVertexState::deinit(Context *rsc)
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ public:
|
|||||||
|
|
||||||
void init(Context *rsc, int32_t w, int32_t h);
|
void init(Context *rsc, int32_t w, int32_t h);
|
||||||
void deinit(Context *rsc);
|
void deinit(Context *rsc);
|
||||||
|
void updateSize(Context *rsc, int32_t w, int32_t h);
|
||||||
|
|
||||||
ObjectBaseRef<ProgramVertex> mDefault;
|
ObjectBaseRef<ProgramVertex> mDefault;
|
||||||
ObjectBaseRef<ProgramVertex> mLast;
|
ObjectBaseRef<ProgramVertex> mLast;
|
||||||
|
|||||||
Reference in New Issue
Block a user