1 /* 2 * Copyright (C) 2008 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 20 import android.util.Log; 21 22 23 /** 24 * @hide 25 * @deprecated in API 16 26 * Program raster is primarily used to specify whether point sprites are enabled and to control 27 * the culling mode. By default, back faces are culled. 28 **/ 29 public class ProgramRaster extends BaseObj { 30 31 /** 32 * @deprecated in API 16 33 **/ 34 public enum CullMode { 35 /** 36 * @deprecated in API 16 37 **/ 38 BACK (0), 39 /** 40 * @deprecated in API 16 41 **/ 42 FRONT (1), 43 /** 44 * @deprecated in API 16 45 **/ 46 NONE (2); 47 48 int mID; 49 CullMode(int id) { 50 mID = id; 51 } 52 } 53 54 boolean mPointSprite; 55 CullMode mCullMode; 56 57 ProgramRaster(int id, RenderScript rs) { 58 super(id, rs); 59 60 mPointSprite = false; 61 mCullMode = CullMode.BACK; 62 } 63 64 /** 65 * @deprecated in API 16 66 * Specifies whether vertices are rendered as screen aligned 67 * elements of a specified size 68 * @return whether point sprites are enabled 69 */ 70 public boolean isPointSpriteEnabled() { 71 return mPointSprite; 72 } 73 74 /** 75 * @deprecated in API 16 76 * Specifies how triangles are culled based on their orientation 77 * @return cull mode 78 */ 79 public CullMode getCullMode() { 80 return mCullMode; 81 } 82 83 /** 84 * @deprecated in API 16 85 */ 86 public static ProgramRaster CULL_BACK(RenderScript rs) { 87 if(rs.mProgramRaster_CULL_BACK == null) { 88 ProgramRaster.Builder builder = new ProgramRaster.Builder(rs); 89 builder.setCullMode(CullMode.BACK); 90 rs.mProgramRaster_CULL_BACK = builder.create(); 91 } 92 return rs.mProgramRaster_CULL_BACK; 93 } 94 95 /** 96 * @deprecated in API 16 97 */ 98 public static ProgramRaster CULL_FRONT(RenderScript rs) { 99 if(rs.mProgramRaster_CULL_FRONT == null) { 100 ProgramRaster.Builder builder = new ProgramRaster.Builder(rs); 101 builder.setCullMode(CullMode.FRONT); 102 rs.mProgramRaster_CULL_FRONT = builder.create(); 103 } 104 return rs.mProgramRaster_CULL_FRONT; 105 } 106 107 /** 108 * @deprecated in API 16 109 */ 110 public static ProgramRaster CULL_NONE(RenderScript rs) { 111 if(rs.mProgramRaster_CULL_NONE == null) { 112 ProgramRaster.Builder builder = new ProgramRaster.Builder(rs); 113 builder.setCullMode(CullMode.NONE); 114 rs.mProgramRaster_CULL_NONE = builder.create(); 115 } 116 return rs.mProgramRaster_CULL_NONE; 117 } 118 119 /** 120 * @deprecated in API 16 121 */ 122 public static class Builder { 123 RenderScript mRS; 124 boolean mPointSprite; 125 CullMode mCullMode; 126 127 /** 128 * @deprecated in API 16 129 */ 130 public Builder(RenderScript rs) { 131 mRS = rs; 132 mPointSprite = false; 133 mCullMode = CullMode.BACK; 134 } 135 136 /** 137 * @deprecated in API 16 138 */ 139 public Builder setPointSpriteEnabled(boolean enable) { 140 mPointSprite = enable; 141 return this; 142 } 143 144 /** 145 * @deprecated in API 16 146 */ 147 public Builder setCullMode(CullMode m) { 148 mCullMode = m; 149 return this; 150 } 151 152 /** 153 * @deprecated in API 16 154 */ 155 public ProgramRaster create() { 156 mRS.validate(); 157 int id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID); 158 ProgramRaster programRaster = new ProgramRaster(id, mRS); 159 programRaster.mPointSprite = mPointSprite; 160 programRaster.mCullMode = mCullMode; 161 return programRaster; 162 } 163 } 164 165 } 166 167 168 169 170 171 172