blob: b9244a93af12731f4c661359d4c6b56050f3c67d [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
Miao Wang82e135c2017-02-27 23:35:35 -080022#include <vector>
23
Jason Sams5fd09d82009-09-23 13:57:02 -070024// ---------------------------------------------------------------------------
25namespace android {
26namespace renderscript {
27
28class ProgramRasterState;
Alex Sakhartchouk407f8ca2011-09-23 17:05:04 -070029/*****************************************************************************
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 *****************************************************************************/
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070037class ProgramRaster : public ProgramBase {
Jason Sams5fd09d82009-09-23 13:57:02 -070038public:
Jason Sams721acc42011-04-06 11:23:54 -070039 struct Hal {
40 mutable void *drv;
41
42 struct State {
Jason Sams721acc42011-04-06 11:23:54 -070043 bool pointSprite;
Jason Sams721acc42011-04-06 11:23:54 -070044 RsCullMode cull;
45 };
46 State state;
47 };
48 Hal mHal;
Jason Sams5fd09d82009-09-23 13:57:02 -070049
Alex Sakhartchouk407f8ca2011-09-23 17:05:04 -070050 virtual void setup(const Context *, ProgramRasterState *);
Jason Samse3150cf2012-07-24 18:10:20 -070051 virtual void serialize(Context *rsc, OStream *stream) const;
Alex Sakhartchouk407f8ca2011-09-23 17:05:04 -070052 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);
Jason Sams5fd09d82009-09-23 13:57:02 -070058protected:
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070059 virtual void preDestroy() const;
60 virtual ~ProgramRaster();
61
62private:
63 ProgramRaster(Context *rsc,
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070064 bool pointSprite,
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070065 RsCullMode cull);
66
Jason Sams5fd09d82009-09-23 13:57:02 -070067};
68
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080069class ProgramRasterState {
Jason Sams5fd09d82009-09-23 13:57:02 -070070public:
71 ProgramRasterState();
72 ~ProgramRasterState();
Jason Sams771565f2010-05-14 15:30:29 -070073 void init(Context *rsc);
Jason Samsf2649a92009-09-25 16:37:33 -070074 void deinit(Context *rsc);
Jason Sams5fd09d82009-09-23 13:57:02 -070075
76 ObjectBaseRef<ProgramRaster> mDefault;
77 ObjectBaseRef<ProgramRaster> mLast;
Alex Sakhartchoukc700e642011-08-16 13:09:46 -070078
79 // Cache of all existing raster programs.
Miao Wang82e135c2017-02-27 23:35:35 -080080 std::vector<ProgramRaster *> mRasterPrograms;
Jason Sams5fd09d82009-09-23 13:57:02 -070081};
82
83
Rahul Chaudhry7974fc02017-02-09 12:33:28 -080084} // namespace renderscript
85} // namespace android
Jason Sams5fd09d82009-09-23 13:57:02 -070086#endif
Yang Nib8353c52015-02-14 18:00:59 -080087
88
89
90