Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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_FRAGMENT_STORE_H |
| 18 | #define ANDROID_RS_PROGRAM_FRAGMENT_STORE_H |
| 19 | |
| 20 | #include "rsProgram.h" |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 21 | #include "rsStream.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 22 | |
| 23 | // --------------------------------------------------------------------------- |
| 24 | namespace android { |
| 25 | namespace renderscript { |
| 26 | |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 27 | class ProgramStoreState; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 28 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 29 | class ProgramStore : public Program { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 30 | public: |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 31 | ProgramStore(Context *); |
| 32 | virtual ~ProgramStore(); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 33 | |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 34 | virtual void setupGL2(const Context *, ProgramStoreState *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 35 | |
| 36 | void setDepthFunc(RsDepthFunc); |
| 37 | void setDepthMask(bool); |
| 38 | |
| 39 | void setBlendFunc(RsBlendSrcFunc src, RsBlendDstFunc dst); |
| 40 | void setColorMask(bool, bool, bool, bool); |
| 41 | |
| 42 | void setDitherEnable(bool); |
| 43 | |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 44 | virtual void serialize(OStream *stream) const; |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 45 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; } |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 46 | static ProgramStore *createFromStream(Context *rsc, IStream *stream); |
| 47 | |
Jason Sams | 48f5056 | 2011-03-18 15:03:25 -0700 | [diff] [blame^] | 48 | void init(); |
| 49 | |
| 50 | struct Hal { |
| 51 | mutable void *drv; |
| 52 | |
| 53 | struct State { |
| 54 | bool ditherEnable; |
| 55 | |
| 56 | //bool blendEnable; |
| 57 | bool colorRWriteEnable; |
| 58 | bool colorGWriteEnable; |
| 59 | bool colorBWriteEnable; |
| 60 | bool colorAWriteEnable; |
| 61 | RsBlendSrcFunc blendSrc; |
| 62 | RsBlendDstFunc blendDst; |
| 63 | |
| 64 | //bool depthTestEnable; |
| 65 | bool depthWriteEnable; |
| 66 | RsDepthFunc depthFunc; |
| 67 | }; |
| 68 | State state; |
| 69 | |
| 70 | |
| 71 | }; |
| 72 | Hal mHal; |
| 73 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 74 | protected: |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 77 | class ProgramStoreState { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 78 | public: |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 79 | ProgramStoreState(); |
| 80 | ~ProgramStoreState(); |
Jason Sams | f603d21 | 2010-05-14 15:30:29 -0700 | [diff] [blame] | 81 | void init(Context *rsc); |
Jason Sams | 61f08d6 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 82 | void deinit(Context *rsc); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 83 | |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 84 | ObjectBaseRef<ProgramStore> mDefault; |
| 85 | ObjectBaseRef<ProgramStore> mLast; |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 86 | |
| 87 | |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 88 | ProgramStore *mPFS; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 91 | } |
| 92 | } |
| 93 | #endif |
| 94 | |
| 95 | |
| 96 | |