| Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 1 | #ifndef CPU_REF_CPUSCRIPTGROUP2IMPL_H_ |
| 2 | #define CPU_REF_CPUSCRIPTGROUP2IMPL_H_ |
| 3 | |
| 4 | #include <list> |
| 5 | |
| 6 | #include "rsd_cpu.h" |
| 7 | |
| 8 | using std::list; |
| 9 | |
| 10 | namespace android { |
| 11 | namespace renderscript { |
| 12 | |
| 13 | class Closure; |
| 14 | class RsdCpuScriptImpl; |
| 15 | class RsdCpuReferenceImpl; |
| 16 | class ScriptGroup2; |
| 17 | |
| 18 | struct RsExpandKernelParams; |
| 19 | |
| 20 | typedef void (*ExpandFuncTy)(const RsExpandKernelParams*, uint32_t, uint32_t, |
| 21 | uint32_t); |
| 22 | |
| 23 | class CPUClosure { |
| 24 | public: |
| 25 | CPUClosure(const Closure* closure, RsdCpuScriptImpl* si, ExpandFuncTy func, |
| 26 | const void* usrPtr, const size_t usrSize) : |
| 27 | mClosure(closure), mSi(si), mFunc(func), mUsrPtr(usrPtr), |
| 28 | mUsrSize(usrSize) {} |
| 29 | |
| 30 | // It's important to do forwarding here than inheritance for unbound value |
| 31 | // binding to work. |
| 32 | const Closure* mClosure; |
| 33 | RsdCpuScriptImpl* mSi; |
| 34 | const ExpandFuncTy mFunc; |
| 35 | const void* mUsrPtr; |
| 36 | const size_t mUsrSize; |
| 37 | }; |
| 38 | |
| 39 | class CpuScriptGroup2Impl : public RsdCpuReference::CpuScriptGroup2 { |
| 40 | public: |
| 41 | CpuScriptGroup2Impl(RsdCpuReferenceImpl *cpuRefImpl, const ScriptGroupBase* group); |
| 42 | virtual ~CpuScriptGroup2Impl(); |
| 43 | |
| 44 | bool init(); |
| 45 | virtual void execute(); |
| 46 | |
| 47 | private: |
| 48 | void setGlobalsForBatch(const list<CPUClosure*>& batch); |
| 49 | void runBatch(const list<CPUClosure*>& batch); |
| 50 | |
| 51 | RsdCpuReferenceImpl* mCpuRefImpl; |
| 52 | const ScriptGroup2* mGroup; |
| 53 | |
| 54 | list<list<CPUClosure*>*> mBatches; |
| 55 | }; |
| 56 | |
| 57 | } // namespace renderscript |
| 58 | } // namespace android |
| 59 | |
| 60 | #endif // CPU_REF_CPUSCRIPTGROUP2IMPL_H_ |