blob: eab00c11c429790fb76be334ad11dced983198e9 [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -07001/*
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -07002 * Copyright (C) 2011 The Android Open Source Project
Jason Sams326e0dd2009-05-22 14:03:28 -07003 *
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
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070020#include "rsProgramBase.h"
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070021#include "rsStream.h"
Jason Sams326e0dd2009-05-22 14:03:28 -070022
Miao Wang82e135c2017-02-27 23:35:35 -080023#include <vector>
24
Jason Sams326e0dd2009-05-22 14:03:28 -070025// ---------------------------------------------------------------------------
26namespace android {
27namespace renderscript {
28
Jason Samsccc010b2010-05-13 18:30:11 -070029class ProgramStoreState;
Alex Sakhartchouk407f8ca2011-09-23 17:05:04 -070030/*****************************************************************************
31 * CAUTION
32 *
33 * Any layout changes for this class may require a corresponding change to be
34 * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
35 * a partial copy of the information below.
36 *
37 *****************************************************************************/
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070038class ProgramStore : public ProgramBase {
Jason Sams326e0dd2009-05-22 14:03:28 -070039public:
Jason Sams8feea4e2011-03-18 15:03:25 -070040 struct Hal {
41 mutable void *drv;
42
43 struct State {
44 bool ditherEnable;
45
46 //bool blendEnable;
47 bool colorRWriteEnable;
48 bool colorGWriteEnable;
49 bool colorBWriteEnable;
50 bool colorAWriteEnable;
51 RsBlendSrcFunc blendSrc;
52 RsBlendDstFunc blendDst;
53
54 //bool depthTestEnable;
55 bool depthWriteEnable;
56 RsDepthFunc depthFunc;
57 };
58 State state;
Jason Sams8feea4e2011-03-18 15:03:25 -070059 };
60 Hal mHal;
61
Alex Sakhartchouk407f8ca2011-09-23 17:05:04 -070062 virtual void setup(const Context *, ProgramStoreState *);
63
Jason Samse3150cf2012-07-24 18:10:20 -070064 virtual void serialize(Context *rsc, OStream *stream) const;
Alex Sakhartchouk407f8ca2011-09-23 17:05:04 -070065 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; }
66 static ProgramStore *createFromStream(Context *rsc, IStream *stream);
67 static ObjectBaseRef<ProgramStore> getProgramStore(Context *,
68 bool colorMaskR, bool colorMaskG,
69 bool colorMaskB, bool colorMaskA,
70 bool depthMask, bool ditherEnable,
71 RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
72 RsDepthFunc depthFunc);
73 void init();
Jason Sams326e0dd2009-05-22 14:03:28 -070074protected:
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070075 virtual void preDestroy() const;
76 virtual ~ProgramStore();
77
78private:
79 ProgramStore(Context *,
80 bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA,
81 bool depthMask, bool ditherEnable,
82 RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
83 RsDepthFunc depthFunc);
Jason Sams326e0dd2009-05-22 14:03:28 -070084};
85
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080086class ProgramStoreState {
Jason Sams326e0dd2009-05-22 14:03:28 -070087public:
Jason Samsccc010b2010-05-13 18:30:11 -070088 ProgramStoreState();
89 ~ProgramStoreState();
Jason Sams771565f2010-05-14 15:30:29 -070090 void init(Context *rsc);
Jason Samsf2649a92009-09-25 16:37:33 -070091 void deinit(Context *rsc);
Jason Sams326e0dd2009-05-22 14:03:28 -070092
Jason Samsccc010b2010-05-13 18:30:11 -070093 ObjectBaseRef<ProgramStore> mDefault;
94 ObjectBaseRef<ProgramStore> mLast;
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070095
96 // Cache of all existing store programs.
Miao Wang82e135c2017-02-27 23:35:35 -080097 std::vector<ProgramStore *> mStorePrograms;
Jason Sams326e0dd2009-05-22 14:03:28 -070098};
99
Rahul Chaudhry7974fc02017-02-09 12:33:28 -0800100} // namespace renderscript
101} // namespace android
Jason Sams326e0dd2009-05-22 14:03:28 -0700102#endif
Yang Nib8353c52015-02-14 18:00:59 -0800103
104
105