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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
#include "Context.h"
#include "Device.h"
namespace android {
namespace hardware {
namespace renderscript {
namespace V1_0 {
namespace implementation {
static dispatchTable loadHAL();
dispatchTable Device::mDispatchHal = loadHAL();
Device::Device() {
}
dispatchTable& Device::getHal() {
return mDispatchHal;
}
// Methods from ::android::hardware::renderscript::V1_0::IDevice follow.
Return<sp<IContext>> Device::contextCreate(uint32_t sdkVersion, ContextType ct, int32_t flags) {
return new Context(sdkVersion, ct, flags);
}
// Methods from ::android::hidl::base::V1_0::IBase follow.
IDevice* HIDL_FETCH_IDevice(const char* /* name */) {
return new Device();
}
// Helper function
dispatchTable loadHAL() {
static_assert(sizeof(void*) <= sizeof(uint64_t), "RenderScript HIDL Error: sizeof(void*) > sizeof(uint64_t)");
static_assert(sizeof(size_t) <= sizeof(uint64_t), "RenderScript HIDL Error: sizeof(size_t) > sizeof(uint64_t)");
const char* filename = "libRS_internal.so";
void* handle = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
dispatchTable dispatchHal = {
.SetNativeLibDir = (SetNativeLibDirFnPtr) nullptr,
.Allocation1DData =
(Allocation1DDataFnPtr)dlsym(handle, "rsAllocation1DData"),
.Allocation1DElementData = (Allocation1DElementDataFnPtr) nullptr,
.Allocation1DRead =
(Allocation1DReadFnPtr)dlsym(handle, "rsAllocation1DRead"),
.Allocation2DData =
(Allocation2DDataFnPtr)dlsym(handle, "rsAllocation2DData"),
.Allocation2DRead =
(Allocation2DReadFnPtr)dlsym(handle, "rsAllocation2DRead"),
.Allocation3DData =
(Allocation3DDataFnPtr)dlsym(handle, "rsAllocation3DData"),
.Allocation3DRead =
(Allocation3DReadFnPtr)dlsym(handle, "rsAllocation3DRead"),
.AllocationAdapterCreate = (AllocationAdapterCreateFnPtr)dlsym(
handle, "rsAllocationAdapterCreate"),
.AllocationAdapterOffset = (AllocationAdapterOffsetFnPtr)dlsym(
handle, "rsAllocationAdapterOffset"),
.AllocationCopy2DRange = (AllocationCopy2DRangeFnPtr)dlsym(
handle, "rsAllocationCopy2DRange"),
.AllocationCopy3DRange = (AllocationCopy3DRangeFnPtr)dlsym(
handle, "rsAllocationCopy3DRange"),
.AllocationCopyToBitmap = (AllocationCopyToBitmapFnPtr)dlsym(
handle, "rsAllocationCopyToBitmap"),
.AllocationCreateFromBitmap = (AllocationCreateFromBitmapFnPtr)dlsym(
handle, "rsAllocationCreateFromBitmap"),
.AllocationCreateStrided = (AllocationCreateStridedFnPtr)dlsym(
handle, "rsAllocationCreateStrided"),
.AllocationCreateTyped = (AllocationCreateTypedFnPtr)dlsym(
handle, "rsAllocationCreateTyped"),
.AllocationCubeCreateFromBitmap =
(AllocationCubeCreateFromBitmapFnPtr)dlsym(
handle, "rsAllocationCubeCreateFromBitmap"),
.AllocationElementData = (AllocationElementDataFnPtr)dlsym(
handle, "rsAllocationElementData"),
.AllocationElementRead = (AllocationElementReadFnPtr)dlsym(
handle, "rsAllocationElementRead"),
.AllocationGenerateMipmaps = (AllocationGenerateMipmapsFnPtr)dlsym(
handle, "rsAllocationGenerateMipmaps"),
.AllocationGetPointer =
(AllocationGetPointerFnPtr)dlsym(handle, "rsAllocationGetPointer"),
.AllocationGetSurface =
(AllocationGetSurfaceFnPtr)dlsym(handle, "rsAllocationGetSurface"),
.AllocationGetType =
(AllocationGetTypeFnPtr)dlsym(handle, "rsaAllocationGetType"),
.AllocationIoReceive =
(AllocationIoReceiveFnPtr)dlsym(handle, "rsAllocationIoReceive"),
.AllocationIoSend =
(AllocationIoSendFnPtr)dlsym(handle, "rsAllocationIoSend"),
.AllocationRead =
(AllocationReadFnPtr)dlsym(handle, "rsAllocationRead"),
.AllocationResize1D =
(AllocationResize1DFnPtr)dlsym(handle, "rsAllocationResize1D"),
.AllocationSetSurface =
(AllocationSetSurfaceFnPtr)dlsym(handle, "rsAllocationSetSurface"),
.AllocationSetupBufferQueue = (AllocationSetupBufferQueueFnPtr)dlsym(
handle, "rsAllocationSetupBufferQueue"),
.AllocationShareBufferQueue = (AllocationShareBufferQueueFnPtr)dlsym(
handle, "rsAllocationShareBufferQueue"),
.AllocationSyncAll =
(AllocationSyncAllFnPtr)dlsym(handle, "rsAllocationSyncAll"),
.AssignName = (AssignNameFnPtr)dlsym(handle, "rsAssignName"),
.ClosureCreate = (ClosureCreateFnPtr)dlsym(handle, "rsClosureCreate"),
.ClosureSetArg = (ClosureSetArgFnPtr)dlsym(handle, "rsClosureSetArg"),
.ClosureSetGlobal =
(ClosureSetGlobalFnPtr)dlsym(handle, "rsClosureSetGlobal"),
.ContextCreateVendor =
(ContextCreateVendorFnPtr)dlsym(handle, "rsContextCreateVendor"),
.ContextDeinitToClient = (ContextDeinitToClientFnPtr)dlsym(
handle, "rsContextDeinitToClient"),
.ContextDestroy =
(ContextDestroyFnPtr)dlsym(handle, "rsContextDestroy"),
.ContextDump = (ContextDumpFnPtr)dlsym(handle, "rsContextDump"),
.ContextFinish = (ContextFinishFnPtr)dlsym(handle, "rsContextFinish"),
.ContextGetMessage =
(ContextGetMessageFnPtr)dlsym(handle, "rsContextGetMessage"),
.ContextInitToClient =
(ContextInitToClientFnPtr)dlsym(handle, "rsContextInitToClient"),
.ContextPeekMessage =
(ContextPeekMessageFnPtr)dlsym(handle, "rsContextPeekMessage"),
.ContextSendMessage =
(ContextSendMessageFnPtr)dlsym(handle, "rsContextSendMessage"),
.ContextSetCacheDir =
(ContextSetCacheDirFnPtr)dlsym(handle, "rsContextSetCacheDir"),
.ContextSetPriority =
(ContextSetPriorityFnPtr)dlsym(handle, "rsContextSetPriority"),
.DeviceCreate = (DeviceCreateFnPtr) nullptr,
.DeviceDestroy = (DeviceDestroyFnPtr) nullptr,
.DeviceSetConfig = (DeviceSetConfigFnPtr) nullptr,
.ElementCreate2 =
(ElementCreate2FnPtr)dlsym(handle, "rsElementCreate2"),
.ElementCreate = (ElementCreateFnPtr)dlsym(handle, "rsElementCreate"),
.ElementGetNativeData =
(ElementGetNativeDataFnPtr)dlsym(handle, "rsaElementGetNativeData"),
.ElementGetSubElements = (ElementGetSubElementsFnPtr)dlsym(
handle, "rsaElementGetSubElements"),
.GetName = (GetNameFnPtr)dlsym(handle, "rsaGetName"),
.InvokeClosureCreate =
(InvokeClosureCreateFnPtr)dlsym(handle, "rsInvokeClosureCreate"),
.ObjDestroy = (ObjDestroyFnPtr)dlsym(handle, "rsObjDestroy"),
.SamplerCreate = (SamplerCreateFnPtr)dlsym(handle, "rsSamplerCreate"),
.ScriptBindAllocation =
(ScriptBindAllocationFnPtr)dlsym(handle, "rsScriptBindAllocation"),
.ScriptCCreate = (ScriptCCreateFnPtr)dlsym(handle, "rsScriptCCreate"),
.ScriptFieldIDCreate =
(ScriptFieldIDCreateFnPtr)dlsym(handle, "rsScriptFieldIDCreate"),
.ScriptForEach = (ScriptForEachFnPtr) nullptr,
.ScriptForEachMulti =
(ScriptForEachMultiFnPtr)dlsym(handle, "rsScriptForEachMulti"),
.ScriptGetVarV = (ScriptGetVarVFnPtr)dlsym(handle, "rsScriptGetVarV"),
.ScriptGroup2Create =
(ScriptGroup2CreateFnPtr)dlsym(handle, "rsScriptGroup2Create"),
.ScriptGroupCreate =
(ScriptGroupCreateFnPtr)dlsym(handle, "rsScriptGroupCreate"),
.ScriptGroupExecute =
(ScriptGroupExecuteFnPtr)dlsym(handle, "rsScriptGroupExecute"),
.ScriptGroupSetInput =
(ScriptGroupSetInputFnPtr)dlsym(handle, "rsScriptGroupSetInput"),
.ScriptGroupSetOutput =
(ScriptGroupSetOutputFnPtr)dlsym(handle, "rsScriptGroupSetOutput"),
.ScriptIntrinsicCreate = (ScriptIntrinsicCreateFnPtr)dlsym(
handle, "rsScriptIntrinsicCreate"),
.ScriptInvoke = (ScriptInvokeFnPtr)dlsym(handle, "rsScriptInvoke"),
.ScriptInvokeIDCreate =
(ScriptInvokeIDCreateFnPtr)dlsym(handle, "rsScriptInvokeIDCreate"),
.ScriptInvokeV = (ScriptInvokeVFnPtr)dlsym(handle, "rsScriptInvokeV"),
.ScriptKernelIDCreate =
(ScriptKernelIDCreateFnPtr)dlsym(handle, "rsScriptKernelIDCreate"),
.ScriptReduce = (ScriptReduceFnPtr)dlsym(handle, "rsScriptReduce"),
.ScriptSetTimeZone =
(ScriptSetTimeZoneFnPtr)dlsym(handle, "rsScriptSetTimeZone"),
.ScriptSetVarD = (ScriptSetVarDFnPtr)dlsym(handle, "rsScriptSetVarD"),
.ScriptSetVarF = (ScriptSetVarFFnPtr)dlsym(handle, "rsScriptSetVarF"),
.ScriptSetVarI = (ScriptSetVarIFnPtr)dlsym(handle, "rsScriptSetVarI"),
.ScriptSetVarJ = (ScriptSetVarJFnPtr)dlsym(handle, "rsScriptSetVarJ"),
.ScriptSetVarObj =
(ScriptSetVarObjFnPtr)dlsym(handle, "rsScriptSetVarObj"),
.ScriptSetVarVE =
(ScriptSetVarVEFnPtr)dlsym(handle, "rsScriptSetVarVE"),
.ScriptSetVarV = (ScriptSetVarVFnPtr)dlsym(handle, "rsScriptSetVarV"),
.TypeCreate = (TypeCreateFnPtr)dlsym(handle, "rsTypeCreate"),
.TypeGetNativeData =
(TypeGetNativeDataFnPtr)dlsym(handle, "rsaTypeGetNativeData"),
};
return dispatchHal;
}
} // namespace implementation
} // namespace V1_0
} // namespace renderscript
} // namespace hardware
} // namespace android
|