Rssurfaceview directly inherits from Surfaceview, and implements the Surfaceholder.callback callback interface. The parsing is as follows:
1. Construction Method 1
Public Rssurfaceview (Context context) { super (context); Init (); LOG.V (Renderscript.log_tag, "Rssurfaceview"); }
2. Construction Method 2
Public Rssurfaceview (context context, AttributeSet Attrs) { Super (context, attrs); Init (); LOG.V (Renderscript.log_tag, "Rssurfaceview"); }
3. Initialize: Increase the callback so that you can be notified when surface is created and destroyed.
private void Init () { //Install a surfaceholder.callback so we get notified if the //underlying surface is CRE Ated and destroyed surfaceholder holder = Getholder (); Holder.addcallback (this); }
4. Callback at creation time
public void surfacecreated (Surfaceholder holder) { msurfaceholder = holder; }
5. Callback at the time of destruction
public void surfacedestroyed (Surfaceholder holder) { synchronized (this) { //Surface would be destroyed when we r Eturn if (MRS! = null) { mrs.setsurface (null, 0, 0) ; } }}
6. Callback When changing
public void surfacechanged (surfaceholder holder, int format, int w, int. h) { synchronized (this) { if (MRS! = null { mrs.setsurface (holder, W, h);}}}
7, pause: Notify the View the current activity has been paused, when the activity is paused must call the modification method, call this method will pause the render thread, must be in the renderer after the settings to be called.
public void Pause () { if (MRS! = null) { mrs.pause (); } }
8, Recovery: Notify this view the current activity has been restored, when activity recovery must call this method to recreate the OpenGL display, and restore the render thread, must be set after the renderer to be called.
public void Resume () { if (MRS! = null) { mrs.resume (); } }
9. Create RENDERSCRIPTGL
Public RENDERSCRIPTGL CREATERENDERSCRIPTGL (Renderscriptgl.surfaceconfig SC) { RENDERSCRIPTGL rs = new RENDERSCRIPTGL (This.getcontext (), SC); SETRENDERSCRIPTGL (RS); return RS; }
10, destroy the current RENDERSCRIPTGL
public void Destroyrenderscriptgl () { synchronized (this) { Mrs.destroy (); MRS = null; } }
11. Set RENDERSCRIPTGL
public void Setrenderscriptgl (RENDERSCRIPTGL rs) { MRS = rs; }
12. Get the current RENDERSCRIPTGL
Public RENDERSCRIPTGL GETRENDERSCRIPTGL () { return mRS; }
Attached source code:
Package Android.renderscript;import Java.io.writer;import Java.util.arraylist;import Java.util.concurrent.semaphore;import Android.content.context;import Android.os.handler;import Android.os.Message ; Import Android.util.attributeset;import Android.util.log;import Android.view.surface;import Android.view.surfaceholder;import android.view.surfaceview;/** * @deprecated in API + * The Surface view for a graphics R Enderscript (RENDERSCRIPTGL) to draw on. * * <div class= "Special Reference" > *
Android in Rssurfaceview