blob: 09d7d5432c9a5a4f74a0a6a1a6a73dc0b4d3a8c8 [file] [log] [blame]
Jason Samsebfb4362009-09-23 13:57:02 -07001/*
Alex Sakhartchouk43850542011-05-05 16:56:27 -07002 * Copyright (C) 2009-2011 The Android Open Source Project
Jason Samsebfb4362009-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 Sakhartchouk43850542011-05-05 16:56:27 -070020#include "rsProgramBase.h"
Jason Samsebfb4362009-09-23 13:57:02 -070021
22// ---------------------------------------------------------------------------
23namespace android {
24namespace renderscript {
25
26class ProgramRasterState;
27
Alex Sakhartchouk43850542011-05-05 16:56:27 -070028class ProgramRaster : public ProgramBase {
Jason Samsebfb4362009-09-23 13:57:02 -070029public:
Jason Sams331bf9b2011-04-06 11:23:54 -070030 virtual void setup(const Context *, ProgramRasterState *);
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -070031 virtual void serialize(OStream *stream) const;
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070032 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_RASTER; }
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -070033 static ProgramRaster *createFromStream(Context *rsc, IStream *stream);
Jason Samsebfb4362009-09-23 13:57:02 -070034
Alex Sakhartchouk117abdb2011-08-16 13:09:46 -070035 static ObjectBaseRef<ProgramRaster> getProgramRaster(Context *rsc,
36 bool pointSmooth,
37 bool lineSmooth,
38 bool pointSprite,
39 float lineWidth,
40 RsCullMode cull);
Jason Sams331bf9b2011-04-06 11:23:54 -070041 struct Hal {
42 mutable void *drv;
43
44 struct State {
45 bool pointSmooth;
46 bool lineSmooth;
47 bool pointSprite;
48 float lineWidth;
49 RsCullMode cull;
50 };
51 State state;
52 };
53 Hal mHal;
Jason Samsebfb4362009-09-23 13:57:02 -070054
55protected:
Alex Sakhartchouk117abdb2011-08-16 13:09:46 -070056 virtual void preDestroy() const;
57 virtual ~ProgramRaster();
58
59private:
60 ProgramRaster(Context *rsc,
61 bool pointSmooth,
62 bool lineSmooth,
63 bool pointSprite,
64 float lineWidth,
65 RsCullMode cull);
66
Jason Samsebfb4362009-09-23 13:57:02 -070067};
68
Alex Sakhartchouked9f2102010-11-09 17:00:54 -080069class ProgramRasterState {
Jason Samsebfb4362009-09-23 13:57:02 -070070public:
71 ProgramRasterState();
72 ~ProgramRasterState();
Jason Samsf603d212010-05-14 15:30:29 -070073 void init(Context *rsc);
Jason Sams61f08d62009-09-25 16:37:33 -070074 void deinit(Context *rsc);
Jason Samsebfb4362009-09-23 13:57:02 -070075
76 ObjectBaseRef<ProgramRaster> mDefault;
77 ObjectBaseRef<ProgramRaster> mLast;
Alex Sakhartchouk117abdb2011-08-16 13:09:46 -070078
79 // Cache of all existing raster programs.
80 Vector<ProgramRaster *> mRasterPrograms;
Jason Samsebfb4362009-09-23 13:57:02 -070081};
82
83
84}
85}
86#endif
87
88
89
90