FountainViewpublic class FountainView extends android.renderscript.RSSurfaceView
Fields Summary |
---|
private android.renderscript.RenderScriptGL | mRS | private FountainRS | mRender |
Methods Summary |
---|
protected void | onDetachedFromWindow()
if (mRS != null) {
mRS = null;
destroyRenderScriptGL();
}
| public boolean | onTouchEvent(android.view.MotionEvent ev)
int act = ev.getActionMasked();
if (act == ev.ACTION_UP) {
mRender.newTouchPosition(0, 0, 0, ev.getPointerId(0));
return false;
} else if (act == MotionEvent.ACTION_POINTER_UP) {
// only one pointer going up, we can get the index like this
int pointerIndex = ev.getActionIndex();
int pointerId = ev.getPointerId(pointerIndex);
mRender.newTouchPosition(0, 0, 0, pointerId);
}
int count = ev.getHistorySize();
int pcount = ev.getPointerCount();
for (int p=0; p < pcount; p++) {
int id = ev.getPointerId(p);
mRender.newTouchPosition(ev.getX(p),
ev.getY(p),
ev.getPressure(p),
id);
for (int i=0; i < count; i++) {
mRender.newTouchPosition(ev.getHistoricalX(p, i),
ev.getHistoricalY(p, i),
ev.getHistoricalPressure(p, i),
id);
}
}
return true;
| public void | surfaceChanged(android.view.SurfaceHolder holder, int format, int w, int h)
super.surfaceChanged(holder, format, w, h);
if (mRS == null) {
RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
mRS = createRenderScriptGL(sc);
mRS.setSurface(holder, w, h);
mRender = new FountainRS();
mRender.init(mRS, getResources(), w, h);
}
|
|