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 
     20 import android.util.Config;
     21 import android.util.Log;
     22 
     23 
     24 /**
     25  * @hide
     26  *
     27  **/
     28 public class ProgramRaster extends BaseObj {
     29     boolean mPointSmooth;
     30     boolean mLineSmooth;
     31     boolean mPointSprite;
     32     float mPointSize;
     33     float mLineWidth;
     34     Element mIn;
     35     Element mOut;
     36 
     37     ProgramRaster(int id, RenderScript rs) {
     38         super(rs);
     39         mID = id;
     40 
     41         mPointSize = 1.0f;
     42         mLineWidth = 1.0f;
     43         mPointSmooth = false;
     44         mLineSmooth = false;
     45         mPointSprite = false;
     46     }
     47 
     48     public void setLineWidth(float w) {
     49         mRS.validate();
     50         mLineWidth = w;
     51         mRS.nProgramRasterSetLineWidth(mID, w);
     52     }
     53 
     54     public void setPointSize(float s) {
     55         mRS.validate();
     56         mPointSize = s;
     57         mRS.nProgramRasterSetPointSize(mID, s);
     58     }
     59 
     60     void internalInit() {
     61         int inID = 0;
     62         int outID = 0;
     63         if (mIn != null) {
     64             inID = mIn.mID;
     65         }
     66         if (mOut != null) {
     67             outID = mOut.mID;
     68         }
     69         mID = mRS.nProgramRasterCreate(inID, outID, mPointSmooth, mLineSmooth, mPointSprite);
     70     }
     71 
     72 
     73     public static class Builder {
     74         RenderScript mRS;
     75         ProgramRaster mPR;
     76 
     77         public Builder(RenderScript rs, Element in, Element out) {
     78             mRS = rs;
     79             mPR = new ProgramRaster(0, rs);
     80         }
     81 
     82         public void setPointSpriteEnable(boolean enable) {
     83             mPR.mPointSprite = enable;
     84         }
     85 
     86         public void setPointSmoothEnable(boolean enable) {
     87             mPR.mPointSmooth = enable;
     88         }
     89 
     90         public void setLineSmoothEnable(boolean enable) {
     91             mPR.mLineSmooth = enable;
     92         }
     93 
     94 
     95         static synchronized ProgramRaster internalCreate(RenderScript rs, Builder b) {
     96             b.mPR.internalInit();
     97             ProgramRaster pr = b.mPR;
     98             b.mPR = new ProgramRaster(0, b.mRS);
     99             return pr;
    100         }
    101 
    102         public ProgramRaster create() {
    103             mRS.validate();
    104             return internalCreate(mRS, this);
    105         }
    106     }
    107 
    108 }
    109 
    110 
    111 
    112 
    113 
    114