Script.java revision 69f0d31e576c0110c2cbbafc3b9bd46e73fc1afc
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/**
20 * @hide
21 **/
22public class Script extends BaseObj {
23    boolean mIsRoot;
24
25    Script(int id, RenderScript rs) {
26        super(rs);
27        mID = id;
28    }
29
30    public void destroy() {
31        mRS.nScriptDestroy(mID);
32        mID = 0;
33    }
34
35    public void bindAllocation(Allocation va, int slot) {
36        mRS.nScriptBindAllocation(mID, va.mID, slot);
37    }
38
39    public void setClearColor(float r, float g, float b, float a) {
40        //mRS.nScriptCSetClearColor(r, g, b, a);
41    }
42
43    public void setClearDepth(float d) {
44        //mRS.nScriptCSetClearDepth(d);
45    }
46
47    public void setClearStencil(int stencil) {
48        //mRS.nScriptCSetClearStencil(stencil);
49    }
50
51
52    public static class Builder {
53        RenderScript mRS;
54        boolean mIsRoot = false;
55        byte[] mTimeZone;
56
57        Builder(RenderScript rs) {
58            mRS = rs;
59        }
60
61        public void addType(Type t) {
62            mRS.nScriptCAddType(t.mID);
63        }
64
65        void transferCreate() {
66            if(mTimeZone != null) {
67                mRS.nScriptCSetTimeZone(mTimeZone);
68            }
69            mRS.nScriptCSetRoot(mIsRoot);
70        }
71
72        void transferObject(Script s) {
73            s.mIsRoot = mIsRoot;
74        }
75
76        public void setTimeZone(String timeZone) {
77            try {
78                mTimeZone = timeZone.getBytes("UTF-8");
79            } catch (java.io.UnsupportedEncodingException e) {
80                throw new RuntimeException(e);
81            }
82        }
83
84        public void setRoot(boolean r) {
85            mIsRoot = r;
86        }
87
88    }
89
90}
91
92