rsProgramVertex.h revision fb6b614bcea88a587a7ea4530be45ff0ffa0210e
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// --------------------------------------------------------------------------- 23namespace android { 24namespace renderscript { 25 26class ProgramVertexState; 27 28class ProgramVertex : public Program 29{ 30public: 31 const static uint32_t MAX_LIGHTS = 8; 32 33 ProgramVertex(Context *,const char * shaderText, uint32_t shaderLength, 34 const uint32_t * params, uint32_t paramLength); 35 ProgramVertex(Context *, bool texMat); 36 virtual ~ProgramVertex(); 37 38 virtual void setupGL(const Context *rsc, ProgramVertexState *state); 39 virtual void setupGL2(const Context *rsc, ProgramVertexState *state, ShaderCache *sc); 40 41 42 void setTextureMatrixEnable(bool e) {mTextureMatrixEnable = e;} 43 void addLight(const Light *); 44 45 void setProjectionMatrix(const rsc_Matrix *) const; 46 void setModelviewMatrix(const rsc_Matrix *) const; 47 void setTextureMatrix(const rsc_Matrix *) const; 48 49 void transformToScreen(const Context *, float *v4out, const float *v3in) const; 50 51 virtual void createShader(); 52 virtual void loadShader(Context *); 53 virtual void init(Context *); 54 55 virtual void serialize(OStream *stream) const; 56 virtual A3DClassID getClassId() const { return A3D_CLASS_ID_PROGRAM_VERTEX; } 57 static ProgramVertex *createFromStream(Context *rsc, IStream *stream); 58 59protected: 60 uint32_t mLightCount; 61 ObjectBaseRef<const Light> mLights[MAX_LIGHTS]; 62 63 // Hacks to create a program for now 64 bool mTextureMatrixEnable; 65 66private: 67 void initAddUserElement(const Element *e, String8 *names, uint32_t *count, const char *prefix); 68}; 69 70 71class ProgramVertexState 72{ 73public: 74 ProgramVertexState(); 75 ~ProgramVertexState(); 76 77 void init(Context *rsc); 78 void deinit(Context *rsc); 79 void updateSize(Context *rsc); 80 81 ObjectBaseRef<ProgramVertex> mDefault; 82 ObjectBaseRef<ProgramVertex> mLast; 83 ObjectBaseRef<Allocation> mDefaultAlloc; 84 85 ObjectBaseRef<Type> mAllocType; 86 87 88 float color[4]; 89}; 90 91 92} 93} 94#endif 95 96 97