Make rsContext be able to have info about the path of native libs
for 64bit Renderscript compat lib.
- Native lib path stored in Java and queried from JNI.
- Then set to Context during context creation.
Change-Id: I3c997cf849efb7b9a0b0ac35d5b62289d70e7434
diff --git a/cpu_ref/rsCpuScript.cpp b/cpu_ref/rsCpuScript.cpp
index 3190d79..94a1db8 100644
--- a/cpu_ref/rsCpuScript.cpp
+++ b/cpu_ref/rsCpuScript.cpp
@@ -113,10 +113,9 @@
static std::string findSharedObjectName(const char *cacheDir,
const char *resName) {
-
#ifndef RS_SERVER
std::string scriptSOName(cacheDir);
-#ifdef RS_COMPATIBILITY_LIB
+#if defined(RS_COMPATIBILITY_LIB) && !defined(__LP64__)
size_t cutPos = scriptSOName.rfind("cache");
if (cutPos != std::string::npos) {
scriptSOName.erase(cutPos);
@@ -126,11 +125,11 @@
scriptSOName.append("/lib/librs.");
#else
scriptSOName.append("/librs.");
-#endif
+#endif // RS_COMPATIBILITY_LIB
#else
std::string scriptSOName("lib");
-#endif
+#endif // RS_SERVER
scriptSOName.append(resName);
scriptSOName.append(".so");
@@ -329,10 +328,15 @@
#endif // RS_COMPATIBILITY_LIB
-void* SharedLibraryUtils::loadSharedLibrary(const char *cacheDir, const char *resName) {
+
+void* SharedLibraryUtils::loadSharedLibrary(const char *cacheDir, const char *resName, const char *nativeLibDir) {
void *loaded = nullptr;
+#if defined(RS_COMPATIBILITY_LIB) && defined(__LP64__)
+ std::string scriptSOName = findSharedObjectName(nativeLibDir, resName);
+#else
std::string scriptSOName = findSharedObjectName(cacheDir, resName);
+#endif
// We should check if we can load the library from the standard app
// location for shared libraries first.
@@ -825,8 +829,8 @@
goto error;
}
#else // RS_COMPATIBILITY_LIB is defined
-
- mScriptSO = SharedLibraryUtils::loadSharedLibrary(cacheDir, resName);
+ const char *nativeLibDir = mCtx->getContext()->getNativeLibDir();
+ mScriptSO = SharedLibraryUtils::loadSharedLibrary(cacheDir, resName, nativeLibDir);
if (!mScriptSO) {
goto error;