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
17package android.renderscript;
18
19
20import android.util.Log;
21
22
23/**
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 **/
28public 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;
48        CullMode(int id) {
49            mID = id;
50        }
51    }
52
53    boolean mPointSprite;
54    CullMode mCullMode;
55
56    ProgramRaster(int 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     */
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     */
78    public CullMode getCullMode() {
79        return mCullMode;
80    }
81
82    /**
83     * @deprecated in API 16
84     */
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     */
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     */
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        public Builder(RenderScript rs) {
130            mRS = rs;
131            mPointSprite = false;
132            mCullMode = CullMode.BACK;
133        }
134
135        /**
136         * @deprecated in API 16
137         */
138        public Builder setPointSpriteEnabled(boolean enable) {
139            mPointSprite = enable;
140            return this;
141        }
142
143        /**
144         * @deprecated in API 16
145         */
146        public Builder setCullMode(CullMode m) {
147            mCullMode = m;
148            return this;
149        }
150
151        /**
152         * @deprecated in API 16
153         */
154        public ProgramRaster create() {
155            mRS.validate();
156            int id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID);
157            ProgramRaster programRaster = new ProgramRaster(id, mRS);
158            programRaster.mPointSprite = mPointSprite;
159            programRaster.mCullMode = mCullMode;
160            return programRaster;
161        }
162    }
163
164}
165
166
167
168
169
170
171