1 /*
2  * Copyright (C) 2009-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_RASTER_H
18 #define ANDROID_RS_PROGRAM_RASTER_H
19 
20 #include "rsProgramBase.h"
21 
22 #include <vector>
23 
24 // ---------------------------------------------------------------------------
25 namespace android {
26 namespace renderscript {
27 
28 class ProgramRasterState;
29 /*****************************************************************************
30  * CAUTION
31  *
32  * Any layout changes for this class may require a corresponding change to be
33  * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
34  * a partial copy of the information below.
35  *
36  *****************************************************************************/
37 class ProgramRaster : public ProgramBase {
38 public:
39     struct Hal {
40         mutable void *drv;
41 
42         struct State {
43             bool pointSprite;
44             RsCullMode cull;
45         };
46         State state;
47     };
48     Hal mHal;
49 
50     virtual void setup(const Context *, ProgramRasterState *);
51     virtual void serialize(Context *rsc, OStream *stream) const;
getClassId()52     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_RASTER; }
53     static ProgramRaster *createFromStream(Context *rsc, IStream *stream);
54 
55     static ObjectBaseRef<ProgramRaster> getProgramRaster(Context *rsc,
56                                                          bool pointSprite,
57                                                          RsCullMode cull);
58 protected:
59     virtual void preDestroy() const;
60     virtual ~ProgramRaster();
61 
62 private:
63     ProgramRaster(Context *rsc,
64                   bool pointSprite,
65                   RsCullMode cull);
66 
67 };
68 
69 class ProgramRasterState {
70 public:
71     ProgramRasterState();
72     ~ProgramRasterState();
73     void init(Context *rsc);
74     void deinit(Context *rsc);
75 
76     ObjectBaseRef<ProgramRaster> mDefault;
77     ObjectBaseRef<ProgramRaster> mLast;
78 
79     // Cache of all existing raster programs.
80     std::vector<ProgramRaster *> mRasterPrograms;
81 };
82 
83 
84 } // namespace renderscript
85 } // namespace android
86 #endif
87 
88 
89 
90 
91