blob: 9bb2795cba5d15623a741b16d11a9e19c6239630 [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
23// ---------------------------------------------------------------------------
24namespace android {
25namespace renderscript {
26
Jason Samsccc010b2010-05-13 18:30:11 -070027class ProgramStoreState;
Alex Sakhartchouk407f8ca2011-09-23 17:05:04 -070028/*****************************************************************************
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 *****************************************************************************/
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070036class ProgramStore : public ProgramBase {
Jason Sams326e0dd2009-05-22 14:03:28 -070037public:
Jason Sams8feea4e2011-03-18 15:03:25 -070038 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;
Jason Sams8feea4e2011-03-18 15:03:25 -070057 };
58 Hal mHal;
59
Alex Sakhartchouk407f8ca2011-09-23 17:05:04 -070060 virtual void setup(const Context *, ProgramStoreState *);
61
62 virtual void serialize(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();
Jason Sams326e0dd2009-05-22 14:03:28 -070072protected:
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070073 virtual void preDestroy() const;
74 virtual ~ProgramStore();
75
76private:
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);
Jason Sams326e0dd2009-05-22 14:03:28 -070082};
83
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080084class ProgramStoreState {
Jason Sams326e0dd2009-05-22 14:03:28 -070085public:
Jason Samsccc010b2010-05-13 18:30:11 -070086 ProgramStoreState();
87 ~ProgramStoreState();
Jason Sams771565f2010-05-14 15:30:29 -070088 void init(Context *rsc);
Jason Samsf2649a92009-09-25 16:37:33 -070089 void deinit(Context *rsc);
Jason Sams326e0dd2009-05-22 14:03:28 -070090
Jason Samsccc010b2010-05-13 18:30:11 -070091 ObjectBaseRef<ProgramStore> mDefault;
92 ObjectBaseRef<ProgramStore> mLast;
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070093
94 // Cache of all existing store programs.
95 Vector<ProgramStore *> mStorePrograms;
Jason Sams326e0dd2009-05-22 14:03:28 -070096};
97
Jason Sams326e0dd2009-05-22 14:03:28 -070098}
99}
100#endif
101
102
103