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.annotation.UnsupportedAppUsage; 20 import android.content.Context; 21 import android.util.AttributeSet; 22 import android.view.SurfaceHolder; 23 import android.view.SurfaceView; 24 25 /** 26 * @hide 27 * @deprecated in API 16 28 * The Surface View for a graphics renderscript (RenderScriptGL) to draw on. 29 * 30 * <div class="special reference"> 31 * <h3>Developer Guides</h3> 32 * <p>For more information about creating an application that uses RenderScript, read the 33 * <a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer guide.</p> 34 * </div> 35 */ 36 public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback { 37 private SurfaceHolder mSurfaceHolder; 38 private RenderScriptGL mRS; 39 40 /** 41 * @deprecated in API 16 42 * Standard View constructor. In order to render something, you 43 * must call {@link android.opengl.GLSurfaceView#setRenderer} to 44 * register a renderer. 45 */ 46 @UnsupportedAppUsage 47 public RSSurfaceView(Context context) { 48 super(context); 49 init(); 50 //Log.v(RenderScript.LOG_TAG, "RSSurfaceView"); 51 } 52 53 /** 54 * @deprecated in API 16 55 * Standard View constructor. In order to render something, you 56 * must call {@link android.opengl.GLSurfaceView#setRenderer} to 57 * register a renderer. 58 */ 59 @UnsupportedAppUsage 60 public RSSurfaceView(Context context, AttributeSet attrs) { 61 super(context, attrs); 62 init(); 63 //Log.v(RenderScript.LOG_TAG, "RSSurfaceView"); 64 } 65 66 private void init() { 67 // Install a SurfaceHolder.Callback so we get notified when the 68 // underlying surface is created and destroyed 69 SurfaceHolder holder = getHolder(); 70 holder.addCallback(this); 71 } 72 73 /** 74 * @deprecated in API 16 75 * This method is part of the SurfaceHolder.Callback interface, and is 76 * not normally called or subclassed by clients of RSSurfaceView. 77 */ 78 public void surfaceCreated(SurfaceHolder holder) { 79 mSurfaceHolder = holder; 80 } 81 82 /** 83 * @deprecated in API 16 84 * This method is part of the SurfaceHolder.Callback interface, and is 85 * not normally called or subclassed by clients of RSSurfaceView. 86 */ 87 public void surfaceDestroyed(SurfaceHolder holder) { 88 synchronized (this) { 89 // Surface will be destroyed when we return 90 if (mRS != null) { 91 mRS.setSurface(null, 0, 0); 92 } 93 } 94 } 95 96 /** 97 * @deprecated in API 16 98 * This method is part of the SurfaceHolder.Callback interface, and is 99 * not normally called or subclassed by clients of RSSurfaceView. 100 */ 101 public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { 102 synchronized (this) { 103 if (mRS != null) { 104 mRS.setSurface(holder, w, h); 105 } 106 } 107 } 108 109 /** 110 * @deprecated in API 16 111 * Inform the view that the activity is paused. The owner of this view must 112 * call this method when the activity is paused. Calling this method will 113 * pause the rendering thread. 114 * Must not be called before a renderer has been set. 115 */ 116 public void pause() { 117 if(mRS != null) { 118 mRS.pause(); 119 } 120 } 121 122 /** 123 * @deprecated in API 16 124 * Inform the view that the activity is resumed. The owner of this view must 125 * call this method when the activity is resumed. Calling this method will 126 * recreate the OpenGL display and resume the rendering 127 * thread. 128 * Must not be called before a renderer has been set. 129 */ 130 public void resume() { 131 if(mRS != null) { 132 mRS.resume(); 133 } 134 } 135 136 /** 137 * @deprecated in API 16 138 **/ 139 public RenderScriptGL createRenderScriptGL(RenderScriptGL.SurfaceConfig sc) { 140 RenderScriptGL rs = new RenderScriptGL(this.getContext(), sc); 141 setRenderScriptGL(rs); 142 return rs; 143 } 144 145 /** 146 * @deprecated in API 16 147 **/ 148 public void destroyRenderScriptGL() { 149 synchronized (this) { 150 mRS.destroy(); 151 mRS = null; 152 } 153 } 154 155 /** 156 * @deprecated in API 16 157 **/ 158 public void setRenderScriptGL(RenderScriptGL rs) { 159 mRS = rs; 160 } 161 162 /** 163 * @deprecated in API 16 164 **/ 165 public RenderScriptGL getRenderScriptGL() { 166 return mRS; 167 } 168 } 169