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 /**
     21  * @hide
     22  * @deprecated in API 16
     23  * Program raster is primarily used to specify whether point sprites are enabled and to control
     24  * the culling mode. By default, back faces are culled.
     25  **/
     26 public class ProgramRaster extends BaseObj {
     27 
     28     /**
     29      * @deprecated in API 16
     30      **/
     31     public enum CullMode {
     32         /**
     33          * @deprecated in API 16
     34          **/
     35         BACK (0),
     36         /**
     37          * @deprecated in API 16
     38          **/
     39         FRONT (1),
     40         /**
     41          * @deprecated in API 16
     42          **/
     43         NONE (2);
     44 
     45         int mID;
     46         CullMode(int id) {
     47             mID = id;
     48         }
     49     }
     50 
     51     boolean mPointSprite;
     52     CullMode mCullMode;
     53 
     54     ProgramRaster(long id, RenderScript rs) {
     55         super(id, rs);
     56 
     57         mPointSprite = false;
     58         mCullMode = CullMode.BACK;
     59     }
     60 
     61     /**
     62      * @deprecated in API 16
     63      * Specifies whether vertices are rendered as screen aligned
     64      * elements of a specified size
     65      * @return whether point sprites are enabled
     66      */
     67     public boolean isPointSpriteEnabled() {
     68         return mPointSprite;
     69     }
     70 
     71     /**
     72      * @deprecated in API 16
     73      * Specifies how triangles are culled based on their orientation
     74      * @return cull mode
     75      */
     76     public CullMode getCullMode() {
     77         return mCullMode;
     78     }
     79 
     80     /**
     81      * @deprecated in API 16
     82      */
     83     public static ProgramRaster CULL_BACK(RenderScript rs) {
     84         if(rs.mProgramRaster_CULL_BACK == null) {
     85             ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
     86             builder.setCullMode(CullMode.BACK);
     87             rs.mProgramRaster_CULL_BACK = builder.create();
     88         }
     89         return rs.mProgramRaster_CULL_BACK;
     90     }
     91 
     92     /**
     93      * @deprecated in API 16
     94      */
     95     public static ProgramRaster CULL_FRONT(RenderScript rs) {
     96         if(rs.mProgramRaster_CULL_FRONT == null) {
     97             ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
     98             builder.setCullMode(CullMode.FRONT);
     99             rs.mProgramRaster_CULL_FRONT = builder.create();
    100         }
    101         return rs.mProgramRaster_CULL_FRONT;
    102     }
    103 
    104     /**
    105      * @deprecated in API 16
    106      */
    107     public static ProgramRaster CULL_NONE(RenderScript rs) {
    108         if(rs.mProgramRaster_CULL_NONE == null) {
    109             ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
    110             builder.setCullMode(CullMode.NONE);
    111             rs.mProgramRaster_CULL_NONE = builder.create();
    112         }
    113         return rs.mProgramRaster_CULL_NONE;
    114     }
    115 
    116     /**
    117      * @deprecated in API 16
    118      */
    119     public static class Builder {
    120         RenderScript mRS;
    121         boolean mPointSprite;
    122         CullMode mCullMode;
    123 
    124         /**
    125          * @deprecated in API 16
    126          */
    127         public Builder(RenderScript rs) {
    128             mRS = rs;
    129             mPointSprite = false;
    130             mCullMode = CullMode.BACK;
    131         }
    132 
    133         /**
    134          * @deprecated in API 16
    135          */
    136         public Builder setPointSpriteEnabled(boolean enable) {
    137             mPointSprite = enable;
    138             return this;
    139         }
    140 
    141         /**
    142          * @deprecated in API 16
    143          */
    144         public Builder setCullMode(CullMode m) {
    145             mCullMode = m;
    146             return this;
    147         }
    148 
    149         /**
    150          * @deprecated in API 16
    151          */
    152         public ProgramRaster create() {
    153             mRS.validate();
    154             long id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID);
    155             ProgramRaster programRaster = new ProgramRaster(id, mRS);
    156             programRaster.mPointSprite = mPointSprite;
    157             programRaster.mCullMode = mCullMode;
    158             return programRaster;
    159         }
    160     }
    161 
    162 }
    163 
    164 
    165 
    166 
    167 
    168 
    169