blob: 1c7b32b85675943b047063421bbe5c9d053218e2 [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() {
Jason Sams1bada8c2009-08-09 17:01:55 -070031 if(mDestroyed) {
32 throw new IllegalStateException("Object already destroyed.");
33 }
34 mDestroyed = true;
Jason Sams69f0d312009-08-03 18:11:17 -070035 mRS.nScriptDestroy(mID);
Jason Sams69f0d312009-08-03 18:11:17 -070036 }
37
38 public void bindAllocation(Allocation va, int slot) {
39 mRS.nScriptBindAllocation(mID, va.mID, slot);
40 }
41
42 public void setClearColor(float r, float g, float b, float a) {
Jason Sams22534172009-08-04 16:58:20 -070043 mRS.nScriptSetClearColor(mID, r, g, b, a);
Jason Sams69f0d312009-08-03 18:11:17 -070044 }
45
46 public void setClearDepth(float d) {
Jason Sams22534172009-08-04 16:58:20 -070047 mRS.nScriptSetClearDepth(mID, d);
Jason Sams69f0d312009-08-03 18:11:17 -070048 }
49
50 public void setClearStencil(int stencil) {
Jason Sams22534172009-08-04 16:58:20 -070051 mRS.nScriptSetClearStencil(mID, stencil);
Jason Sams69f0d312009-08-03 18:11:17 -070052 }
53
Jason Sams22534172009-08-04 16:58:20 -070054 public void setTimeZone(String timeZone) {
55 try {
56 mRS.nScriptSetTimeZone(mID, timeZone.getBytes("UTF-8"));
57 } catch (java.io.UnsupportedEncodingException e) {
58 throw new RuntimeException(e);
59 }
60 }
Jason Sams69f0d312009-08-03 18:11:17 -070061
62 public static class Builder {
63 RenderScript mRS;
64 boolean mIsRoot = false;
Jason Sams69f0d312009-08-03 18:11:17 -070065
66 Builder(RenderScript rs) {
67 mRS = rs;
68 }
69
70 public void addType(Type t) {
71 mRS.nScriptCAddType(t.mID);
72 }
73
74 void transferCreate() {
Jason Sams69f0d312009-08-03 18:11:17 -070075 mRS.nScriptCSetRoot(mIsRoot);
76 }
77
78 void transferObject(Script s) {
79 s.mIsRoot = mIsRoot;
80 }
81
Jason Sams69f0d312009-08-03 18:11:17 -070082 public void setRoot(boolean r) {
83 mIsRoot = r;
84 }
85
86 }
87
88}
89