rsProgramFragment.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_FRAGMENT_H 18#define ANDROID_RS_PROGRAM_FRAGMENT_H 19 20#include "rsProgram.h" 21 22// --------------------------------------------------------------------------- 23namespace android { 24namespace renderscript { 25 26class ProgramFragmentState; 27 28class ProgramFragment : public Program 29{ 30public: 31 ProgramFragment(Context *, const uint32_t * params, uint32_t paramLength); 32 ProgramFragment(Context *rsc, const char * shaderText, 33 uint32_t shaderLength, const uint32_t * params, 34 uint32_t paramLength); 35 virtual ~ProgramFragment(); 36 37 virtual void setupGL(const Context *, ProgramFragmentState *); 38 virtual void setupGL2(const Context *, ProgramFragmentState *, ShaderCache *sc); 39 40 virtual void createShader(); 41 virtual void loadShader(Context *rsc); 42 virtual void init(Context *rsc); 43 virtual void serialize(OStream *stream) const; 44 virtual A3DClassID getClassId() const { return A3D_CLASS_ID_PROGRAM_FRAGMENT; } 45 static ProgramFragment *createFromStream(Context *rsc, IStream *stream); 46 47protected: 48 // Hacks to create a program for now 49 uint32_t mTextureFormats[MAX_TEXTURE]; 50 uint32_t mTextureDimensions[MAX_TEXTURE]; 51 RsTexEnvMode mEnvModes[MAX_TEXTURE]; 52 uint32_t mTextureEnableMask; 53 bool mPointSpriteEnable; 54}; 55 56class ProgramFragmentState 57{ 58public: 59 ProgramFragmentState(); 60 ~ProgramFragmentState(); 61 62 ProgramFragment *mPF; 63 void init(Context *rsc); 64 void deinit(Context *rsc); 65 66 ObjectBaseRef<Type> mTextureTypes[ProgramFragment::MAX_TEXTURE]; 67 ObjectBaseRef<ProgramFragment> mDefault; 68 Vector<ProgramFragment *> mPrograms; 69 70 ObjectBaseRef<ProgramFragment> mLast; 71}; 72 73 74} 75} 76#endif 77 78 79 80 81