rsScript.h revision be36bf3a76481737a7fa606a04144ceef80eb4f2
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_SCRIPT_H 18#define ANDROID_RS_SCRIPT_H 19 20#include "rsAllocation.h" 21 22 23// --------------------------------------------------------------------------- 24namespace android { 25namespace renderscript { 26 27class ProgramVertex; 28class ProgramFragment; 29class ProgramRaster; 30class ProgramFragmentStore; 31 32#define MAX_SCRIPT_BANKS 32 33 34class Script : public ObjectBase 35{ 36public: 37 typedef void (* InvokeFunc_t)(void); 38 39 Script(Context *); 40 virtual ~Script(); 41 42 struct Enviroment_t { 43 float mClearColor[4]; 44 float mClearDepth; 45 uint32_t mClearStencil; 46 47 uint32_t mStartTimeMillis; 48 const char* mTimeZone; 49 50 ObjectBaseRef<ProgramVertex> mVertex; 51 ObjectBaseRef<ProgramFragment> mFragment; 52 ObjectBaseRef<ProgramRaster> mRaster; 53 ObjectBaseRef<ProgramFragmentStore> mFragmentStore; 54 55 uint32_t mInvokeFunctionCount; 56 InvokeFunc_t *mInvokeFunctions; 57 uint32_t mFieldCount; 58 void ** mFieldAddress; 59 60 char * mScriptText; 61 uint32_t mScriptTextLength; 62 }; 63 Enviroment_t mEnviroment; 64 65 ObjectBaseRef<Allocation> mSlots[MAX_SCRIPT_BANKS]; 66 ObjectBaseRef<const Type> mTypes[MAX_SCRIPT_BANKS]; 67 bool mSlotWritable[MAX_SCRIPT_BANKS]; 68 69 void setVar(uint32_t slot, const void *val, uint32_t len); 70 71 virtual void setupScript() = 0; 72 virtual uint32_t run(Context *, uint32_t launchID) = 0; 73}; 74 75 76 77} 78} 79#endif 80 81