rsScript.h revision 93eacc7ce0aad4314b4cb41a281f59ce54bb3286
1/* 2 * Copyright (C) 2009-2012 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 27#ifndef RS_COMPATIBILITY_LIB 28class ProgramVertex; 29class ProgramFragment; 30class ProgramRaster; 31class ProgramStore; 32#endif 33 34class ScriptKernelID : public ObjectBase { 35public: 36 ScriptKernelID(Context *rsc, Script *s, int slot, int sig); 37 virtual ~ScriptKernelID(); 38 39 virtual void serialize(Context *rsc, OStream *stream) const; 40 virtual RsA3DClassID getClassId() const; 41 42 Script *mScript; 43 int mSlot; 44 bool mHasKernelInput; 45 bool mHasKernelOutput; 46}; 47 48class ScriptFieldID : public ObjectBase { 49public: 50 ScriptFieldID(Context *rsc, Script *s, int slot); 51 virtual ~ScriptFieldID(); 52 53 virtual void serialize(Context *rsc, OStream *stream) const; 54 virtual RsA3DClassID getClassId() const; 55 56 Script *mScript; 57 int mSlot; 58}; 59 60class Script : public ObjectBase { 61public: 62 63 struct Hal { 64 void * drv; 65 66 struct DriverInfo { 67 int mVersionMajor; 68 int mVersionMinor; 69 70 size_t exportedVariableCount; 71 size_t exportedFunctionCount; 72 size_t exportedPragmaCount; 73 char const **exportedPragmaKeyList; 74 char const **exportedPragmaValueList; 75 76 int (* root)(); 77 }; 78 DriverInfo info; 79 }; 80 Hal mHal; 81 82 typedef void (* InvokeFunc_t)(void); 83 84 Script(Context *); 85 virtual ~Script(); 86 87 struct Enviroment_t { 88 int64_t mStartTimeMillis; 89 mutable int64_t mLastDtTime; 90 91#ifndef RS_COMPATIBILITY_LIB 92 ObjectBaseRef<ProgramVertex> mVertex; 93 ObjectBaseRef<ProgramFragment> mFragment; 94 ObjectBaseRef<ProgramRaster> mRaster; 95 ObjectBaseRef<ProgramStore> mFragmentStore; 96#endif 97 }; 98 Enviroment_t mEnviroment; 99 100 void setSlot(uint32_t slot, Allocation *a); 101 void setVar(uint32_t slot, const void *val, size_t len); 102 void setVar(uint32_t slot, const void *val, size_t len, Element *e, 103 const size_t *dims, size_t dimLen); 104 void setVarObj(uint32_t slot, ObjectBase *val); 105 106 virtual bool freeChildren(); 107 108 virtual void runForEach(Context *rsc, 109 uint32_t slot, 110 const Allocation * ain, 111 Allocation * aout, 112 const void * usr, 113 size_t usrBytes, 114 const RsScriptCall *sc = NULL) = 0; 115 116 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) = 0; 117 virtual void setupScript(Context *rsc) = 0; 118 virtual uint32_t run(Context *) = 0; 119protected: 120 bool mInitialized; 121 ObjectBaseRef<Allocation> *mSlots; 122 ObjectBaseRef<const Type> *mTypes; 123 124}; 125 126 127} 128} 129#endif 130 131