| 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_VERTEX_H | 
 | 18 | #define ANDROID_RS_PROGRAM_VERTEX_H | 
 | 19 |  | 
 | 20 | #include "rsProgram.h" | 
 | 21 |  | 
 | 22 | // --------------------------------------------------------------------------- | 
 | 23 | namespace android { | 
 | 24 | namespace renderscript { | 
 | 25 |  | 
| Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 26 | class ProgramVertexState; | 
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 27 |  | 
 | 28 | class ProgramVertex : public Program | 
 | 29 | { | 
 | 30 | public: | 
| Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 31 |     const static uint32_t MAX_LIGHTS = 8; | 
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 32 |  | 
| Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 33 |     ProgramVertex(Context *,const char * shaderText, uint32_t shaderLength, | 
 | 34 |                   const uint32_t * params, uint32_t paramLength); | 
 | 35 |     ProgramVertex(Context *, bool texMat); | 
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 36 |     virtual ~ProgramVertex(); | 
 | 37 |  | 
| Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 38 |     virtual void setupGL2(const Context *rsc, ProgramVertexState *state, ShaderCache *sc); | 
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 39 |  | 
 | 40 |  | 
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 41 |     void setTextureMatrixEnable(bool e) {mTextureMatrixEnable = e;} | 
| Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 42 |     void addLight(const Light *); | 
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 43 |  | 
| Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 44 |     void setProjectionMatrix(const rsc_Matrix *) const; | 
| Alex Sakhartchouk | cbed752 | 2010-08-16 17:40:10 -0700 | [diff] [blame] | 45 |     void getProjectionMatrix(rsc_Matrix *) const; | 
| Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 46 |     void setModelviewMatrix(const rsc_Matrix *) const; | 
 | 47 |     void setTextureMatrix(const rsc_Matrix *) const; | 
 | 48 |  | 
| Jason Sams | e9ad9a7 | 2009-09-30 17:36:20 -0700 | [diff] [blame] | 49 |     void transformToScreen(const Context *, float *v4out, const float *v3in) const; | 
 | 50 |  | 
| Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 51 |     virtual void createShader(); | 
| Jason Sams | 5dad8b4 | 2009-12-15 19:10:11 -0800 | [diff] [blame] | 52 |     virtual void loadShader(Context *); | 
| Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 53 |     virtual void init(Context *); | 
 | 54 |  | 
| Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 55 |     virtual void serialize(OStream *stream) const; | 
| Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 56 |     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_VERTEX; } | 
| Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 57 |     static ProgramVertex *createFromStream(Context *rsc, IStream *stream); | 
| Jason Sams | e9ad9a7 | 2009-09-30 17:36:20 -0700 | [diff] [blame] | 58 |  | 
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 59 | protected: | 
| Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 60 |     uint32_t mLightCount; | 
| Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 61 |     ObjectBaseRef<const Light> mLights[MAX_LIGHTS]; | 
 | 62 |  | 
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 63 |     // Hacks to create a program for now | 
 | 64 |     bool mTextureMatrixEnable; | 
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 65 | }; | 
 | 66 |  | 
 | 67 |  | 
| Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 68 | class ProgramVertexState | 
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 69 | { | 
 | 70 | public: | 
 | 71 |     ProgramVertexState(); | 
 | 72 |     ~ProgramVertexState(); | 
 | 73 |  | 
| Jason Sams | f603d21 | 2010-05-14 15:30:29 -0700 | [diff] [blame] | 74 |     void init(Context *rsc); | 
| Jason Sams | 61f08d6 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 75 |     void deinit(Context *rsc); | 
| Jason Sams | f603d21 | 2010-05-14 15:30:29 -0700 | [diff] [blame] | 76 |     void updateSize(Context *rsc); | 
| Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 77 |  | 
 | 78 |     ObjectBaseRef<ProgramVertex> mDefault; | 
| Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 79 |     ObjectBaseRef<ProgramVertex> mLast; | 
| Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 80 |     ObjectBaseRef<Allocation> mDefaultAlloc; | 
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 81 | }; | 
 | 82 |  | 
 | 83 |  | 
 | 84 | } | 
 | 85 | } | 
 | 86 | #endif | 
 | 87 |  | 
 | 88 |  |