blob: 9696cea528fa71b64bf1c52a9a251a6896b9bc96 [file] [log] [blame]
Jason Sams69f0d312009-08-03 18:11:17 -07001/*
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) {
Jason Sams22534172009-08-04 16:58:20 -070040 mRS.nScriptSetClearColor(mID, r, g, b, a);
Jason Sams69f0d312009-08-03 18:11:17 -070041 }
42
43 public void setClearDepth(float d) {
Jason Sams22534172009-08-04 16:58:20 -070044 mRS.nScriptSetClearDepth(mID, d);
Jason Sams69f0d312009-08-03 18:11:17 -070045 }
46
47 public void setClearStencil(int stencil) {
Jason Sams22534172009-08-04 16:58:20 -070048 mRS.nScriptSetClearStencil(mID, stencil);
Jason Sams69f0d312009-08-03 18:11:17 -070049 }
50
Jason Sams22534172009-08-04 16:58:20 -070051 public void setTimeZone(String timeZone) {
52 try {
53 mRS.nScriptSetTimeZone(mID, timeZone.getBytes("UTF-8"));
54 } catch (java.io.UnsupportedEncodingException e) {
55 throw new RuntimeException(e);
56 }
57 }
Jason Sams69f0d312009-08-03 18:11:17 -070058
59 public static class Builder {
60 RenderScript mRS;
61 boolean mIsRoot = false;
Jason Sams69f0d312009-08-03 18:11:17 -070062
63 Builder(RenderScript rs) {
64 mRS = rs;
65 }
66
67 public void addType(Type t) {
68 mRS.nScriptCAddType(t.mID);
69 }
70
71 void transferCreate() {
Jason Sams69f0d312009-08-03 18:11:17 -070072 mRS.nScriptCSetRoot(mIsRoot);
73 }
74
75 void transferObject(Script s) {
76 s.mIsRoot = mIsRoot;
77 }
78
Jason Sams69f0d312009-08-03 18:11:17 -070079 public void setRoot(boolean r) {
80 mIsRoot = r;
81 }
82
83 }
84
85}
86