rsScript.h revision bad807405b2b9764372af1ad24bcfd4fb1f33d8e
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 struct Hal { 35 void * drv; 36 37 struct State { 38 ObjectBaseRef<const Type> type; 39 void * mallocPtr; 40 41 uint32_t usageFlags; 42 RsAllocationMipmapControl mipmapControl; 43 44 // Cached fields from the Type and Element 45 // to prevent pointer chasing in critical loops. 46 uint32_t dimensionX; 47 uint32_t dimensionY; 48 uint32_t dimensionZ; 49 uint32_t elementSizeBytes; 50 bool hasMipmaps; 51 bool hasFaces; 52 bool hasReferences; 53 }; 54 State state; 55 56 struct DriverInfo { 57 int mVersionMajor; 58 int mVersionMinor; 59 60 size_t exportedVariableCount; 61 size_t exportedFunctionCount; 62 size_t exportedPragmaCount; 63 char const **exportedPragmaKeyList; 64 char const **exportedPragmaValueList; 65 66 int (* root)(); 67 bool isThreadable; 68 }; 69 DriverInfo info; 70 }; 71 Hal mHal; 72 73 typedef void (* InvokeFunc_t)(void); 74 75 Script(Context *); 76 virtual ~Script(); 77 78 struct Enviroment_t { 79 int64_t mStartTimeMillis; 80 int64_t mLastDtTime; 81 const char* mTimeZone; 82 83 ObjectBaseRef<ProgramVertex> mVertex; 84 ObjectBaseRef<ProgramFragment> mFragment; 85 ObjectBaseRef<ProgramRaster> mRaster; 86 ObjectBaseRef<ProgramStore> mFragmentStore; 87 }; 88 Enviroment_t mEnviroment; 89 90 void initSlots(); 91 void setSlot(uint32_t slot, Allocation *a); 92 void setVar(uint32_t slot, const void *val, uint32_t len); 93 void setVarObj(uint32_t slot, ObjectBase *val); 94 95 virtual void runForEach(Context *rsc, 96 const Allocation * ain, 97 Allocation * aout, 98 const void * usr, 99 const RsScriptCall *sc = NULL) = 0; 100 101 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) = 0; 102 virtual void setupScript(Context *rsc) = 0; 103 virtual uint32_t run(Context *) = 0; 104protected: 105 ObjectBaseRef<Allocation> *mSlots; 106 ObjectBaseRef<const Type> *mTypes; 107 108}; 109 110 111} 112} 113#endif 114 115