FileDocCategorySizeDatePackage
HelloWorldView.javaAPI DocAndroid 5.1 API2296Thu Mar 12 22:22:44 GMT 2015com.example.android.rs.helloworld

HelloWorldView

public class HelloWorldView extends android.renderscript.RSSurfaceView

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

        super(context);
        ensureRenderScript();
    
Methods Summary
private voidensureRenderScript()

        if (mRS == null) {
            // Initialize renderscript with desired surface characteristics.
            // In this case, just use the defaults
            RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
            mRS = createRenderScriptGL(sc);
            // Create an instance of the script that does the rendering
            mRender = new HelloWorldRS();
            mRender.init(mRS, getResources());
        }
    
protected voidonAttachedToWindow()

        super.onAttachedToWindow();
        ensureRenderScript();
    
protected voidonDetachedFromWindow()

        // Handle the system event and clean up
        mRender = null;
        if (mRS != null) {
            mRS = null;
            destroyRenderScriptGL();
        }
    
public booleanonTouchEvent(android.view.MotionEvent ev)

        // Pass touch events from the system to the rendering script
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            mRender.onActionDown((int)ev.getX(), (int)ev.getY());
            return true;
        }

        return false;