summaryrefslogtreecommitdiff
path: root/cpu_ref/rsCpuScriptGroup2.h
blob: 6cb72a65ceb2b57346489484e18aed13b5383e40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef CPU_REF_CPUSCRIPTGROUP2IMPL_H_
#define CPU_REF_CPUSCRIPTGROUP2IMPL_H_

#include <list>

#include "rsd_cpu.h"

using std::list;

namespace android {
namespace renderscript {

class Closure;
class RsdCpuScriptImpl;
class RsdCpuReferenceImpl;
class ScriptGroup2;

struct RsExpandKernelParams;

typedef void (*ExpandFuncTy)(const RsExpandKernelParams*, uint32_t, uint32_t,
                             uint32_t);

class CPUClosure {
 public:
  CPUClosure(const Closure* closure, RsdCpuScriptImpl* si, ExpandFuncTy func,
             const void* usrPtr, const size_t usrSize) :
      mClosure(closure), mSi(si), mFunc(func), mUsrPtr(usrPtr),
      mUsrSize(usrSize) {}

  // It's important to do forwarding here than inheritance for unbound value
  // binding to work.
  const Closure* mClosure;
  RsdCpuScriptImpl* mSi;
  const ExpandFuncTy mFunc;
  const void* mUsrPtr;
  const size_t mUsrSize;
};

class CpuScriptGroup2Impl : public RsdCpuReference::CpuScriptGroup2 {
 public:
  CpuScriptGroup2Impl(RsdCpuReferenceImpl *cpuRefImpl, const ScriptGroupBase* group);
  virtual ~CpuScriptGroup2Impl();

  bool init();
  virtual void execute();

 private:
  void setGlobalsForBatch(const list<CPUClosure*>& batch);
  void runBatch(const list<CPUClosure*>& batch);

  RsdCpuReferenceImpl* mCpuRefImpl;
  const ScriptGroup2* mGroup;

  list<list<CPUClosure*>*> mBatches;
};

}  // namespace renderscript
}  // namespace android

#endif  // CPU_REF_CPUSCRIPTGROUP2IMPL_H_