xref: /aosp_15_r20/frameworks/rs/rsProgramStore.h (revision e1eccf28f96817838ad6867f7f39d2351ec11f56)
1*e1eccf28SAndroid Build Coastguard Worker /*
2*e1eccf28SAndroid Build Coastguard Worker  * Copyright (C) 2011 The Android Open Source Project
3*e1eccf28SAndroid Build Coastguard Worker  *
4*e1eccf28SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*e1eccf28SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*e1eccf28SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*e1eccf28SAndroid Build Coastguard Worker  *
8*e1eccf28SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*e1eccf28SAndroid Build Coastguard Worker  *
10*e1eccf28SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*e1eccf28SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*e1eccf28SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*e1eccf28SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*e1eccf28SAndroid Build Coastguard Worker  * limitations under the License.
15*e1eccf28SAndroid Build Coastguard Worker  */
16*e1eccf28SAndroid Build Coastguard Worker 
17*e1eccf28SAndroid Build Coastguard Worker #ifndef ANDROID_RS_PROGRAM_FRAGMENT_STORE_H
18*e1eccf28SAndroid Build Coastguard Worker #define ANDROID_RS_PROGRAM_FRAGMENT_STORE_H
19*e1eccf28SAndroid Build Coastguard Worker 
20*e1eccf28SAndroid Build Coastguard Worker #include "rsProgramBase.h"
21*e1eccf28SAndroid Build Coastguard Worker #include "rsStream.h"
22*e1eccf28SAndroid Build Coastguard Worker 
23*e1eccf28SAndroid Build Coastguard Worker #include <vector>
24*e1eccf28SAndroid Build Coastguard Worker 
25*e1eccf28SAndroid Build Coastguard Worker // ---------------------------------------------------------------------------
26*e1eccf28SAndroid Build Coastguard Worker namespace android {
27*e1eccf28SAndroid Build Coastguard Worker namespace renderscript {
28*e1eccf28SAndroid Build Coastguard Worker 
29*e1eccf28SAndroid Build Coastguard Worker class ProgramStoreState;
30*e1eccf28SAndroid Build Coastguard Worker /*****************************************************************************
31*e1eccf28SAndroid Build Coastguard Worker  * CAUTION
32*e1eccf28SAndroid Build Coastguard Worker  *
33*e1eccf28SAndroid Build Coastguard Worker  * Any layout changes for this class may require a corresponding change to be
34*e1eccf28SAndroid Build Coastguard Worker  * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
35*e1eccf28SAndroid Build Coastguard Worker  * a partial copy of the information below.
36*e1eccf28SAndroid Build Coastguard Worker  *
37*e1eccf28SAndroid Build Coastguard Worker  *****************************************************************************/
38*e1eccf28SAndroid Build Coastguard Worker class ProgramStore : public ProgramBase {
39*e1eccf28SAndroid Build Coastguard Worker public:
40*e1eccf28SAndroid Build Coastguard Worker     struct Hal {
41*e1eccf28SAndroid Build Coastguard Worker         mutable void *drv;
42*e1eccf28SAndroid Build Coastguard Worker 
43*e1eccf28SAndroid Build Coastguard Worker         struct State {
44*e1eccf28SAndroid Build Coastguard Worker             bool ditherEnable;
45*e1eccf28SAndroid Build Coastguard Worker 
46*e1eccf28SAndroid Build Coastguard Worker             //bool blendEnable;
47*e1eccf28SAndroid Build Coastguard Worker             bool colorRWriteEnable;
48*e1eccf28SAndroid Build Coastguard Worker             bool colorGWriteEnable;
49*e1eccf28SAndroid Build Coastguard Worker             bool colorBWriteEnable;
50*e1eccf28SAndroid Build Coastguard Worker             bool colorAWriteEnable;
51*e1eccf28SAndroid Build Coastguard Worker             RsBlendSrcFunc blendSrc;
52*e1eccf28SAndroid Build Coastguard Worker             RsBlendDstFunc blendDst;
53*e1eccf28SAndroid Build Coastguard Worker 
54*e1eccf28SAndroid Build Coastguard Worker             //bool depthTestEnable;
55*e1eccf28SAndroid Build Coastguard Worker             bool depthWriteEnable;
56*e1eccf28SAndroid Build Coastguard Worker             RsDepthFunc depthFunc;
57*e1eccf28SAndroid Build Coastguard Worker         };
58*e1eccf28SAndroid Build Coastguard Worker         State state;
59*e1eccf28SAndroid Build Coastguard Worker     };
60*e1eccf28SAndroid Build Coastguard Worker     Hal mHal;
61*e1eccf28SAndroid Build Coastguard Worker 
62*e1eccf28SAndroid Build Coastguard Worker     virtual void setup(const Context *, ProgramStoreState *);
63*e1eccf28SAndroid Build Coastguard Worker 
64*e1eccf28SAndroid Build Coastguard Worker     virtual void serialize(Context *rsc, OStream *stream) const;
getClassId()65*e1eccf28SAndroid Build Coastguard Worker     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; }
66*e1eccf28SAndroid Build Coastguard Worker     static ProgramStore *createFromStream(Context *rsc, IStream *stream);
67*e1eccf28SAndroid Build Coastguard Worker     static ObjectBaseRef<ProgramStore> getProgramStore(Context *,
68*e1eccf28SAndroid Build Coastguard Worker                                                        bool colorMaskR, bool colorMaskG,
69*e1eccf28SAndroid Build Coastguard Worker                                                        bool colorMaskB, bool colorMaskA,
70*e1eccf28SAndroid Build Coastguard Worker                                                        bool depthMask, bool ditherEnable,
71*e1eccf28SAndroid Build Coastguard Worker                                                        RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
72*e1eccf28SAndroid Build Coastguard Worker                                                        RsDepthFunc depthFunc);
73*e1eccf28SAndroid Build Coastguard Worker     void init();
74*e1eccf28SAndroid Build Coastguard Worker protected:
75*e1eccf28SAndroid Build Coastguard Worker     virtual void preDestroy() const;
76*e1eccf28SAndroid Build Coastguard Worker     virtual ~ProgramStore();
77*e1eccf28SAndroid Build Coastguard Worker 
78*e1eccf28SAndroid Build Coastguard Worker private:
79*e1eccf28SAndroid Build Coastguard Worker     ProgramStore(Context *,
80*e1eccf28SAndroid Build Coastguard Worker                  bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA,
81*e1eccf28SAndroid Build Coastguard Worker                  bool depthMask, bool ditherEnable,
82*e1eccf28SAndroid Build Coastguard Worker                  RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
83*e1eccf28SAndroid Build Coastguard Worker                  RsDepthFunc depthFunc);
84*e1eccf28SAndroid Build Coastguard Worker };
85*e1eccf28SAndroid Build Coastguard Worker 
86*e1eccf28SAndroid Build Coastguard Worker class ProgramStoreState {
87*e1eccf28SAndroid Build Coastguard Worker public:
88*e1eccf28SAndroid Build Coastguard Worker     ProgramStoreState();
89*e1eccf28SAndroid Build Coastguard Worker     ~ProgramStoreState();
90*e1eccf28SAndroid Build Coastguard Worker     void init(Context *rsc);
91*e1eccf28SAndroid Build Coastguard Worker     void deinit(Context *rsc);
92*e1eccf28SAndroid Build Coastguard Worker 
93*e1eccf28SAndroid Build Coastguard Worker     ObjectBaseRef<ProgramStore> mDefault;
94*e1eccf28SAndroid Build Coastguard Worker     ObjectBaseRef<ProgramStore> mLast;
95*e1eccf28SAndroid Build Coastguard Worker 
96*e1eccf28SAndroid Build Coastguard Worker     // Cache of all existing store programs.
97*e1eccf28SAndroid Build Coastguard Worker     std::vector<ProgramStore *> mStorePrograms;
98*e1eccf28SAndroid Build Coastguard Worker };
99*e1eccf28SAndroid Build Coastguard Worker 
100*e1eccf28SAndroid Build Coastguard Worker } // namespace renderscript
101*e1eccf28SAndroid Build Coastguard Worker } // namespace android
102*e1eccf28SAndroid Build Coastguard Worker #endif
103*e1eccf28SAndroid Build Coastguard Worker 
104*e1eccf28SAndroid Build Coastguard Worker 
105*e1eccf28SAndroid Build Coastguard Worker 
106