blob: e9a524b9b100b722fac0ab866b058103ec5a60dc [file] [log] [blame]
Jason Sams5fd09d82009-09-23 13:57:02 -07001/*
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -07002 * Copyright (C) 2009-2011 The Android Open Source Project
Jason Sams5fd09d82009-09-23 13:57:02 -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_RASTER_H
18#define ANDROID_RS_PROGRAM_RASTER_H
19
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070020#include "rsProgramBase.h"
Jason Sams5fd09d82009-09-23 13:57:02 -070021
22// ---------------------------------------------------------------------------
23namespace android {
24namespace renderscript {
25
26class ProgramRasterState;
Alex Sakhartchouk407f8ca2011-09-23 17:05:04 -070027/*****************************************************************************
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 *****************************************************************************/
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070035class ProgramRaster : public ProgramBase {
Jason Sams5fd09d82009-09-23 13:57:02 -070036public:
Jason Sams721acc42011-04-06 11:23:54 -070037 struct Hal {
38 mutable void *drv;
39
40 struct State {
Jason Sams721acc42011-04-06 11:23:54 -070041 bool pointSprite;
Jason Sams721acc42011-04-06 11:23:54 -070042 RsCullMode cull;
43 };
44 State state;
45 };
46 Hal mHal;
Jason Sams5fd09d82009-09-23 13:57:02 -070047
Alex Sakhartchouk407f8ca2011-09-23 17:05:04 -070048 virtual void setup(const Context *, ProgramRasterState *);
Jason Samse3150cf2012-07-24 18:10:20 -070049 virtual void serialize(Context *rsc, OStream *stream) const;
Alex Sakhartchouk407f8ca2011-09-23 17:05:04 -070050 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);
Jason Sams5fd09d82009-09-23 13:57:02 -070056protected:
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070057 virtual void preDestroy() const;
58 virtual ~ProgramRaster();
59
60private:
61 ProgramRaster(Context *rsc,
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070062 bool pointSprite,
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070063 RsCullMode cull);
64
Jason Sams5fd09d82009-09-23 13:57:02 -070065};
66
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080067class ProgramRasterState {
Jason Sams5fd09d82009-09-23 13:57:02 -070068public:
69 ProgramRasterState();
70 ~ProgramRasterState();
Jason Sams771565f2010-05-14 15:30:29 -070071 void init(Context *rsc);
Jason Samsf2649a92009-09-25 16:37:33 -070072 void deinit(Context *rsc);
Jason Sams5fd09d82009-09-23 13:57:02 -070073
74 ObjectBaseRef<ProgramRaster> mDefault;
75 ObjectBaseRef<ProgramRaster> mLast;
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070076
77 // Cache of all existing raster programs.
78 Vector<ProgramRaster *> mRasterPrograms;
Jason Sams5fd09d82009-09-23 13:57:02 -070079};
80
81
82}
83}
84#endif
85
86
87
88