1 /* 2 * Copyright (C) 2008-2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.renderscript; 18 19 import android.content.Context; 20 import android.util.AttributeSet; 21 import android.view.SurfaceHolder; 22 import android.view.SurfaceView; 23 24 /** 25 * @hide 26 * @deprecated in API 16 27 * The Surface View for a graphics renderscript (RenderScriptGL) to draw on. 28 * 29 * <div class="special reference"> 30 * <h3>Developer Guides</h3> 31 * <p>For more information about creating an application that uses RenderScript, read the 32 * <a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer guide.</p> 33 * </div> 34 */ 35 public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback { 36 private SurfaceHolder mSurfaceHolder; 37 private RenderScriptGL mRS; 38 39 /** 40 * @deprecated in API 16 41 * Standard View constructor. In order to render something, you 42 * must call {@link android.opengl.GLSurfaceView#setRenderer} to 43 * register a renderer. 44 */ RSSurfaceView(Context context)45 public RSSurfaceView(Context context) { 46 super(context); 47 init(); 48 //Log.v(RenderScript.LOG_TAG, "RSSurfaceView"); 49 } 50 51 /** 52 * @deprecated in API 16 53 * Standard View constructor. In order to render something, you 54 * must call {@link android.opengl.GLSurfaceView#setRenderer} to 55 * register a renderer. 56 */ RSSurfaceView(Context context, AttributeSet attrs)57 public RSSurfaceView(Context context, AttributeSet attrs) { 58 super(context, attrs); 59 init(); 60 //Log.v(RenderScript.LOG_TAG, "RSSurfaceView"); 61 } 62 init()63 private void init() { 64 // Install a SurfaceHolder.Callback so we get notified when the 65 // underlying surface is created and destroyed 66 SurfaceHolder holder = getHolder(); 67 holder.addCallback(this); 68 } 69 70 /** 71 * @deprecated in API 16 72 * This method is part of the SurfaceHolder.Callback interface, and is 73 * not normally called or subclassed by clients of RSSurfaceView. 74 */ surfaceCreated(SurfaceHolder holder)75 public void surfaceCreated(SurfaceHolder holder) { 76 mSurfaceHolder = holder; 77 } 78 79 /** 80 * @deprecated in API 16 81 * This method is part of the SurfaceHolder.Callback interface, and is 82 * not normally called or subclassed by clients of RSSurfaceView. 83 */ surfaceDestroyed(SurfaceHolder holder)84 public void surfaceDestroyed(SurfaceHolder holder) { 85 synchronized (this) { 86 // Surface will be destroyed when we return 87 if (mRS != null) { 88 mRS.setSurface(null, 0, 0); 89 } 90 } 91 } 92 93 /** 94 * @deprecated in API 16 95 * This method is part of the SurfaceHolder.Callback interface, and is 96 * not normally called or subclassed by clients of RSSurfaceView. 97 */ surfaceChanged(SurfaceHolder holder, int format, int w, int h)98 public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { 99 synchronized (this) { 100 if (mRS != null) { 101 mRS.setSurface(holder, w, h); 102 } 103 } 104 } 105 106 /** 107 * @deprecated in API 16 108 * Inform the view that the activity is paused. The owner of this view must 109 * call this method when the activity is paused. Calling this method will 110 * pause the rendering thread. 111 * Must not be called before a renderer has been set. 112 */ pause()113 public void pause() { 114 if(mRS != null) { 115 mRS.pause(); 116 } 117 } 118 119 /** 120 * @deprecated in API 16 121 * Inform the view that the activity is resumed. The owner of this view must 122 * call this method when the activity is resumed. Calling this method will 123 * recreate the OpenGL display and resume the rendering 124 * thread. 125 * Must not be called before a renderer has been set. 126 */ resume()127 public void resume() { 128 if(mRS != null) { 129 mRS.resume(); 130 } 131 } 132 133 /** 134 * @deprecated in API 16 135 **/ createRenderScriptGL(RenderScriptGL.SurfaceConfig sc)136 public RenderScriptGL createRenderScriptGL(RenderScriptGL.SurfaceConfig sc) { 137 RenderScriptGL rs = new RenderScriptGL(this.getContext(), sc); 138 setRenderScriptGL(rs); 139 return rs; 140 } 141 142 /** 143 * @deprecated in API 16 144 **/ destroyRenderScriptGL()145 public void destroyRenderScriptGL() { 146 synchronized (this) { 147 mRS.destroy(); 148 mRS = null; 149 } 150 } 151 152 /** 153 * @deprecated in API 16 154 **/ setRenderScriptGL(RenderScriptGL rs)155 public void setRenderScriptGL(RenderScriptGL rs) { 156 mRS = rs; 157 } 158 159 /** 160 * @deprecated in API 16 161 **/ getRenderScriptGL()162 public RenderScriptGL getRenderScriptGL() { 163 return mRS; 164 } 165 } 166