Load ANGLE from APK
Allow using ANGLE for GLES instead of native libraries.
To enable this, we also pass a handle to vendor libEGL
to use in GLES backend. A new GLAttrib is added to
facilitate this: EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE. To
facilitate this, we are adding eglext_angle.h to the tree
from ANGLE revision: 57ff6f95
If a namespace is provided, it will be used to find ANGLE.
This should be the default route for most applications.
The namespace will point to the system ANGLE unless an update
has been applied, then it will point to the update.
To install system version:
adb root
adb shell mkdir -p /system/app/ANGLEPrebuilt
adb push ANGLEPrebuilt.apk /system/app/ANGLEPrebuilt/ANGLEPrebuilt.apk
adb reboot
To install update version:
adb install ANGLEPrebuilt.apk
To invoke with APK based apps:
adb shell settings put global angle_enabled_app <package-name>
Test: Manual (calculator, copyTexImage)
Change-Id: Idf2acb64092fe334fd9394c12b2b2f0acaaa4029
(cherry picked from commit cb2d420c7cc5b0a2a33463a8645709f9d411dcab)
(cherry picked from commit 4dd74eb6f2736adf9df785e2c435abb6351c1dac)
(cherry picked from commit 87503698bb3b50e6bf2745c082058eec4abec1a2)
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index a8ef7a0..80daeb9 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -56,6 +56,16 @@
mDriverPath = path;
}
+void GraphicsEnv::setAnglePath(const std::string path) {
+ if (!mAnglePath.empty()) {
+ ALOGV("ignoring attempt to change ANGLE path from '%s' to '%s'", mAnglePath.c_str(),
+ path.c_str());
+ return;
+ }
+ ALOGV("setting ANGLE path to '%s'", path.c_str());
+ mAnglePath = path;
+}
+
void GraphicsEnv::setLayerPaths(NativeLoaderNamespace* appNamespace, const std::string layerPaths) {
if (mLayerPaths.empty()) {
mLayerPaths = layerPaths;
@@ -102,8 +112,31 @@
return mDriverNamespace;
}
+android_namespace_t* GraphicsEnv::getAngleNamespace() {
+ static std::once_flag once;
+ std::call_once(once, [this]() {
+ if (mAnglePath.empty()) return;
+
+ mAngleNamespace = android_create_namespace("ANGLE",
+ nullptr, // ld_library_path
+ mAnglePath.c_str(), // default_library_path
+ ANDROID_NAMESPACE_TYPE_SHARED |
+ ANDROID_NAMESPACE_TYPE_ISOLATED,
+ nullptr, // permitted_when_isolated_path
+ nullptr);
+ if (!mAngleNamespace) ALOGD("Could not create ANGLE namespace from default");
+ });
+
+ return mAngleNamespace;
+}
+
} // namespace android
-extern "C" android_namespace_t* android_getDriverNamespace() {
+extern "C" {
+android_namespace_t* android_getDriverNamespace() {
return android::GraphicsEnv::getInstance().getDriverNamespace();
}
+android_namespace_t* android_getAngleNamespace() {
+ return android::GraphicsEnv::getInstance().getAngleNamespace();
+}
+}