blob: c9196aa9f8e81eb3da8846383a2fa96270e3a862 [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
19
20import java.io.IOException;
21import java.io.InputStream;
22
23import android.content.res.Resources;
24import android.os.Bundle;
25import android.util.Config;
26import android.util.Log;
27
28import android.graphics.Bitmap;
29import android.graphics.BitmapFactory;
30
31/**
32 * @hide
33 *
34 **/
35public class Light extends BaseObj {
36 Light(int id, RenderScript rs) {
37 super(rs);
38 mID = id;
39 }
40
41 public void destroy() {
42 mRS.nLightDestroy(mID);
43 mID = 0;
44 }
45
46 public void setColor(float r, float g, float b) {
47 mRS.nLightSetColor(mID, r, g, b);
48 }
49
50 public void setPosition(float x, float y, float z) {
51 mRS.nLightSetPosition(mID, x, y, z);
52 }
53
54 public static class Builder {
55 RenderScript mRS;
56 boolean mIsMono;
57 boolean mIsLocal;
58
59 public Builder(RenderScript rs) {
60 mRS = rs;
61 mIsMono = false;
62 mIsLocal = false;
63 }
64
65 public void lightSetIsMono(boolean isMono) {
66 mIsMono = isMono;
67 }
68
69 public void lightSetIsLocal(boolean isLocal) {
70 mIsLocal = isLocal;
71 }
72
73 static synchronized Light internalCreate(RenderScript rs, Builder b) {
74 rs.nSamplerBegin();
75 rs.nLightSetIsMono(b.mIsMono);
76 rs.nLightSetIsLocal(b.mIsLocal);
77 int id = rs.nLightCreate();
78 return new Light(id, rs);
79 }
80
81 public Light create() {
82 return internalCreate(mRS, this);
83 }
84 }
85
86}
87