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 class ProgramStore : public ProgramBase { 30 public: 31 virtual void setup(const Context *, ProgramStoreState *); 32 33 virtual void serialize(OStream *stream) const; getClassId()34 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; } 35 static ProgramStore *createFromStream(Context *rsc, IStream *stream); 36 static ObjectBaseRef<ProgramStore> getProgramStore(Context *, 37 bool colorMaskR, bool colorMaskG, 38 bool colorMaskB, bool colorMaskA, 39 bool depthMask, bool ditherEnable, 40 RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc, 41 RsDepthFunc depthFunc); 42 43 void init(); 44 45 struct Hal { 46 mutable void *drv; 47 48 struct State { 49 bool ditherEnable; 50 51 //bool blendEnable; 52 bool colorRWriteEnable; 53 bool colorGWriteEnable; 54 bool colorBWriteEnable; 55 bool colorAWriteEnable; 56 RsBlendSrcFunc blendSrc; 57 RsBlendDstFunc blendDst; 58 59 //bool depthTestEnable; 60 bool depthWriteEnable; 61 RsDepthFunc depthFunc; 62 }; 63 State state; 64 }; 65 Hal mHal; 66 67 protected: 68 virtual void preDestroy() const; 69 virtual ~ProgramStore(); 70 71 private: 72 ProgramStore(Context *, 73 bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA, 74 bool depthMask, bool ditherEnable, 75 RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc, 76 RsDepthFunc depthFunc); 77 }; 78 79 class ProgramStoreState { 80 public: 81 ProgramStoreState(); 82 ~ProgramStoreState(); 83 void init(Context *rsc); 84 void deinit(Context *rsc); 85 86 ObjectBaseRef<ProgramStore> mDefault; 87 ObjectBaseRef<ProgramStore> mLast; 88 89 // Cache of all existing store programs. 90 Vector<ProgramStore *> mStorePrograms; 91 }; 92 93 } 94 } 95 #endif 96 97 98 99