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 44protected: 45 // Hacks to create a program for now 46 uint32_t mTextureFormats[MAX_TEXTURE]; 47 uint32_t mTextureDimensions[MAX_TEXTURE]; 48 RsTexEnvMode mEnvModes[MAX_TEXTURE]; 49 uint32_t mTextureEnableMask; 50 bool mPointSpriteEnable; 51}; 52 53class ProgramFragmentState 54{ 55public: 56 ProgramFragmentState(); 57 ~ProgramFragmentState(); 58 59 ProgramFragment *mPF; 60 void init(Context *rsc, int32_t w, int32_t h); 61 void deinit(Context *rsc); 62 63 ObjectBaseRef<Type> mTextureTypes[ProgramFragment::MAX_TEXTURE]; 64 ObjectBaseRef<ProgramFragment> mDefault; 65 Vector<ProgramFragment *> mPrograms; 66 67 ObjectBaseRef<ProgramFragment> mLast; 68}; 69 70 71} 72} 73#endif 74 75 76 77 78