1 #define LOG_TAG "android.hardware.renderscript@1.0-impl"
2 
3 #include "Context.h"
4 #include "Device.h"
5 
6 namespace android {
7 namespace hardware {
8 namespace renderscript {
9 namespace V1_0 {
10 namespace implementation {
11 
12 
Context(uint32_t sdkVersion,ContextType ct,int32_t flags)13 Context::Context(uint32_t sdkVersion, ContextType ct, int32_t flags) {
14     RsDevice _dev = nullptr;
15     uint32_t _version = 0;
16     uint32_t _sdkVersion = sdkVersion;
17     RsContextType _ct = static_cast<RsContextType>(ct);
18     int32_t _flags = flags;
19     const char* driverName = nullptr;
20 
21 #ifdef OVERRIDE_RS_DRIVER
22 #define XSTR(S) #S
23 #define STR(S) XSTR(S)
24 #define OVERRIDE_RS_DRIVER_STRING STR(OVERRIDE_RS_DRIVER)
25     static std::string driverString(OVERRIDE_RS_DRIVER_STRING);
26     driverName = driverString.c_str();
27 #undef XSTR
28 #undef STR
29 #endif  // OVERRIDE_RS_DRIVER
30     mContext = Device::getHal().ContextCreateVendor(_dev, _version, _sdkVersion,
31                                                     _ct, _flags, driverName);
32 }
33 
34 
35 // Helper functions
36 template<typename ReturnType>
hidl_to_rs(OpaqueHandle src)37 static ReturnType hidl_to_rs(OpaqueHandle src) {
38     return reinterpret_cast<ReturnType>(static_cast<uintptr_t>(src));
39 }
40 
41 template<typename ReturnType, typename SourceType>
hidl_to_rs(SourceType * src)42 static ReturnType hidl_to_rs(SourceType* src) {
43     return reinterpret_cast<ReturnType>(src);
44 }
45 
46 template<typename RsType, typename HidlType, typename Operation>
hidl_to_rs(const hidl_vec<HidlType> & src,Operation operation)47 static std::vector<RsType> hidl_to_rs(const hidl_vec<HidlType>& src, Operation operation) {
48     std::vector<RsType> dst(src.size());
49     std::transform(src.begin(), src.end(), dst.begin(), operation);
50     return dst;
51 }
52 
53 template<typename ReturnType, typename SourceType>
rs_to_hidl(SourceType * src)54 static ReturnType rs_to_hidl(SourceType* src) {
55     return static_cast<ReturnType>(reinterpret_cast<uintptr_t>(src));
56 }
57 
58 template<typename HidlType, typename RsType, typename Operation>
rs_to_hidl(const std::vector<RsType> & src,Operation operation)59 static hidl_vec<HidlType> rs_to_hidl(const std::vector<RsType>& src, Operation operation) {
60     std::vector<HidlType> dst(src.size());
61     std::transform(src.begin(), src.end(), dst.begin(), operation);
62     return dst;
63 }
64 
65 
66 // Methods from ::android::hardware::renderscript::V1_0::IContext follow.
67 
allocationAdapterCreate(Type type,Allocation baseAlloc)68 Return<Allocation> Context::allocationAdapterCreate(Type type, Allocation baseAlloc) {
69     RsType _type = hidl_to_rs<RsType>(type);
70     RsAllocation _baseAlloc = hidl_to_rs<RsAllocation>(baseAlloc);
71     RsAllocation _subAlloc = Device::getHal().AllocationAdapterCreate(mContext, _type, _baseAlloc);
72     return rs_to_hidl<Allocation>(_subAlloc);
73 }
74 
allocationAdapterOffset(Allocation alloc,const hidl_vec<uint32_t> & offsets)75 Return<void> Context::allocationAdapterOffset(Allocation alloc, const hidl_vec<uint32_t>& offsets) {
76     RsAllocation _alloc = hidl_to_rs<RsAllocation>(alloc);
77     const hidl_vec<uint32_t>& _offsets = offsets;
78     Device::getHal().AllocationAdapterOffset(mContext, _alloc, _offsets.data(), _offsets.size() * sizeof(uint32_t));
79     return Void();
80 }
81 
allocationGetType(Allocation allocation)82 Return<Type> Context::allocationGetType(Allocation allocation) {
83     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
84     const void* _type = Device::getHal().AllocationGetType(mContext, _allocation);
85     return rs_to_hidl<Type>(_type);
86 }
87 
allocationCreateTyped(Type type,AllocationMipmapControl amips,int32_t usage,Ptr ptr)88 Return<Allocation> Context::allocationCreateTyped(Type type, AllocationMipmapControl amips, int32_t usage, Ptr ptr) {
89     RsType _type = hidl_to_rs<RsType>(type);
90     RsAllocationMipmapControl _amips = static_cast<RsAllocationMipmapControl>(amips);
91     uint32_t _usage = usage;
92     uintptr_t _ptr = hidl_to_rs<uintptr_t>(ptr);
93     RsAllocation _allocation = Device::getHal().AllocationCreateTyped(mContext, _type, _amips, _usage, _ptr);
94     return rs_to_hidl<Allocation>(_allocation);
95 }
96 
allocationCreateFromBitmap(Type type,AllocationMipmapControl amips,const hidl_vec<uint8_t> & bitmap,int32_t usage)97 Return<Allocation> Context::allocationCreateFromBitmap(Type type, AllocationMipmapControl amips, const hidl_vec<uint8_t>& bitmap, int32_t usage) {
98     RsType _type = hidl_to_rs<RsType>(type);
99     RsAllocationMipmapControl _amips = static_cast<RsAllocationMipmapControl>(amips);
100     const hidl_vec<uint8_t>& _bitmap = bitmap;
101     uint32_t _usage = usage;
102     RsAllocation _allocation = Device::getHal().AllocationCreateFromBitmap(mContext, _type, _amips, _bitmap.data(), _bitmap.size(), _usage);
103     return rs_to_hidl<Allocation>(_allocation);
104 }
105 
allocationCubeCreateFromBitmap(Type type,AllocationMipmapControl amips,const hidl_vec<uint8_t> & bitmap,int32_t usage)106 Return<Allocation> Context::allocationCubeCreateFromBitmap(Type type, AllocationMipmapControl amips, const hidl_vec<uint8_t>& bitmap, int32_t usage) {
107     RsType _type = hidl_to_rs<RsType>(type);
108     RsAllocationMipmapControl _amips = static_cast<RsAllocationMipmapControl>(amips);
109     const hidl_vec<uint8_t>& _bitmap = bitmap;
110     uint32_t _usage = usage;
111     RsAllocation _allocation = Device::getHal().AllocationCubeCreateFromBitmap(mContext, _type, _amips, _bitmap.data(), _bitmap.size(), _usage);
112     return rs_to_hidl<Allocation>(_allocation);
113 }
114 
allocationGetNativeWindow(Allocation allocation)115 Return<NativeWindow> Context::allocationGetNativeWindow(Allocation allocation) {
116     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
117     RsNativeWindow _nativeWindow = Device::getHal().AllocationGetSurface(mContext, _allocation);
118     return rs_to_hidl<NativeWindow>(_nativeWindow);
119 }
120 
allocationSetNativeWindow(Allocation allocation,NativeWindow nativewindow)121 Return<void> Context::allocationSetNativeWindow(Allocation allocation, NativeWindow nativewindow) {
122     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
123     RsNativeWindow _nativewindow = hidl_to_rs<RsNativeWindow>(nativewindow);
124     Device::getHal().AllocationSetSurface(mContext, _allocation, _nativewindow);
125     return Void();
126 }
127 
allocationSetupBufferQueue(Allocation alloc,uint32_t numBuffer)128 Return<void> Context::allocationSetupBufferQueue(Allocation alloc, uint32_t numBuffer) {
129     RsAllocation _alloc = hidl_to_rs<RsAllocation>(alloc);
130     uint32_t _numBuffer = numBuffer;
131     Device::getHal().AllocationSetupBufferQueue(mContext, _alloc, _numBuffer);
132     return Void();
133 }
134 
allocationShareBufferQueue(Allocation baseAlloc,Allocation subAlloc)135 Return<void> Context::allocationShareBufferQueue(Allocation baseAlloc, Allocation subAlloc) {
136     RsAllocation _baseAlloc = hidl_to_rs<RsAllocation>(baseAlloc);
137     RsAllocation _subAlloc = hidl_to_rs<RsAllocation>(subAlloc);
138     Device::getHal().AllocationShareBufferQueue(mContext, _baseAlloc, _subAlloc);
139     return Void();
140 }
141 
allocationCopyToBitmap(Allocation allocation,Ptr data,Size sizeBytes)142 Return<void> Context::allocationCopyToBitmap(Allocation allocation, Ptr data, Size sizeBytes) {
143     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
144     void* _data = hidl_to_rs<void*>(data);
145     size_t _sizeBytes = static_cast<size_t>(sizeBytes);
146     Device::getHal().AllocationCopyToBitmap(mContext, _allocation, _data, _sizeBytes);
147     return Void();
148 }
149 
allocation1DWrite(Allocation allocation,uint32_t offset,uint32_t lod,uint32_t count,const hidl_vec<uint8_t> & data)150 Return<void> Context::allocation1DWrite(Allocation allocation, uint32_t offset, uint32_t lod, uint32_t count, const hidl_vec<uint8_t>& data) {
151     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
152     uint32_t _offset = offset;
153     uint32_t _lod = lod;
154     uint32_t _count = count;
155     const void* _dataPtr = hidl_to_rs<const void*>(data.data());
156     size_t _sizeBytes = data.size();
157     Device::getHal().Allocation1DData(mContext, _allocation, _offset, _lod, _count, _dataPtr, _sizeBytes);
158     return Void();
159 }
160 
allocationElementWrite(Allocation allocation,uint32_t x,uint32_t y,uint32_t z,uint32_t lod,const hidl_vec<uint8_t> & data,Size compIdx)161 Return<void> Context::allocationElementWrite(Allocation allocation, uint32_t x, uint32_t y, uint32_t z, uint32_t lod, const hidl_vec<uint8_t>& data, Size compIdx) {
162     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
163     uint32_t _x = x;
164     uint32_t _y = y;
165     uint32_t _z = z;
166     uint32_t _lod = lod;
167     const void* _dataPtr = hidl_to_rs<const void*>(data.data());
168     size_t _sizeBytes = data.size();
169     size_t _compIdx = static_cast<size_t>(compIdx);
170     Device::getHal().AllocationElementData(mContext, _allocation, _x, _y, _z, _lod, _dataPtr, _sizeBytes, _compIdx);
171     return Void();
172 }
173 
allocation2DWrite(Allocation allocation,uint32_t xoff,uint32_t yoff,uint32_t lod,AllocationCubemapFace face,uint32_t w,uint32_t h,const hidl_vec<uint8_t> & data,Size stride)174 Return<void> Context::allocation2DWrite(Allocation allocation, uint32_t xoff, uint32_t yoff, uint32_t lod, AllocationCubemapFace face, uint32_t w, uint32_t h, const hidl_vec<uint8_t>& data, Size stride) {
175     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
176     uint32_t _xoff = xoff;
177     uint32_t _yoff = yoff;
178     uint32_t _lod = lod;
179     RsAllocationCubemapFace _face = static_cast<RsAllocationCubemapFace>(face);
180     uint32_t _w = w;
181     uint32_t _h = h;
182     const void* _dataPtr = hidl_to_rs<const void*>(data.data());
183     size_t _sizeBytes = data.size();
184     size_t _stride = static_cast<size_t>(stride);
185     Device::getHal().Allocation2DData(mContext, _allocation, _xoff, _yoff, _lod, _face, _w, _h, _dataPtr, _sizeBytes, _stride);
186     return Void();
187 }
188 
allocation3DWrite(Allocation allocation,uint32_t xoff,uint32_t yoff,uint32_t zoff,uint32_t lod,uint32_t w,uint32_t h,uint32_t d,const hidl_vec<uint8_t> & data,Size stride)189 Return<void> Context::allocation3DWrite(Allocation allocation, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, uint32_t w, uint32_t h, uint32_t d, const hidl_vec<uint8_t>& data, Size stride) {
190     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
191     uint32_t _xoff = xoff;
192     uint32_t _yoff = yoff;
193     uint32_t _zoff = zoff;
194     uint32_t _lod = lod;
195     uint32_t _w = w;
196     uint32_t _h = h;
197     uint32_t _d = d;
198     const void* _dataPtr = hidl_to_rs<const void*>(data.data());
199     size_t _sizeBytes = data.size();
200     size_t _stride = static_cast<size_t>(stride);
201     Device::getHal().Allocation3DData(mContext, _allocation, _xoff, _yoff, _zoff, _lod, _w, _h, _d, _dataPtr, _sizeBytes, _stride);
202     return Void();
203 }
204 
allocationGenerateMipmaps(Allocation allocation)205 Return<void> Context::allocationGenerateMipmaps(Allocation allocation) {
206     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
207     Device::getHal().AllocationGenerateMipmaps(mContext, _allocation);
208     return Void();
209 }
210 
allocationRead(Allocation allocation,Ptr data,Size sizeBytes)211 Return<void> Context::allocationRead(Allocation allocation, Ptr data, Size sizeBytes) {
212     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
213     void* _data = hidl_to_rs<void*>(data);
214     size_t _sizeBytes = static_cast<size_t>(sizeBytes);
215     Device::getHal().AllocationRead(mContext, _allocation, _data, _sizeBytes);
216     return Void();
217 }
218 
allocation1DRead(Allocation allocation,uint32_t xoff,uint32_t lod,uint32_t count,Ptr data,Size sizeBytes)219 Return<void> Context::allocation1DRead(Allocation allocation, uint32_t xoff, uint32_t lod, uint32_t count, Ptr data, Size sizeBytes) {
220     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
221     uint32_t _xoff = xoff;
222     uint32_t _lod = lod;
223     uint32_t _count = count;
224     void* _data = hidl_to_rs<void*>(data);
225     size_t _sizeBytes = static_cast<size_t>(sizeBytes);
226     Device::getHal().Allocation1DRead(mContext, _allocation, _xoff, _lod, _count, _data, _sizeBytes);
227     return Void();
228 }
229 
allocationElementRead(Allocation allocation,uint32_t x,uint32_t y,uint32_t z,uint32_t lod,Ptr data,Size sizeBytes,Size compIdx)230 Return<void> Context::allocationElementRead(Allocation allocation, uint32_t x, uint32_t y, uint32_t z, uint32_t lod, Ptr data, Size sizeBytes, Size compIdx) {
231     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
232     uint32_t _x = x;
233     uint32_t _y = y;
234     uint32_t _z = z;
235     uint32_t _lod = lod;
236     void* _data = hidl_to_rs<void*>(data);
237     size_t _sizeBytes = static_cast<size_t>(sizeBytes);
238     size_t _compIdx = static_cast<size_t>(compIdx);
239     Device::getHal().AllocationElementRead(mContext, _allocation, _x, _y, _z, _lod, _data, _sizeBytes, _compIdx);
240     return Void();
241 }
242 
allocation2DRead(Allocation allocation,uint32_t xoff,uint32_t yoff,uint32_t lod,AllocationCubemapFace face,uint32_t w,uint32_t h,Ptr data,Size sizeBytes,Size stride)243 Return<void> Context::allocation2DRead(Allocation allocation, uint32_t xoff, uint32_t yoff, uint32_t lod, AllocationCubemapFace face, uint32_t w, uint32_t h, Ptr data, Size sizeBytes, Size stride) {
244     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
245     uint32_t _xoff = xoff;
246     uint32_t _yoff = yoff;
247     uint32_t _lod = lod;
248     RsAllocationCubemapFace _face = static_cast<RsAllocationCubemapFace>(face);
249     uint32_t _w = w;
250     uint32_t _h = h;
251     void* _data = hidl_to_rs<void*>(data);
252     size_t _sizeBytes = static_cast<size_t>(sizeBytes);
253     size_t _stride = static_cast<size_t>(stride);
254     Device::getHal().Allocation2DRead(mContext, _allocation, _xoff, _yoff, _lod, _face, _w, _h, _data, _sizeBytes, _stride);
255     return Void();
256 }
257 
allocation3DRead(Allocation allocation,uint32_t xoff,uint32_t yoff,uint32_t zoff,uint32_t lod,uint32_t w,uint32_t h,uint32_t d,Ptr data,Size sizeBytes,Size stride)258 Return<void> Context::allocation3DRead(Allocation allocation, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, uint32_t w, uint32_t h, uint32_t d, Ptr data, Size sizeBytes, Size stride) {
259     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
260     uint32_t _xoff = xoff;
261     uint32_t _yoff = yoff;
262     uint32_t _zoff = zoff;
263     uint32_t _lod = lod;
264     uint32_t _w = w;
265     uint32_t _h = h;
266     uint32_t _d = d;
267     void* _dataPtr = hidl_to_rs<void*>(data);
268     size_t _sizeBytes = static_cast<size_t>(sizeBytes);
269     size_t _stride = static_cast<size_t>(stride);
270     Device::getHal().Allocation3DRead(mContext, _allocation, _xoff, _yoff, _zoff, _lod, _w, _h, _d, _dataPtr, _sizeBytes, _stride);
271     return Void();
272 }
273 
allocationSyncAll(Allocation allocation,AllocationUsageType usageType)274 Return<void> Context::allocationSyncAll(Allocation allocation, AllocationUsageType usageType) {
275     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
276     RsAllocationUsageType _usageType = static_cast<RsAllocationUsageType>(usageType);
277     Device::getHal().AllocationSyncAll(mContext, _allocation, _usageType);
278     return Void();
279 }
280 
allocationResize1D(Allocation allocation,uint32_t dimX)281 Return<void> Context::allocationResize1D(Allocation allocation, uint32_t dimX) {
282     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
283     uint32_t _dimX = dimX;
284     Device::getHal().AllocationResize1D(mContext, _allocation, _dimX);
285     return Void();
286 }
287 
allocationCopy2DRange(Allocation dstAlloc,uint32_t dstXoff,uint32_t dstYoff,uint32_t dstMip,AllocationCubemapFace dstFace,uint32_t width,uint32_t height,Allocation srcAlloc,uint32_t srcXoff,uint32_t srcYoff,uint32_t srcMip,AllocationCubemapFace srcFace)288 Return<void> Context::allocationCopy2DRange(Allocation dstAlloc, uint32_t dstXoff, uint32_t dstYoff, uint32_t dstMip, AllocationCubemapFace dstFace, uint32_t width, uint32_t height, Allocation srcAlloc, uint32_t srcXoff, uint32_t srcYoff, uint32_t srcMip, AllocationCubemapFace srcFace) {
289     RsAllocation _dstAlloc = hidl_to_rs<RsAllocation>(dstAlloc);
290     uint32_t _dstXoff = dstXoff;
291     uint32_t _dstYoff = dstYoff;
292     uint32_t _dstMip = dstMip;
293     RsAllocationCubemapFace _dstFace = static_cast<RsAllocationCubemapFace>(dstFace);
294     uint32_t _width = width;
295     uint32_t _height = height;
296     RsAllocation _srcAlloc = hidl_to_rs<RsAllocation>(srcAlloc);
297     uint32_t _srcXoff = srcXoff;
298     uint32_t _srcYoff = srcYoff;
299     uint32_t _srcMip = srcMip;
300     RsAllocationCubemapFace _srcFace = static_cast<RsAllocationCubemapFace>(srcFace);
301     Device::getHal().AllocationCopy2DRange(mContext, _dstAlloc, _dstXoff, _dstYoff, _dstMip, _dstFace, _width, _height, _srcAlloc, _srcXoff, _srcYoff, _srcMip, _srcFace);
302     return Void();
303 }
304 
allocationCopy3DRange(Allocation dstAlloc,uint32_t dstXoff,uint32_t dstYoff,uint32_t dstZoff,uint32_t dstMip,uint32_t width,uint32_t height,uint32_t depth,Allocation srcAlloc,uint32_t srcXoff,uint32_t srcYoff,uint32_t srcZoff,uint32_t srcMip)305 Return<void> Context::allocationCopy3DRange(Allocation dstAlloc, uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff, uint32_t dstMip, uint32_t width, uint32_t height, uint32_t depth, Allocation srcAlloc, uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, uint32_t srcMip) {
306     RsAllocation _dstAlloc = hidl_to_rs<RsAllocation>(dstAlloc);
307     uint32_t _dstXoff = dstXoff;
308     uint32_t _dstYoff = dstYoff;
309     uint32_t _dstZoff = dstZoff;
310     uint32_t _dstMip = dstMip;
311     uint32_t _width = width;
312     uint32_t _height = height;
313     uint32_t _depth = depth;
314     RsAllocation _srcAlloc = hidl_to_rs<RsAllocation>(srcAlloc);
315     uint32_t _srcXoff = srcXoff;
316     uint32_t _srcYoff = srcYoff;
317     uint32_t _srcZoff = srcZoff;
318     uint32_t _srcMip = srcMip;
319     Device::getHal().AllocationCopy3DRange(mContext, _dstAlloc, _dstXoff, _dstYoff, _dstZoff, _dstMip, _width, _height, _depth, _srcAlloc, _srcXoff, _srcYoff, _srcZoff, _srcMip);
320     return Void();
321 }
322 
allocationIoSend(Allocation allocation)323 Return<void> Context::allocationIoSend(Allocation allocation) {
324     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
325     Device::getHal().AllocationIoSend(mContext, _allocation);
326     return Void();
327 }
328 
allocationIoReceive(Allocation allocation)329 Return<void> Context::allocationIoReceive(Allocation allocation) {
330     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
331     Device::getHal().AllocationIoReceive(mContext, _allocation);
332     return Void();
333 }
334 
allocationGetPointer(Allocation allocation,uint32_t lod,AllocationCubemapFace face,uint32_t z,allocationGetPointer_cb _hidl_cb)335 Return<void> Context::allocationGetPointer(Allocation allocation, uint32_t lod, AllocationCubemapFace face, uint32_t z, allocationGetPointer_cb _hidl_cb) {
336     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
337     uint32_t _lod = lod;
338     RsAllocationCubemapFace _face = static_cast<RsAllocationCubemapFace>(face);
339     uint32_t _z = z;
340     uint32_t _array = 0;
341     size_t _stride = 0;
342     void* _dataPtr = Device::getHal().AllocationGetPointer(mContext, _allocation, _lod, _face, _z, _array, &_stride, sizeof(size_t));
343     Ptr dataPtr = reinterpret_cast<Ptr>(_dataPtr);
344     Size stride = static_cast<Size>(_stride);
345     _hidl_cb(dataPtr, stride);
346     return Void();
347 }
348 
elementGetNativeMetadata(Element element,elementGetNativeMetadata_cb _hidl_cb)349 Return<void> Context::elementGetNativeMetadata(Element element, elementGetNativeMetadata_cb _hidl_cb) {
350     RsElement _element = hidl_to_rs<RsElement>(element);
351     std::vector<uint32_t> _elemData(5);
352     Device::getHal().ElementGetNativeData(mContext, _element, _elemData.data(), _elemData.size());
353     hidl_vec<uint32_t> elemData = _elemData;
354     _hidl_cb(elemData);
355     return Void();
356 }
357 
elementGetSubElements(Element element,Size numSubElem,elementGetSubElements_cb _hidl_cb)358 Return<void> Context::elementGetSubElements(Element element, Size numSubElem, elementGetSubElements_cb _hidl_cb) {
359     RsElement _element = hidl_to_rs<RsElement>(element);
360     uint32_t _numSubElem = static_cast<uint32_t>(numSubElem);
361     std::vector<uintptr_t> _ids(_numSubElem);
362     std::vector<const char*> _names(_numSubElem);
363     std::vector<size_t> _arraySizes(_numSubElem);
364     Device::getHal().ElementGetSubElements(mContext, _element, _ids.data(), _names.data(), _arraySizes.data(), _numSubElem);
365     hidl_vec<Element>     ids        = rs_to_hidl<Element>(_ids,       [](uintptr_t val) { return static_cast<Element>(val); });
366     hidl_vec<hidl_string> names      = rs_to_hidl<hidl_string>(_names, [](const char* val) { return val; });
367     hidl_vec<Size>        arraySizes = rs_to_hidl<Size>(_arraySizes,   [](size_t val) { return static_cast<Size>(val); });
368     _hidl_cb(ids, names, arraySizes);
369     return Void();
370 }
371 
elementCreate(DataType dt,DataKind dk,bool norm,uint32_t size)372 Return<Element> Context::elementCreate(DataType dt, DataKind dk, bool norm, uint32_t size) {
373     RsDataType _dt = static_cast<RsDataType>(dt);
374     RsDataKind _dk = static_cast<RsDataKind>(dk);
375     bool _norm = norm;
376     uint32_t _size = size;
377     RsElement _element = Device::getHal().ElementCreate(mContext, _dt, _dk, _norm, _size);
378     return rs_to_hidl<Element>(_element);
379 }
380 
elementComplexCreate(const hidl_vec<Element> & eins,const hidl_vec<hidl_string> & names,const hidl_vec<Size> & arraySizes)381 Return<Element> Context::elementComplexCreate(const hidl_vec<Element>& eins, const hidl_vec<hidl_string>& names, const hidl_vec<Size>& arraySizes) {
382     std::vector<RsElement>   _eins           = hidl_to_rs<RsElement>(eins,      [](Element val) { return hidl_to_rs<RsElement>(val); });
383     std::vector<const char*> _namesPtr       = hidl_to_rs<const char*>(names,   [](const hidl_string& val) { return val.c_str(); });
384     std::vector<size_t>      _nameLengthsPtr = hidl_to_rs<size_t>(names,        [](const hidl_string& val) { return val.size(); });
385     std::vector<uint32_t>    _arraySizes     = hidl_to_rs<uint32_t>(arraySizes, [](Size val) { return static_cast<uint32_t>(val); });
386     RsElement _element = Device::getHal().ElementCreate2(mContext, _eins.data(), _eins.size(), _namesPtr.data(), _namesPtr.size(), _nameLengthsPtr.data(), _arraySizes.data(), _arraySizes.size());
387     return rs_to_hidl<Element>(_element);
388 }
389 
typeGetNativeMetadata(Type type,typeGetNativeMetadata_cb _hidl_cb)390 Return<void> Context::typeGetNativeMetadata(Type type, typeGetNativeMetadata_cb _hidl_cb) {
391     RsType _type = hidl_to_rs<RsType>(type);
392     std::vector<uintptr_t> _metadata(6);
393     Device::getHal().TypeGetNativeData(mContext, _type, _metadata.data(), _metadata.size());
394     hidl_vec<OpaqueHandle> metadata = rs_to_hidl<OpaqueHandle>(_metadata, [](uintptr_t val) { return static_cast<OpaqueHandle>(val); });
395     _hidl_cb(metadata);
396     return Void();
397 }
398 
typeCreate(Element element,uint32_t dimX,uint32_t dimY,uint32_t dimZ,bool mipmaps,bool faces,YuvFormat yuv)399 Return<Type> Context::typeCreate(Element element, uint32_t dimX, uint32_t dimY, uint32_t dimZ, bool mipmaps, bool faces, YuvFormat yuv) {
400     RsElement _element = hidl_to_rs<RsElement>(element);
401     uint32_t _dimX = dimX;
402     uint32_t _dimY = dimY;
403     uint32_t _dimZ = dimZ;
404     bool _mipmaps = mipmaps;
405     bool _faces = faces;
406     RsYuvFormat _yuv = static_cast<RsYuvFormat>(yuv);
407     RsType _type = Device::getHal().TypeCreate(mContext, _element, _dimX, _dimY, _dimZ, _mipmaps, _faces, _yuv);
408     return rs_to_hidl<Type>(_type);
409 }
410 
contextDestroy()411 Return<void> Context::contextDestroy() {
412     Device::getHal().ContextDestroy(mContext);
413     mContext = nullptr;
414     return Void();
415 }
416 
contextGetMessage(Ptr data,Size size,contextGetMessage_cb _hidl_cb)417 Return<void> Context::contextGetMessage(Ptr data, Size size, contextGetMessage_cb _hidl_cb) {
418     void* _data = hidl_to_rs<void*>(data);
419     size_t _size = static_cast<size_t>(size);
420     size_t _receiveLen = 0;
421     uint32_t _subID = 0;
422     RsMessageToClientType _messageType = Device::getHal().ContextGetMessage(mContext, _data, _size, &_receiveLen, sizeof(size_t), &_subID, sizeof(uint32_t));
423     MessageToClientType messageType = static_cast<MessageToClientType>(_messageType);
424     Size receiveLen = static_cast<Size>(_receiveLen);
425     _hidl_cb(messageType, receiveLen);
426     return Void();
427 }
428 
contextPeekMessage(contextPeekMessage_cb _hidl_cb)429 Return<void> Context::contextPeekMessage(contextPeekMessage_cb _hidl_cb) {
430     size_t _receiveLen = 0;
431     uint32_t _subID = 0;
432     RsMessageToClientType _messageType = Device::getHal().ContextPeekMessage(mContext, &_receiveLen, sizeof(size_t), &_subID, sizeof(uint32_t));
433     MessageToClientType messageType = static_cast<MessageToClientType>(_messageType);
434     Size receiveLen = static_cast<Size>(_receiveLen);
435     uint32_t subID = _subID;
436     _hidl_cb(messageType, receiveLen, subID);
437     return Void();
438 }
439 
contextSendMessage(uint32_t id,const hidl_vec<uint8_t> & data)440 Return<void> Context::contextSendMessage(uint32_t id, const hidl_vec<uint8_t>& data) {
441     uint32_t _id = id;
442     const uint8_t* _dataPtr = data.data();
443     size_t _dataSize = data.size();
444     Device::getHal().ContextSendMessage(mContext, _id, _dataPtr, _dataSize);
445     return Void();
446 }
447 
contextInitToClient()448 Return<void> Context::contextInitToClient() {
449     Device::getHal().ContextInitToClient(mContext);
450     return Void();
451 }
452 
contextDeinitToClient()453 Return<void> Context::contextDeinitToClient() {
454     Device::getHal().ContextDeinitToClient(mContext);
455     return Void();
456 }
457 
contextFinish()458 Return<void> Context::contextFinish() {
459     Device::getHal().ContextFinish(mContext);
460     return Void();
461 }
462 
contextLog()463 Return<void> Context::contextLog() {
464     uint32_t _bits = 0;
465     Device::getHal().ContextDump(mContext, _bits);
466     return Void();
467 }
468 
contextSetPriority(ThreadPriorities priority)469 Return<void> Context::contextSetPriority(ThreadPriorities priority) {
470     RsThreadPriorities _priority = static_cast<RsThreadPriorities>(priority);
471     Device::getHal().ContextSetPriority(mContext, _priority);
472     return Void();
473 }
474 
contextSetCacheDir(const hidl_string & cacheDir)475 Return<void> Context::contextSetCacheDir(const hidl_string& cacheDir) {
476     Device::getHal().ContextSetCacheDir(mContext, cacheDir.c_str(), cacheDir.size());
477     return Void();
478 }
479 
assignName(ObjectBase obj,const hidl_string & name)480 Return<void> Context::assignName(ObjectBase obj, const hidl_string& name) {
481     RsObjectBase _obj = hidl_to_rs<RsObjectBase>(obj);
482     const hidl_string& _name = name;
483     Device::getHal().AssignName(mContext, _obj, _name.c_str(), _name.size());
484     return Void();
485 }
486 
getName(ObjectBase obj,getName_cb _hidl_cb)487 Return<void> Context::getName(ObjectBase obj, getName_cb _hidl_cb) {
488     void* _obj = hidl_to_rs<void*>(obj);
489     const char* _name = nullptr;
490     Device::getHal().GetName(mContext, _obj, &_name);
491     hidl_string name = _name;
492     _hidl_cb(name);
493     return Void();
494 }
495 
closureCreate(ScriptKernelID kernelID,Allocation returnValue,const hidl_vec<ScriptFieldID> & fieldIDS,const hidl_vec<int64_t> & values,const hidl_vec<int32_t> & sizes,const hidl_vec<Closure> & depClosures,const hidl_vec<ScriptFieldID> & depFieldIDS)496 Return<Closure> Context::closureCreate(ScriptKernelID kernelID, Allocation returnValue, const hidl_vec<ScriptFieldID>& fieldIDS, const hidl_vec<int64_t>& values, const hidl_vec<int32_t>& sizes, const hidl_vec<Closure>& depClosures, const hidl_vec<ScriptFieldID>& depFieldIDS) {
497     RsScriptKernelID _kernelID = hidl_to_rs<RsScriptKernelID>(kernelID);
498     RsAllocation _returnValue = hidl_to_rs<RsAllocation>(returnValue);
499     std::vector<RsScriptFieldID> _fieldIDS = hidl_to_rs<RsScriptFieldID>(fieldIDS, [](ScriptFieldID val) { return hidl_to_rs<RsScriptFieldID>(val); });
500     int64_t* _valuesPtr = const_cast<int64_t*>(values.data());
501     size_t _valuesLength = values.size();
502     std::vector<int>             _sizes       = hidl_to_rs<int>(sizes,                   [](int32_t val) { return static_cast<int>(val); });
503     std::vector<RsClosure>       _depClosures = hidl_to_rs<RsClosure>(depClosures,       [](Closure val) { return hidl_to_rs<RsClosure>(val); });
504     std::vector<RsScriptFieldID> _depFieldIDS = hidl_to_rs<RsScriptFieldID>(depFieldIDS, [](ScriptFieldID val) { return hidl_to_rs<RsScriptFieldID>(val); });
505     RsClosure _closure = Device::getHal().ClosureCreate(mContext, _kernelID, _returnValue, _fieldIDS.data(), _fieldIDS.size(), _valuesPtr, _valuesLength, _sizes.data(), _sizes.size(), _depClosures.data(), _depClosures.size(), _depFieldIDS.data(), _depFieldIDS.size());
506     return rs_to_hidl<Closure>(_closure);
507 }
508 
invokeClosureCreate(ScriptInvokeID invokeID,const hidl_vec<uint8_t> & params,const hidl_vec<ScriptFieldID> & fieldIDS,const hidl_vec<int64_t> & values,const hidl_vec<int32_t> & sizes)509 Return<Closure> Context::invokeClosureCreate(ScriptInvokeID invokeID, const hidl_vec<uint8_t>& params, const hidl_vec<ScriptFieldID>& fieldIDS, const hidl_vec<int64_t>& values, const hidl_vec<int32_t>& sizes) {
510     RsScriptInvokeID _invokeID = hidl_to_rs<RsScriptInvokeID>(invokeID);
511     const void* _paramsPtr = params.data();
512     size_t _paramsSize = params.size();
513     std::vector<RsScriptFieldID> _fieldIDS = hidl_to_rs<RsScriptFieldID>(fieldIDS, [](ScriptFieldID val) { return hidl_to_rs<RsScriptFieldID>(val); });
514     const int64_t* _valuesPtr = values.data();
515     size_t _valuesLength = values.size();
516     std::vector<int> _sizes = hidl_to_rs<int>(sizes, [](int32_t val) { return static_cast<int>(val); });
517     RsClosure _closure = Device::getHal().InvokeClosureCreate(mContext, _invokeID, _paramsPtr, _paramsSize, _fieldIDS.data(), _fieldIDS.size(), _valuesPtr, _valuesLength, _sizes.data(), _sizes.size());
518     return rs_to_hidl<Closure>(_closure);
519 }
520 
closureSetArg(Closure closure,uint32_t index,Ptr value,int32_t size)521 Return<void> Context::closureSetArg(Closure closure, uint32_t index, Ptr value, int32_t size) {
522     RsClosure _closure = hidl_to_rs<RsClosure>(closure);
523     uint32_t _index = index;
524     uintptr_t _value = hidl_to_rs<uintptr_t>(value);
525     int _size = static_cast<int>(size);
526     Device::getHal().ClosureSetArg(mContext, _closure, _index, _value, _size);
527     return Void();
528 }
529 
closureSetGlobal(Closure closure,ScriptFieldID fieldID,int64_t value,int32_t size)530 Return<void> Context::closureSetGlobal(Closure closure, ScriptFieldID fieldID, int64_t value, int32_t size) {
531     RsClosure _closure = hidl_to_rs<RsClosure>(closure);
532     RsScriptFieldID _fieldID = hidl_to_rs<RsScriptFieldID>(fieldID);
533     int64_t _value = value;
534     int _size = static_cast<int>(size);
535     Device::getHal().ClosureSetGlobal(mContext, _closure, _fieldID, _value, _size);
536     return Void();
537 }
538 
scriptKernelIDCreate(Script script,int32_t slot,int32_t sig)539 Return<ScriptKernelID> Context::scriptKernelIDCreate(Script script, int32_t slot, int32_t sig) {
540     RsScript _script = hidl_to_rs<RsScript>(script);
541     int _slot = static_cast<int>(slot);
542     int _sig = static_cast<int>(sig);
543     RsScriptKernelID _scriptKernelID = Device::getHal().ScriptKernelIDCreate(mContext, _script, _slot, _sig);
544     return rs_to_hidl<ScriptKernelID>(_scriptKernelID);
545 }
546 
scriptInvokeIDCreate(Script script,int32_t slot)547 Return<ScriptInvokeID> Context::scriptInvokeIDCreate(Script script, int32_t slot) {
548     RsScript _script = hidl_to_rs<RsScript>(script);
549     int _slot = static_cast<int>(slot);
550     RsScriptInvokeID _scriptInvokeID = Device::getHal().ScriptInvokeIDCreate(mContext, _script, _slot);
551     return rs_to_hidl<ScriptInvokeID>(_scriptInvokeID);
552 }
553 
scriptFieldIDCreate(Script script,int32_t slot)554 Return<ScriptFieldID> Context::scriptFieldIDCreate(Script script, int32_t slot) {
555     RsScript _script = hidl_to_rs<RsScript>(script);
556     int _slot = static_cast<int>(slot);
557     RsScriptFieldID _scriptFieldID = Device::getHal().ScriptFieldIDCreate(mContext, _script, _slot);
558     return rs_to_hidl<ScriptFieldID>(_scriptFieldID);
559 }
560 
scriptGroupCreate(const hidl_vec<ScriptKernelID> & kernels,const hidl_vec<ScriptKernelID> & srcK,const hidl_vec<ScriptKernelID> & dstK,const hidl_vec<ScriptFieldID> & dstF,const hidl_vec<Type> & types)561 Return<ScriptGroup> Context::scriptGroupCreate(const hidl_vec<ScriptKernelID>& kernels, const hidl_vec<ScriptKernelID>& srcK, const hidl_vec<ScriptKernelID>& dstK, const hidl_vec<ScriptFieldID>& dstF, const hidl_vec<Type>& types) {
562     std::vector<RsScriptKernelID> _kernels = hidl_to_rs<RsScriptKernelID>(kernels, [](ScriptFieldID val) { return hidl_to_rs<RsScriptKernelID>(val); });
563     std::vector<RsScriptKernelID> _srcK    = hidl_to_rs<RsScriptKernelID>(srcK,    [](ScriptFieldID val) { return hidl_to_rs<RsScriptKernelID>(val); });
564     std::vector<RsScriptKernelID> _dstK    = hidl_to_rs<RsScriptKernelID>(dstK,    [](ScriptFieldID val) { return hidl_to_rs<RsScriptKernelID>(val); });
565     std::vector<RsScriptFieldID>  _dstF    = hidl_to_rs<RsScriptFieldID>(dstF,     [](ScriptFieldID val) { return hidl_to_rs<RsScriptFieldID>(val); });
566     std::vector<RsType>           _types   = hidl_to_rs<RsType>(types,             [](Type val) { return hidl_to_rs<RsType>(val); });
567     RsScriptGroup _scriptGroup = Device::getHal().ScriptGroupCreate(mContext, _kernels.data(), _kernels.size() * sizeof(RsScriptKernelID), _srcK.data(), _srcK.size() * sizeof(RsScriptKernelID), _dstK.data(), _dstK.size() * sizeof(RsScriptKernelID), _dstF.data(), _dstF.size() * sizeof(RsScriptFieldID), _types.data(), _types.size() * sizeof(RsType));
568     return rs_to_hidl<ScriptGroup>(_scriptGroup);
569 }
570 
scriptGroup2Create(const hidl_string & name,const hidl_string & cacheDir,const hidl_vec<Closure> & closures)571 Return<ScriptGroup2> Context::scriptGroup2Create(const hidl_string& name, const hidl_string& cacheDir, const hidl_vec<Closure>& closures) {
572     const hidl_string& _name = name;
573     const hidl_string& _cacheDir = cacheDir;
574     std::vector<RsClosure> _closures = hidl_to_rs<RsClosure>(closures, [](Closure val) { return hidl_to_rs<RsClosure>(val); });
575     RsScriptGroup2 _scriptGroup2 = Device::getHal().ScriptGroup2Create(mContext, _name.c_str(), _name.size(), _cacheDir.c_str(), _cacheDir.size(), _closures.data(), _closures.size());
576     return rs_to_hidl<ScriptGroup2>(_scriptGroup2);
577 }
578 
scriptGroupSetOutput(ScriptGroup sg,ScriptKernelID kid,Allocation alloc)579 Return<void> Context::scriptGroupSetOutput(ScriptGroup sg, ScriptKernelID kid, Allocation alloc) {
580     RsScriptGroup _sg = hidl_to_rs<RsScriptGroup>(sg);
581     RsScriptKernelID _kid = hidl_to_rs<RsScriptKernelID>(kid);
582     RsAllocation _alloc = hidl_to_rs<RsAllocation>(alloc);
583     Device::getHal().ScriptGroupSetOutput(mContext, _sg, _kid, _alloc);
584     return Void();
585 }
586 
scriptGroupSetInput(ScriptGroup sg,ScriptKernelID kid,Allocation alloc)587 Return<void> Context::scriptGroupSetInput(ScriptGroup sg, ScriptKernelID kid, Allocation alloc) {
588     RsScriptGroup _sg = hidl_to_rs<RsScriptGroup>(sg);
589     RsScriptKernelID _kid = hidl_to_rs<RsScriptKernelID>(kid);
590     RsAllocation _alloc = hidl_to_rs<RsAllocation>(alloc);
591     Device::getHal().ScriptGroupSetInput(mContext, _sg, _kid, _alloc);
592     return Void();
593 }
594 
scriptGroupExecute(ScriptGroup sg)595 Return<void> Context::scriptGroupExecute(ScriptGroup sg) {
596     RsScriptGroup _sg = hidl_to_rs<RsScriptGroup>(sg);
597     Device::getHal().ScriptGroupExecute(mContext, _sg);
598     return Void();
599 }
600 
objDestroy(ObjectBase obj)601 Return<void> Context::objDestroy(ObjectBase obj) {
602     RsAsyncVoidPtr _obj = hidl_to_rs<RsAsyncVoidPtr>(obj);
603     Device::getHal().ObjDestroy(mContext, _obj);
604     return Void();
605 }
606 
samplerCreate(SamplerValue magFilter,SamplerValue minFilter,SamplerValue wrapS,SamplerValue wrapT,SamplerValue wrapR,float aniso)607 Return<Sampler> Context::samplerCreate(SamplerValue magFilter, SamplerValue minFilter, SamplerValue wrapS, SamplerValue wrapT, SamplerValue wrapR, float aniso) {
608     RsSamplerValue _magFilter = static_cast<RsSamplerValue>(magFilter);
609     RsSamplerValue _minFilter = static_cast<RsSamplerValue>(minFilter);
610     RsSamplerValue _wrapS = static_cast<RsSamplerValue>(wrapS);
611     RsSamplerValue _wrapT = static_cast<RsSamplerValue>(wrapT);
612     RsSamplerValue _wrapR = static_cast<RsSamplerValue>(wrapR);
613     float _aniso = static_cast<float>(aniso);
614     RsSampler _sampler = Device::getHal().SamplerCreate(mContext, _magFilter, _minFilter, _wrapS, _wrapT, _wrapR, _aniso);
615     return rs_to_hidl<Sampler>(_sampler);
616 }
617 
scriptBindAllocation(Script script,Allocation allocation,uint32_t slot)618 Return<void> Context::scriptBindAllocation(Script script, Allocation allocation, uint32_t slot) {
619     RsScript _script = hidl_to_rs<RsScript>(script);
620     RsAllocation _allocation = hidl_to_rs<RsAllocation>(allocation);
621     uint32_t _slot = slot;
622     Device::getHal().ScriptBindAllocation(mContext, _script, _allocation, _slot);
623     return Void();
624 }
625 
scriptSetTimeZone(Script script,const hidl_string & timeZone)626 Return<void> Context::scriptSetTimeZone(Script script, const hidl_string& timeZone) {
627     RsScript _script = hidl_to_rs<RsScript>(script);
628     const hidl_string& _timeZone = timeZone;
629     Device::getHal().ScriptSetTimeZone(mContext, _script, _timeZone.c_str(), _timeZone.size());
630     return Void();
631 }
632 
scriptInvoke(Script vs,uint32_t slot)633 Return<void> Context::scriptInvoke(Script vs, uint32_t slot) {
634     RsScript _vs = hidl_to_rs<RsScript>(vs);
635     uint32_t _slot = slot;
636     Device::getHal().ScriptInvoke(mContext, _vs, _slot);
637     return Void();
638 }
639 
scriptInvokeV(Script vs,uint32_t slot,const hidl_vec<uint8_t> & data)640 Return<void> Context::scriptInvokeV(Script vs, uint32_t slot, const hidl_vec<uint8_t>& data) {
641     RsScript _vs = hidl_to_rs<RsScript>(vs);
642     uint32_t _slot = slot;
643     const void* _dataPtr = hidl_to_rs<const void*>(data.data());
644     size_t _len = data.size();
645     Device::getHal().ScriptInvokeV(mContext, _vs, _slot, _dataPtr, _len);
646     return Void();
647 }
648 
scriptForEach(Script vs,uint32_t slot,const hidl_vec<Allocation> & vains,Allocation vaout,const hidl_vec<uint8_t> & params,Ptr sc)649 Return<void> Context::scriptForEach(Script vs, uint32_t slot, const hidl_vec<Allocation>& vains, Allocation vaout, const hidl_vec<uint8_t>& params, Ptr sc) {
650     RsScript _vs = hidl_to_rs<RsScript>(vs);
651     uint32_t _slot = slot;
652     std::vector<RsAllocation> _vains = hidl_to_rs<RsAllocation>(vains, [](Allocation val) { return hidl_to_rs<RsAllocation>(val); });
653     RsAllocation _vaout = hidl_to_rs<RsAllocation>(vaout);
654     const void* _paramsPtr = hidl_to_rs<const void*>(params.data());
655     size_t _paramLen = params.size();
656     const RsScriptCall* _sc = hidl_to_rs<const RsScriptCall*>(sc);
657     size_t _scLen = _sc != nullptr ? sizeof(ScriptCall) : 0;
658     Device::getHal().ScriptForEachMulti(mContext, _vs, _slot, _vains.data(), _vains.size(), _vaout, _paramsPtr, _paramLen, _sc, _scLen);
659     return Void();
660 }
661 
scriptReduce(Script vs,uint32_t slot,const hidl_vec<Allocation> & vains,Allocation vaout,Ptr sc)662 Return<void> Context::scriptReduce(Script vs, uint32_t slot, const hidl_vec<Allocation>& vains, Allocation vaout, Ptr sc) {
663     RsScript _vs = hidl_to_rs<RsScript>(vs);
664     uint32_t _slot = slot;
665     std::vector<RsAllocation> _vains = hidl_to_rs<RsAllocation>(vains, [](Allocation val) { return hidl_to_rs<RsAllocation>(val); });
666     RsAllocation _vaout = hidl_to_rs<RsAllocation>(vaout);
667     const RsScriptCall* _sc = hidl_to_rs<const RsScriptCall*>(sc);
668     size_t _scLen = _sc != nullptr ? sizeof(ScriptCall) : 0;
669     Device::getHal().ScriptReduce(mContext, _vs, _slot, _vains.data(), _vains.size(), _vaout, _sc, _scLen);
670     return Void();
671 }
672 
scriptSetVarI(Script vs,uint32_t slot,int32_t value)673 Return<void> Context::scriptSetVarI(Script vs, uint32_t slot, int32_t value) {
674     RsScript _vs = hidl_to_rs<RsScript>(vs);
675     uint32_t _slot = slot;
676     int _value = static_cast<int>(value);
677     Device::getHal().ScriptSetVarI(mContext, _vs, _slot, _value);
678     return Void();
679 }
680 
scriptSetVarObj(Script vs,uint32_t slot,ObjectBase obj)681 Return<void> Context::scriptSetVarObj(Script vs, uint32_t slot, ObjectBase obj) {
682     RsScript _vs = hidl_to_rs<RsScript>(vs);
683     uint32_t _slot = slot;
684     RsObjectBase _obj = hidl_to_rs<RsObjectBase>(obj);
685     Device::getHal().ScriptSetVarObj(mContext, _vs, _slot, _obj);
686     return Void();
687 }
688 
scriptSetVarJ(Script vs,uint32_t slot,int64_t value)689 Return<void> Context::scriptSetVarJ(Script vs, uint32_t slot, int64_t value) {
690     RsScript _vs = hidl_to_rs<RsScript>(vs);
691     uint32_t _slot = slot;
692     int64_t _value = static_cast<int64_t>(value);
693     Device::getHal().ScriptSetVarJ(mContext, _vs, _slot, _value);
694     return Void();
695 }
696 
scriptSetVarF(Script vs,uint32_t slot,float value)697 Return<void> Context::scriptSetVarF(Script vs, uint32_t slot, float value) {
698     RsScript _vs = hidl_to_rs<RsScript>(vs);
699     uint32_t _slot = slot;
700     float _value = value;
701     Device::getHal().ScriptSetVarF(mContext, _vs, _slot, _value);
702     return Void();
703 }
704 
scriptSetVarD(Script vs,uint32_t slot,double value)705 Return<void> Context::scriptSetVarD(Script vs, uint32_t slot, double value) {
706     RsScript _vs = hidl_to_rs<RsScript>(vs);
707     uint32_t _slot = slot;
708     double _value = value;
709     Device::getHal().ScriptSetVarD(mContext, _vs, _slot, _value);
710     return Void();
711 }
712 
scriptSetVarV(Script vs,uint32_t slot,const hidl_vec<uint8_t> & data)713 Return<void> Context::scriptSetVarV(Script vs, uint32_t slot, const hidl_vec<uint8_t>& data) {
714     RsScript _vs = hidl_to_rs<RsScript>(vs);
715     uint32_t _slot = slot;
716     const void* _dataPtr = hidl_to_rs<const void*>(data.data());
717     size_t _len = data.size();
718     Device::getHal().ScriptSetVarV(mContext, _vs, _slot, _dataPtr, _len);
719     return Void();
720 }
721 
scriptGetVarV(Script vs,uint32_t slot,Size len,scriptGetVarV_cb _hidl_cb)722 Return<void> Context::scriptGetVarV(Script vs, uint32_t slot, Size len, scriptGetVarV_cb _hidl_cb) {
723     RsScript _vs = hidl_to_rs<RsScript>(vs);
724     uint32_t _slot = slot;
725     size_t _len = static_cast<size_t>(len);
726     std::vector<uint8_t> _data(_len);
727     Device::getHal().ScriptGetVarV(mContext, _vs, _slot, _data.data(), _data.size());
728     hidl_vec<uint8_t> data = _data;
729     _hidl_cb(data);
730     return Void();
731 }
732 
scriptSetVarVE(Script vs,uint32_t slot,const hidl_vec<uint8_t> & data,Element ve,const hidl_vec<uint32_t> & dims)733 Return<void> Context::scriptSetVarVE(Script vs, uint32_t slot, const hidl_vec<uint8_t>& data, Element ve, const hidl_vec<uint32_t>& dims) {
734     RsScript _vs = hidl_to_rs<RsScript>(vs);
735     uint32_t _slot = slot;
736     const void* _dataPtr = hidl_to_rs<const void*>(data.data());
737     size_t _len = data.size();
738     RsElement _ve = hidl_to_rs<RsElement>(ve);
739     const uint32_t* _dimsPtr = dims.data();
740     size_t _dimLen = dims.size() * sizeof(uint32_t);
741     Device::getHal().ScriptSetVarVE(mContext, _vs, _slot, _dataPtr, _len, _ve, _dimsPtr, _dimLen);
742     return Void();
743 }
744 
scriptCCreate(const hidl_string & resName,const hidl_string & cacheDir,const hidl_vec<uint8_t> & text)745 Return<Script> Context::scriptCCreate(const hidl_string& resName, const hidl_string& cacheDir, const hidl_vec<uint8_t>& text) {
746     const hidl_string& _resName = resName;
747     const hidl_string& _cacheDir = cacheDir;
748     const char* _textPtr = hidl_to_rs<const char*>(text.data());
749     size_t _textSize = text.size();
750     RsScript _script = Device::getHal().ScriptCCreate(mContext, _resName.c_str(), _resName.size(), _cacheDir.c_str(), _cacheDir.size(), _textPtr, _textSize);
751     return rs_to_hidl<Script>(_script);
752 }
753 
scriptIntrinsicCreate(ScriptIntrinsicID id,Element elem)754 Return<Script> Context::scriptIntrinsicCreate(ScriptIntrinsicID id, Element elem) {
755     RsScriptIntrinsicID _id = static_cast<RsScriptIntrinsicID>(id);
756     RsElement _elem = hidl_to_rs<RsElement>(elem);
757     RsScript _script = Device::getHal().ScriptIntrinsicCreate(mContext, _id, _elem);
758     return rs_to_hidl<Script>(_script);
759 }
760 
761 
762 // Methods from ::android::hidl::base::V1_0::IBase follow.
763 
764 
765 }  // namespace implementation
766 }  // namespace V1_0
767 }  // namespace renderscript
768 }  // namespace hardware
769 }  // namespace android
770