| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 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 | |
| 17 | package android.renderscript; |
| 18 | |
| 19 | /** |
| 20 | * @hide |
| 21 | **/ |
| 22 | public 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 Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 40 | mRS.nScriptSetClearColor(mID, r, g, b, a); |
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | public void setClearDepth(float d) { |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 44 | mRS.nScriptSetClearDepth(mID, d); |
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | public void setClearStencil(int stencil) { |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 48 | mRS.nScriptSetClearStencil(mID, stencil); |
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 51 | 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 Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 58 | |
| 59 | public static class Builder { |
| 60 | RenderScript mRS; |
| 61 | boolean mIsRoot = false; |
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 62 | |
| 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 Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 72 | mRS.nScriptCSetRoot(mIsRoot); |
| 73 | } |
| 74 | |
| 75 | void transferObject(Script s) { |
| 76 | s.mIsRoot = mIsRoot; |
| 77 | } |
| 78 | |
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 79 | public void setRoot(boolean r) { |
| 80 | mIsRoot = r; |
| 81 | } |
| 82 | |
| 83 | } |
| 84 | |
| 85 | } |
| 86 | |