blob: aab656f608440902dad008b63449c2e3934d7853 [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
Jason Sams0835d422009-08-04 17:58:23 -070032 public void setColor(float r, float g, float b) {
Jason Sams771bebb2009-12-07 12:40:12 -080033 mRS.validate();
Jason Sams0835d422009-08-04 17:58:23 -070034 mRS.nLightSetColor(mID, r, g, b);
35 }
36
37 public void setPosition(float x, float y, float z) {
Jason Sams771bebb2009-12-07 12:40:12 -080038 mRS.validate();
Jason Sams0835d422009-08-04 17:58:23 -070039 mRS.nLightSetPosition(mID, x, y, z);
40 }
41
42 public static class Builder {
43 RenderScript mRS;
44 boolean mIsMono;
45 boolean mIsLocal;
46
47 public Builder(RenderScript rs) {
48 mRS = rs;
49 mIsMono = false;
50 mIsLocal = false;
51 }
52
53 public void lightSetIsMono(boolean isMono) {
54 mIsMono = isMono;
55 }
56
57 public void lightSetIsLocal(boolean isLocal) {
58 mIsLocal = isLocal;
59 }
60
61 static synchronized Light internalCreate(RenderScript rs, Builder b) {
62 rs.nSamplerBegin();
63 rs.nLightSetIsMono(b.mIsMono);
64 rs.nLightSetIsLocal(b.mIsLocal);
65 int id = rs.nLightCreate();
66 return new Light(id, rs);
67 }
68
69 public Light create() {
Jason Sams771bebb2009-12-07 12:40:12 -080070 mRS.validate();
Jason Sams0835d422009-08-04 17:58:23 -070071 return internalCreate(mRS, this);
72 }
73 }
74
75}
76