Jason Sams | 326e0dd | 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_H |
| 18 | #define ANDROID_RS_PROGRAM_FRAGMENT_H |
| 19 | |
| 20 | #include "rsProgram.h" |
| 21 | |
| 22 | // --------------------------------------------------------------------------- |
| 23 | namespace android { |
| 24 | namespace renderscript { |
| 25 | |
Jason Sams | cfb1d11 | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 26 | class ProgramFragmentState; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 27 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 28 | class ProgramFragment : public Program { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 29 | public: |
Jason Sams | f2e4fa2 | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 30 | ProgramFragment(Context *rsc, const char * shaderText, |
| 31 | uint32_t shaderLength, const uint32_t * params, |
| 32 | uint32_t paramLength); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 33 | virtual ~ProgramFragment(); |
| 34 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 35 | virtual void setupGL2(Context *, ProgramFragmentState *); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 36 | |
Alex Sakhartchouk | fb6b614 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 37 | virtual void serialize(OStream *stream) const; |
Alex Sakhartchouk | b825f67 | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 38 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_FRAGMENT; } |
Alex Sakhartchouk | fb6b614 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 39 | static ProgramFragment *createFromStream(Context *rsc, IStream *stream); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 40 | |
Alex Sakhartchouk | 383e5b1 | 2010-09-23 16:16:33 -0700 | [diff] [blame] | 41 | void setConstantColor(Context *, float, float, float, float); |
Jason Sams | 6445e52 | 2010-08-04 17:50:20 -0700 | [diff] [blame] | 42 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 43 | protected: |
Jason Sams | 6445e52 | 2010-08-04 17:50:20 -0700 | [diff] [blame] | 44 | float mConstantColor[4]; |
Alex Sakhartchouk | 660ccc7 | 2010-09-02 18:43:24 -0700 | [diff] [blame] | 45 | int32_t mTextureUniformIndexStart; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 46 | }; |
| 47 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 48 | class ProgramFragmentState { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 49 | public: |
| 50 | ProgramFragmentState(); |
| 51 | ~ProgramFragmentState(); |
| 52 | |
| 53 | ProgramFragment *mPF; |
Jason Sams | 771565f | 2010-05-14 15:30:29 -0700 | [diff] [blame] | 54 | void init(Context *rsc); |
Jason Sams | f2649a9 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 55 | void deinit(Context *rsc); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 56 | |
Jason Sams | 8ce125b | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 57 | ObjectBaseRef<ProgramFragment> mDefault; |
Jason Sams | a0a1b6f | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 58 | Vector<ProgramFragment *> mPrograms; |
Jason Sams | cfb1d11 | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 59 | |
| 60 | ObjectBaseRef<ProgramFragment> mLast; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | #endif |
| 66 | |
| 67 | |
| 68 | |
| 69 | |