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