Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 1 | /* |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 2 | * Copyright (C) 2009-2011 The Android Open Source Project |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 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 | |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 20 | #include "rsProgramBase.h" |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 21 | |
| 22 | // --------------------------------------------------------------------------- |
| 23 | namespace android { |
| 24 | namespace renderscript { |
| 25 | |
| 26 | class ProgramRasterState; |
Alex Sakhartchouk | 407f8ca | 2011-09-23 17:05:04 -0700 | [diff] [blame] | 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 | *****************************************************************************/ |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 35 | class ProgramRaster : public ProgramBase { |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 36 | public: |
Jason Sams | 721acc4 | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 37 | struct Hal { |
| 38 | mutable void *drv; |
| 39 | |
| 40 | struct State { |
Jason Sams | 721acc4 | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 41 | bool pointSprite; |
Jason Sams | 721acc4 | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 42 | RsCullMode cull; |
| 43 | }; |
| 44 | State state; |
| 45 | }; |
| 46 | Hal mHal; |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 47 | |
Alex Sakhartchouk | 407f8ca | 2011-09-23 17:05:04 -0700 | [diff] [blame] | 48 | virtual void setup(const Context *, ProgramRasterState *); |
Jason Sams | e3150cf | 2012-07-24 18:10:20 -0700 | [diff] [blame] | 49 | virtual void serialize(Context *rsc, OStream *stream) const; |
Alex Sakhartchouk | 407f8ca | 2011-09-23 17:05:04 -0700 | [diff] [blame] | 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); |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 56 | protected: |
Alex Sakhartchouk | c700e64 | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 57 | virtual void preDestroy() const; |
| 58 | virtual ~ProgramRaster(); |
| 59 | |
| 60 | private: |
| 61 | ProgramRaster(Context *rsc, |
Alex Sakhartchouk | c700e64 | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 62 | bool pointSprite, |
Alex Sakhartchouk | c700e64 | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 63 | RsCullMode cull); |
| 64 | |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 67 | class ProgramRasterState { |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 68 | public: |
| 69 | ProgramRasterState(); |
| 70 | ~ProgramRasterState(); |
Jason Sams | 771565f | 2010-05-14 15:30:29 -0700 | [diff] [blame] | 71 | void init(Context *rsc); |
Jason Sams | f2649a9 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 72 | void deinit(Context *rsc); |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 73 | |
| 74 | ObjectBaseRef<ProgramRaster> mDefault; |
| 75 | ObjectBaseRef<ProgramRaster> mLast; |
Alex Sakhartchouk | c700e64 | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 76 | |
| 77 | // Cache of all existing raster programs. |
| 78 | Vector<ProgramRaster *> mRasterPrograms; |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | |
| 82 | } |
| 83 | } |
| 84 | #endif |
| 85 | |
| 86 | |
| 87 | |
| 88 | |