blob: 6cb72a65ceb2b57346489484e18aed13b5383e40 [file] [log] [blame]
Yang Ni1ffd86b2015-01-07 09:16:40 -08001#ifndef CPU_REF_CPUSCRIPTGROUP2IMPL_H_
2#define CPU_REF_CPUSCRIPTGROUP2IMPL_H_
3
4#include <list>
5
6#include "rsd_cpu.h"
7
8using std::list;
9
10namespace android {
11namespace renderscript {
12
13class Closure;
14class RsdCpuScriptImpl;
15class RsdCpuReferenceImpl;
16class ScriptGroup2;
17
18struct RsExpandKernelParams;
19
20typedef void (*ExpandFuncTy)(const RsExpandKernelParams*, uint32_t, uint32_t,
21 uint32_t);
22
23class 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
39class 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_