ProgramRaster.java revision ebfb436a49673693b98469683451bd9ede797557
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.Config;
21import android.util.Log;
22
23
24/**
25 * @hide
26 *
27 **/
28public class ProgramRaster extends BaseObj {
29    boolean mPointSmooth;
30    boolean mLineSmooth;
31    boolean mPointSprite;
32    float mPointSize;
33    float mLineWidth;
34    Element mIn;
35    Element mOut;
36
37    ProgramRaster(int id, RenderScript rs) {
38        super(rs);
39        mID = id;
40
41        mPointSize = 1.0f;
42        mLineWidth = 1.0f;
43        mPointSmooth = false;
44        mLineSmooth = false;
45        mPointSprite = false;
46    }
47
48    public void setLineWidth(float w) {
49        mLineWidth = w;
50        mRS.nProgramRasterSetLineWidth(mID, w);
51    }
52
53    public void setPointSize(float s) {
54        mPointSize = s;
55        mRS.nProgramRasterSetPointSize(mID, s);
56    }
57
58    void internalInit() {
59        int inID = 0;
60        int outID = 0;
61        if (mIn != null) {
62            inID = mIn.mID;
63        }
64        if (mOut != null) {
65            outID = mOut.mID;
66        }
67        mID = mRS.nProgramRasterCreate(inID, outID, mPointSmooth, mLineSmooth, mPointSprite);
68    }
69
70
71    public static class Builder {
72        RenderScript mRS;
73        ProgramRaster mPR;
74
75        public Builder(RenderScript rs, Element in, Element out) {
76            mRS = rs;
77            mPR = new ProgramRaster(0, rs);
78        }
79
80        public void setPointSpriteEnable(boolean enable) {
81            mPR.mPointSprite = enable;
82        }
83
84        public void setPointSmoothEnable(boolean enable) {
85            mPR.mPointSmooth = enable;
86        }
87
88        public void setLineSmoothEnable(boolean enable) {
89            mPR.mLineSmooth = enable;
90        }
91
92
93        static synchronized ProgramRaster internalCreate(RenderScript rs, Builder b) {
94            b.mPR.internalInit();
95            ProgramRaster pr = b.mPR;
96            b.mPR = new ProgramRaster(0, b.mRS);
97            return pr;
98        }
99
100        public ProgramRaster create() {
101            return internalCreate(mRS, this);
102        }
103    }
104
105}
106
107
108
109
110
111