Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011 The Android Open Source Project |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -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_FRAGMENT_STORE_H |
| 18 | #define ANDROID_RS_PROGRAM_FRAGMENT_STORE_H |
| 19 | |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 20 | #include "rsProgramBase.h" |
Alex Sakhartchouk | fb6b614 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 21 | #include "rsStream.h" |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 22 | |
Miao Wang | 82e135c | 2017-02-27 23:35:35 -0800 | [diff] [blame] | 23 | #include <vector> |
| 24 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 25 | // --------------------------------------------------------------------------- |
| 26 | namespace android { |
| 27 | namespace renderscript { |
| 28 | |
Jason Sams | ccc010b | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 29 | class ProgramStoreState; |
Alex Sakhartchouk | 407f8ca | 2011-09-23 17:05:04 -0700 | [diff] [blame] | 30 | /***************************************************************************** |
| 31 | * CAUTION |
| 32 | * |
| 33 | * Any layout changes for this class may require a corresponding change to be |
| 34 | * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains |
| 35 | * a partial copy of the information below. |
| 36 | * |
| 37 | *****************************************************************************/ |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 38 | class ProgramStore : public ProgramBase { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 39 | public: |
Jason Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 40 | struct Hal { |
| 41 | mutable void *drv; |
| 42 | |
| 43 | struct State { |
| 44 | bool ditherEnable; |
| 45 | |
| 46 | //bool blendEnable; |
| 47 | bool colorRWriteEnable; |
| 48 | bool colorGWriteEnable; |
| 49 | bool colorBWriteEnable; |
| 50 | bool colorAWriteEnable; |
| 51 | RsBlendSrcFunc blendSrc; |
| 52 | RsBlendDstFunc blendDst; |
| 53 | |
| 54 | //bool depthTestEnable; |
| 55 | bool depthWriteEnable; |
| 56 | RsDepthFunc depthFunc; |
| 57 | }; |
| 58 | State state; |
Jason Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 59 | }; |
| 60 | Hal mHal; |
| 61 | |
Alex Sakhartchouk | 407f8ca | 2011-09-23 17:05:04 -0700 | [diff] [blame] | 62 | virtual void setup(const Context *, ProgramStoreState *); |
| 63 | |
Jason Sams | e3150cf | 2012-07-24 18:10:20 -0700 | [diff] [blame] | 64 | virtual void serialize(Context *rsc, OStream *stream) const; |
Alex Sakhartchouk | 407f8ca | 2011-09-23 17:05:04 -0700 | [diff] [blame] | 65 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; } |
| 66 | static ProgramStore *createFromStream(Context *rsc, IStream *stream); |
| 67 | static ObjectBaseRef<ProgramStore> getProgramStore(Context *, |
| 68 | bool colorMaskR, bool colorMaskG, |
| 69 | bool colorMaskB, bool colorMaskA, |
| 70 | bool depthMask, bool ditherEnable, |
| 71 | RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc, |
| 72 | RsDepthFunc depthFunc); |
| 73 | void init(); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 74 | protected: |
Alex Sakhartchouk | c700e64 | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 75 | virtual void preDestroy() const; |
| 76 | virtual ~ProgramStore(); |
| 77 | |
| 78 | private: |
| 79 | ProgramStore(Context *, |
| 80 | bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA, |
| 81 | bool depthMask, bool ditherEnable, |
| 82 | RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc, |
| 83 | RsDepthFunc depthFunc); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 84 | }; |
| 85 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 86 | class ProgramStoreState { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 87 | public: |
Jason Sams | ccc010b | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 88 | ProgramStoreState(); |
| 89 | ~ProgramStoreState(); |
Jason Sams | 771565f | 2010-05-14 15:30:29 -0700 | [diff] [blame] | 90 | void init(Context *rsc); |
Jason Sams | f2649a9 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 91 | void deinit(Context *rsc); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 92 | |
Jason Sams | ccc010b | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 93 | ObjectBaseRef<ProgramStore> mDefault; |
| 94 | ObjectBaseRef<ProgramStore> mLast; |
Alex Sakhartchouk | c700e64 | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 95 | |
| 96 | // Cache of all existing store programs. |
Miao Wang | 82e135c | 2017-02-27 23:35:35 -0800 | [diff] [blame] | 97 | std::vector<ProgramStore *> mStorePrograms; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
Rahul Chaudhry | 7974fc0 | 2017-02-09 12:33:28 -0800 | [diff] [blame] | 100 | } // namespace renderscript |
| 101 | } // namespace android |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 102 | #endif |
Yang Ni | b8353c5 | 2015-02-14 18:00:59 -0800 | [diff] [blame] | 103 | |
| 104 | |
| 105 | |