blob: e21f039678b3db87605ed37d16b264dc1ce7192c [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;
Jason Sams326e0dd2009-05-22 14:03:28 -070028
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070029class ProgramStore : public ProgramBase {
Jason Sams326e0dd2009-05-22 14:03:28 -070030public:
Jason Sams721acc42011-04-06 11:23:54 -070031 virtual void setup(const Context *, ProgramStoreState *);
Jason Sams326e0dd2009-05-22 14:03:28 -070032
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070033 virtual void serialize(OStream *stream) const;
Alex Sakhartchoukb825f672010-06-04 10:06:50 -070034 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; }
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070035 static ProgramStore *createFromStream(Context *rsc, IStream *stream);
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070036 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);
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070042
Jason Sams8feea4e2011-03-18 15:03:25 -070043 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;
Jason Sams8feea4e2011-03-18 15:03:25 -070064 };
65 Hal mHal;
66
Jason Sams326e0dd2009-05-22 14:03:28 -070067protected:
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070068 virtual void preDestroy() const;
69 virtual ~ProgramStore();
70
71private:
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);
Jason Sams326e0dd2009-05-22 14:03:28 -070077};
78
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080079class ProgramStoreState {
Jason Sams326e0dd2009-05-22 14:03:28 -070080public:
Jason Samsccc010b2010-05-13 18:30:11 -070081 ProgramStoreState();
82 ~ProgramStoreState();
Jason Sams771565f2010-05-14 15:30:29 -070083 void init(Context *rsc);
Jason Samsf2649a92009-09-25 16:37:33 -070084 void deinit(Context *rsc);
Jason Sams326e0dd2009-05-22 14:03:28 -070085
Jason Samsccc010b2010-05-13 18:30:11 -070086 ObjectBaseRef<ProgramStore> mDefault;
87 ObjectBaseRef<ProgramStore> mLast;
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070088
89 // Cache of all existing store programs.
90 Vector<ProgramStore *> mStorePrograms;
Jason Sams326e0dd2009-05-22 14:03:28 -070091};
92
Jason Sams326e0dd2009-05-22 14:03:28 -070093}
94}
95#endif
96
97
98