/* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_HARDWARE_RENDERSCRIPT_V1_0_CONTEXT_H #define ANDROID_HARDWARE_RENDERSCRIPT_V1_0_CONTEXT_H #include "cpp/rsDispatch.h" #include "dlfcn.h" #include #include #include namespace android { namespace hardware { namespace renderscript { namespace V1_0 { namespace implementation { using ::android::hardware::renderscript::V1_0::AllocationCubemapFace; using ::android::hardware::renderscript::V1_0::AllocationMipmapControl; using ::android::hardware::renderscript::V1_0::AllocationUsageType; using ::android::hardware::renderscript::V1_0::ContextType; using ::android::hardware::renderscript::V1_0::DataKind; using ::android::hardware::renderscript::V1_0::DataType; using ::android::hardware::renderscript::V1_0::IContext; using ::android::hardware::renderscript::V1_0::MessageToClientType; using ::android::hardware::renderscript::V1_0::SamplerValue; using ::android::hardware::renderscript::V1_0::ScriptCall; using ::android::hardware::renderscript::V1_0::ScriptIntrinsicID; using ::android::hardware::renderscript::V1_0::ThreadPriorities; using ::android::hardware::renderscript::V1_0::YuvFormat; using ::android::hidl::base::V1_0::IBase; using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; using ::android::sp; struct Context : public IContext { Context(uint32_t sdkVersion, ContextType ct, int32_t flags); // Methods from ::android::hardware::renderscript::V1_0::IContext follow. Return allocationAdapterCreate(Type type, Allocation baseAlloc) override; Return allocationAdapterOffset(Allocation alloc, const hidl_vec& offsets) override; Return allocationGetType(Allocation allocation) override; Return allocationCreateTyped(Type type, AllocationMipmapControl amips, int32_t usage, Ptr ptr) override; Return allocationCreateFromBitmap(Type type, AllocationMipmapControl amips, const hidl_vec& bitmap, int32_t usage) override; Return allocationCubeCreateFromBitmap(Type type, AllocationMipmapControl amips, const hidl_vec& bitmap, int32_t usage) override; Return allocationGetNativeWindow(Allocation allocation) override; Return allocationSetNativeWindow(Allocation allocation, NativeWindow nativewindow) override; Return allocationSetupBufferQueue(Allocation alloc, uint32_t numBuffer) override; Return allocationShareBufferQueue(Allocation baseAlloc, Allocation subAlloc) override; Return allocationCopyToBitmap(Allocation allocation, Ptr data, Size sizeBytes) override; Return allocation1DWrite(Allocation allocation, uint32_t offset, uint32_t lod, uint32_t count, const hidl_vec& data) override; Return allocationElementWrite(Allocation allocation, uint32_t x, uint32_t y, uint32_t z, uint32_t lod, const hidl_vec& data, Size compIdx) override; Return allocation2DWrite(Allocation allocation, uint32_t xoff, uint32_t yoff, uint32_t lod, AllocationCubemapFace face, uint32_t w, uint32_t h, const hidl_vec& data, Size stride) override; Return 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& data, Size stride) override; Return allocationGenerateMipmaps(Allocation allocation) override; Return allocationRead(Allocation allocation, Ptr data, Size sizeBytes) override; Return allocation1DRead(Allocation allocation, uint32_t xoff, uint32_t lod, uint32_t count, Ptr data, Size sizeBytes) override; Return allocationElementRead(Allocation allocation, uint32_t x, uint32_t y, uint32_t z, uint32_t lod, Ptr data, Size sizeBytes, Size compIdx) override; Return 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) override; Return 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) override; Return allocationSyncAll(Allocation allocation, AllocationUsageType usageType) override; Return allocationResize1D(Allocation allocation, uint32_t dimX) override; Return 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) override; Return 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) override; Return allocationIoSend(Allocation allocation) override; Return allocationIoReceive(Allocation allocation) override; Return allocationGetPointer(Allocation allocation, uint32_t lod, AllocationCubemapFace face, uint32_t z, allocationGetPointer_cb _hidl_cb) override; Return elementGetNativeMetadata(Element element, elementGetNativeMetadata_cb _hidl_cb) override; Return elementGetSubElements(Element element, Size numSubElem, elementGetSubElements_cb _hidl_cb) override; Return elementCreate(DataType dt, DataKind dk, bool norm, uint32_t size) override; Return elementComplexCreate(const hidl_vec& eins, const hidl_vec& names, const hidl_vec& arraySizes) override; Return typeGetNativeMetadata(Type type, typeGetNativeMetadata_cb _hidl_cb) override; Return typeCreate(Element element, uint32_t dimX, uint32_t dimY, uint32_t dimZ, bool mipmaps, bool faces, YuvFormat yuv) override; Return contextDestroy() override; Return contextGetMessage(Ptr data, Size size, contextGetMessage_cb _hidl_cb) override; Return contextPeekMessage(contextPeekMessage_cb _hidl_cb) override; Return contextSendMessage(uint32_t id, const hidl_vec& data) override; Return contextInitToClient() override; Return contextDeinitToClient() override; Return contextFinish() override; Return contextLog() override; Return contextSetPriority(ThreadPriorities priority) override; Return contextSetCacheDir(const hidl_string& cacheDir) override; Return assignName(ObjectBase obj, const hidl_string& name) override; Return getName(ObjectBase obj, getName_cb _hidl_cb) override; Return closureCreate(ScriptKernelID kernelID, Allocation returnValue, const hidl_vec& fieldIDS, const hidl_vec& values, const hidl_vec& sizes, const hidl_vec& depClosures, const hidl_vec& depFieldIDS) override; Return invokeClosureCreate(ScriptInvokeID invokeID, const hidl_vec& params, const hidl_vec& fieldIDS, const hidl_vec& values, const hidl_vec& sizes) override; Return closureSetArg(Closure closure, uint32_t index, Ptr value, int32_t size) override; Return closureSetGlobal(Closure closure, ScriptFieldID fieldID, int64_t value, int32_t size) override; Return scriptKernelIDCreate(Script script, int32_t slot, int32_t sig) override; Return scriptInvokeIDCreate(Script script, int32_t slot) override; Return scriptFieldIDCreate(Script script, int32_t slot) override; Return scriptGroupCreate(const hidl_vec& kernels, const hidl_vec& srcK, const hidl_vec& dstK, const hidl_vec& dstF, const hidl_vec& types) override; Return scriptGroup2Create(const hidl_string& name, const hidl_string& cacheDir, const hidl_vec& closures) override; Return scriptGroupSetOutput(ScriptGroup sg, ScriptKernelID kid, Allocation alloc) override; Return scriptGroupSetInput(ScriptGroup sg, ScriptKernelID kid, Allocation alloc) override; Return scriptGroupExecute(ScriptGroup sg) override; Return objDestroy(ObjectBase obj) override; Return samplerCreate(SamplerValue magFilter, SamplerValue minFilter, SamplerValue wrapS, SamplerValue wrapT, SamplerValue wrapR, float aniso) override; Return scriptBindAllocation(Script script, Allocation allocation, uint32_t slot) override; Return scriptSetTimeZone(Script script, const hidl_string& timeZone) override; Return scriptInvoke(Script vs, uint32_t slot) override; Return scriptInvokeV(Script vs, uint32_t slot, const hidl_vec& data) override; Return scriptForEach(Script vs, uint32_t slot, const hidl_vec& vains, Allocation vaout, const hidl_vec& params, Ptr sc) override; Return scriptReduce(Script vs, uint32_t slot, const hidl_vec& vains, Allocation vaout, Ptr sc) override; Return scriptSetVarI(Script vs, uint32_t slot, int32_t value) override; Return scriptSetVarObj(Script vs, uint32_t slot, ObjectBase obj) override; Return scriptSetVarJ(Script vs, uint32_t slot, int64_t value) override; Return scriptSetVarF(Script vs, uint32_t slot, float value) override; Return scriptSetVarD(Script vs, uint32_t slot, double value) override; Return scriptSetVarV(Script vs, uint32_t slot, const hidl_vec& data) override; Return scriptGetVarV(Script vs, uint32_t slot, Size len, scriptGetVarV_cb _hidl_cb) override; Return scriptSetVarVE(Script vs, uint32_t slot, const hidl_vec& data, Element ve, const hidl_vec& dims) override; Return