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.compat.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 @Deprecated
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(long 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         @UnsupportedAppUsage
131         public Builder(RenderScript rs) {
132             mRS = rs;
133             mPointSprite = false;
134             mCullMode = CullMode.BACK;
135         }
136 
137         /**
138          * @deprecated in API 16
139          */
140         @UnsupportedAppUsage
141         public Builder setPointSpriteEnabled(boolean enable) {
142             mPointSprite = enable;
143             return this;
144         }
145 
146         /**
147          * @deprecated in API 16
148          */
149         public Builder setCullMode(CullMode m) {
150             mCullMode = m;
151             return this;
152         }
153 
154         /**
155          * @deprecated in API 16
156          */
157         @UnsupportedAppUsage
158         public ProgramRaster create() {
159             mRS.validate();
160             long id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID);
161             ProgramRaster programRaster = new ProgramRaster(id, mRS);
162             programRaster.mPointSprite = mPointSprite;
163             programRaster.mCullMode = mCullMode;
164             return programRaster;
165         }
166     }
167 
168 }
169 
170 
171 
172 
173 
174 
175