rsClosure.h revision 062c287f573ecc06c38ee4295e5627e12c52ac3d
1#ifndef ANDROID_RENDERSCRIPT_CLOSURE_H_ 2#define ANDROID_RENDERSCRIPT_CLOSURE_H_ 3 4#include "rsDefines.h" 5#include "rsMap.h" 6#include "rsObjectBase.h" 7 8namespace android { 9namespace renderscript { 10 11class Allocation; 12class Context; 13class IDBase; 14class ObjectBase; 15class ScriptFieldID; 16class ScriptInvokeID; 17class ScriptKernelID; 18class Type; 19 20class Closure : public ObjectBase { 21 public: 22 Closure(Context* context, 23 const ScriptKernelID* kernelID, 24 Allocation* returnValue, 25 const int numValues, 26 const ScriptFieldID** fieldIDs, 27 const void** values, // Allocations or primitive (numeric) types 28 const size_t* sizes, // size for data type. -1 indicates an allocation. 29 const Closure** depClosures, 30 const ScriptFieldID** depFieldIDs); 31 Closure(Context* context, 32 const ScriptInvokeID* invokeID, 33 const void* params, 34 const size_t paramLength, 35 const size_t numValues, 36 const ScriptFieldID** fieldIDs, 37 const void** values, // Allocations or primitive (numeric) types 38 const size_t* sizes); // size for data type. -1 indicates an allocation. 39 40 virtual ~Closure(); 41 42 virtual void serialize(Context *rsc, OStream *stream) const {} 43 44 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_CLOSURE; } 45 46 void setArg(const uint32_t index, const void* value, const size_t size); 47 void setGlobal(const ScriptFieldID* fieldID, const void* value, 48 const size_t size); 49 50 Context* mContext; 51 52 // KernelId or InvokeID 53 const ObjectBaseRef<IDBase> mFunctionID; 54 // Flag indicating if this closure is for a kernel (true) or invocable 55 // function (false) 56 const bool mIsKernel; 57 58 // Values referrenced in arguments and globals cannot be futures. They must be 59 // either a known value or unbound value. 60 // For now, all arguments should be Allocations. 61 const void** mArgs; 62 size_t mNumArg; 63 64 // A global could be allocation or any primitive data type. 65 Map<const ScriptFieldID*, Pair<const void*, size_t>> mGlobals; 66 67 Allocation* mReturnValue; 68 69 // All the other closures which this closure depends on for one of its 70 // arguments, and the fields which it depends on. 71 Map<const Closure*, Map<int, const ObjectBaseRef<ScriptFieldID>*>*> mArgDeps; 72 73 // All the other closures that this closure depends on for one of its fields, 74 // and the fields that it depends on. 75 Map<const Closure*, Map<const ObjectBaseRef<ScriptFieldID>*, 76 const ObjectBaseRef<ScriptFieldID>*>*> mGlobalDeps; 77 78 const void* mParams; 79 const size_t mParamLength; 80}; 81 82} // namespace renderscript 83} // namespace android 84 85#endif // ANDROID_RENDERSCRIPT_CLOSURE_H_ 86