FileDocCategorySizeDatePackage
FountainView.javaAPI DocAndroid 5.1 API3429Thu Mar 12 22:22:44 GMT 2015com.example.android.rs.fountain

FountainView

public class FountainView extends android.renderscript.RSSurfaceView

Fields Summary
private android.renderscript.RenderScriptGL
mRS
private FountainRS
mRender
Constructors Summary
public FountainView(android.content.Context context)

        super(context);
        //setFocusable(true);
    
Methods Summary
protected voidonDetachedFromWindow()

        if (mRS != null) {
            mRS = null;
            destroyRenderScriptGL();
        }
    
public booleanonTouchEvent(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 voidsurfaceChanged(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());
        }