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