Home | History | Annotate | Download | only in renderscript
      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 import android.util.Config;
     20 import android.util.Log;
     21 
     22 /**
     23  * @hide
     24  *
     25  **/
     26 public class Light extends BaseObj {
     27     Light(int id, RenderScript rs) {
     28         super(rs);
     29         mID = id;
     30     }
     31 
     32     public void setColor(float r, float g, float b) {
     33         mRS.validate();
     34         mRS.nLightSetColor(mID, r, g, b);
     35     }
     36 
     37     public void setPosition(float x, float y, float z) {
     38         mRS.validate();
     39         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() {
     70             mRS.validate();
     71             return internalCreate(mRS, this);
     72         }
     73     }
     74 
     75 }
     76 
     77