rsScript.h revision afb743aca56c18beb7ab924e75cb6e070ef3e55a
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 ProgramStore; 31 32class Script : public ObjectBase { 33public: 34 typedef void (* InvokeFunc_t)(void); 35 36 Script(Context *); 37 virtual ~Script(); 38 39 struct Enviroment_t { 40 int64_t mStartTimeMillis; 41 int64_t mLastDtTime; 42 const char* mTimeZone; 43 44 ObjectBaseRef<ProgramVertex> mVertex; 45 ObjectBaseRef<ProgramFragment> mFragment; 46 ObjectBaseRef<ProgramRaster> mRaster; 47 ObjectBaseRef<ProgramStore> mFragmentStore; 48 49 uint32_t mInvokeFunctionCount; 50 InvokeFunc_t *mInvokeFunctions; 51 uint32_t mFieldCount; 52 void ** mFieldAddress; 53 54 char * mScriptText; 55 uint32_t mScriptTextLength; 56 57 bool mIsThreadable; 58 }; 59 Enviroment_t mEnviroment; 60 61 void initSlots(); 62 void setSlot(uint32_t slot, Allocation *a); 63 void setVar(uint32_t slot, const void *val, uint32_t len); 64 65 virtual void runForEach(Context *rsc, 66 const Allocation * ain, 67 Allocation * aout, 68 const void * usr, 69 const RsScriptCall *sc = NULL) = 0; 70 71 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) = 0; 72 virtual void setupScript(Context *rsc) = 0; 73 virtual uint32_t run(Context *) = 0; 74protected: 75 ObjectBaseRef<Allocation> *mSlots; 76 ObjectBaseRef<const Type> *mTypes; 77 78}; 79 80 81} 82} 83#endif 84 85