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 | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 33 | ProgramVertex(Context *, Element *in, Element *out); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 34 | virtual ~ProgramVertex(); |
| 35 | |
Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 36 | virtual void setupGL(const Context *rsc, ProgramVertexState *state); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 37 | |
| 38 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 39 | void setTextureMatrixEnable(bool e) {mTextureMatrixEnable = e;} |
Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 40 | void addLight(const Light *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 41 | |
Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 42 | void setProjectionMatrix(const rsc_Matrix *) const; |
| 43 | void setModelviewMatrix(const rsc_Matrix *) const; |
| 44 | void setTextureMatrix(const rsc_Matrix *) const; |
| 45 | |
Jason Sams | e9ad9a7 | 2009-09-30 17:36:20 -0700 | [diff] [blame] | 46 | void transformToScreen(const Context *, float *v4out, const float *v3in) const; |
| 47 | |
| 48 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 49 | protected: |
Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 50 | uint32_t mLightCount; |
Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 51 | ObjectBaseRef<const Light> mLights[MAX_LIGHTS]; |
| 52 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 53 | // Hacks to create a program for now |
| 54 | bool mTextureMatrixEnable; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 58 | class ProgramVertexState |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 59 | { |
| 60 | public: |
| 61 | ProgramVertexState(); |
| 62 | ~ProgramVertexState(); |
| 63 | |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 64 | void init(Context *rsc, int32_t w, int32_t h); |
Jason Sams | 61f08d6 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 65 | void deinit(Context *rsc); |
Jason Sams | eb4b031 | 2009-11-12 16:09:45 -0800 | [diff] [blame] | 66 | void updateSize(Context *rsc, int32_t w, int32_t h); |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 67 | |
| 68 | ObjectBaseRef<ProgramVertex> mDefault; |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 69 | ObjectBaseRef<ProgramVertex> mLast; |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 70 | ObjectBaseRef<Allocation> mDefaultAlloc; |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 71 | |
Jason Sams | 61f08d6 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 72 | ObjectBaseRef<Type> mAllocType; |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 73 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 74 | ProgramVertex *mPV; |
| 75 | |
| 76 | //ObjectBaseRef<Type> mTextureTypes[ProgramFragment::MAX_TEXTURE]; |
| 77 | |
| 78 | |
| 79 | }; |
| 80 | |
| 81 | |
| 82 | } |
| 83 | } |
| 84 | #endif |
| 85 | |
| 86 | |