blob: 8067f193df11fd92779d04a1f515049a7061183c [file] [log] [blame]
Jason Sams0835d422009-08-04 17:58:23 -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
Jason Sams0835d422009-08-04 17:58:23 -070019import android.util.Config;
20import android.util.Log;
21
Jason Sams0835d422009-08-04 17:58:23 -070022/**
23 * @hide
24 *
25 **/
26public class Light extends BaseObj {
27 Light(int id, RenderScript rs) {
28 super(rs);
29 mID = id;
30 }
31
32 public void destroy() {
33 mRS.nLightDestroy(mID);
34 mID = 0;
35 }
36
37 public void setColor(float r, float g, float b) {
38 mRS.nLightSetColor(mID, r, g, b);
39 }
40
41 public void setPosition(float x, float y, float z) {
42 mRS.nLightSetPosition(mID, x, y, z);
43 }
44
45 public static class Builder {
46 RenderScript mRS;
47 boolean mIsMono;
48 boolean mIsLocal;
49
50 public Builder(RenderScript rs) {
51 mRS = rs;
52 mIsMono = false;
53 mIsLocal = false;
54 }
55
56 public void lightSetIsMono(boolean isMono) {
57 mIsMono = isMono;
58 }
59
60 public void lightSetIsLocal(boolean isLocal) {
61 mIsLocal = isLocal;
62 }
63
64 static synchronized Light internalCreate(RenderScript rs, Builder b) {
65 rs.nSamplerBegin();
66 rs.nLightSetIsMono(b.mIsMono);
67 rs.nLightSetIsLocal(b.mIsLocal);
68 int id = rs.nLightCreate();
69 return new Light(id, rs);
70 }
71
72 public Light create() {
73 return internalCreate(mRS, this);
74 }
75 }
76
77}
78