Home | History | Annotate | Download | only in rs
      1 /*
      2  * Copyright (C) 2011 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 #ifndef ANDROID_RS_PROGRAM_FRAGMENT_STORE_H
     18 #define ANDROID_RS_PROGRAM_FRAGMENT_STORE_H
     19 
     20 #include "rsProgramBase.h"
     21 #include "rsStream.h"
     22 
     23 // ---------------------------------------------------------------------------
     24 namespace android {
     25 namespace renderscript {
     26 
     27 class ProgramStoreState;
     28 /*****************************************************************************
     29  * CAUTION
     30  *
     31  * Any layout changes for this class may require a corresponding change to be
     32  * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
     33  * a partial copy of the information below.
     34  *
     35  *****************************************************************************/
     36 class ProgramStore : public ProgramBase {
     37 public:
     38     struct Hal {
     39         mutable void *drv;
     40 
     41         struct State {
     42             bool ditherEnable;
     43 
     44             //bool blendEnable;
     45             bool colorRWriteEnable;
     46             bool colorGWriteEnable;
     47             bool colorBWriteEnable;
     48             bool colorAWriteEnable;
     49             RsBlendSrcFunc blendSrc;
     50             RsBlendDstFunc blendDst;
     51 
     52             //bool depthTestEnable;
     53             bool depthWriteEnable;
     54             RsDepthFunc depthFunc;
     55         };
     56         State state;
     57     };
     58     Hal mHal;
     59 
     60     virtual void setup(const Context *, ProgramStoreState *);
     61 
     62     virtual void serialize(Context *rsc, OStream *stream) const;
     63     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; }
     64     static ProgramStore *createFromStream(Context *rsc, IStream *stream);
     65     static ObjectBaseRef<ProgramStore> getProgramStore(Context *,
     66                                                        bool colorMaskR, bool colorMaskG,
     67                                                        bool colorMaskB, bool colorMaskA,
     68                                                        bool depthMask, bool ditherEnable,
     69                                                        RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
     70                                                        RsDepthFunc depthFunc);
     71     void init();
     72 protected:
     73     virtual void preDestroy() const;
     74     virtual ~ProgramStore();
     75 
     76 private:
     77     ProgramStore(Context *,
     78                  bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA,
     79                  bool depthMask, bool ditherEnable,
     80                  RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
     81                  RsDepthFunc depthFunc);
     82 };
     83 
     84 class ProgramStoreState {
     85 public:
     86     ProgramStoreState();
     87     ~ProgramStoreState();
     88     void init(Context *rsc);
     89     void deinit(Context *rsc);
     90 
     91     ObjectBaseRef<ProgramStore> mDefault;
     92     ObjectBaseRef<ProgramStore> mLast;
     93 
     94     // Cache of all existing store programs.
     95     Vector<ProgramStore *> mStorePrograms;
     96 };
     97 
     98 }
     99 }
    100 #endif
    101 
    102 
    103 
    104