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