diff options
author | 2020-04-30 18:40:55 -0400 | |
---|---|---|
committer | 2020-05-01 18:08:58 -0400 | |
commit | 4e0f56bbb07b944e2e4df52a66ae191511fbd38e (patch) | |
tree | 52f0682ea6cc2a293b835ecc70ca1ec90dca36d9 | |
parent | 1b8793a693aaba1be177f1cfaf8932aa30ac0034 (diff) |
Update libEGL to use android::base properties instead of cutils
android::base properties work on host and are generally more concise
than cutils properties.
Also, add libbase to egl_libs_defaults. This does not actually add
another dependency because libbase is already a dependency via
libbacktrace.
Bug: 155436554
Test: atest libEGL_test
Test: build, flash and boot
Change-Id: Ibf66e01ce93524eaa29098ae9c57bc6452133f76
-rw-r--r-- | opengl/libs/Android.bp | 1 | ||||
-rw-r--r-- | opengl/libs/EGL/BlobCache.cpp | 20 | ||||
-rw-r--r-- | opengl/libs/EGL/Loader.cpp | 12 | ||||
-rw-r--r-- | opengl/libs/EGL/egl.cpp | 10 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_angle_platform.cpp | 1 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_display.cpp | 20 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_layers.cpp | 6 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_platform_entries.cpp | 9 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_tls.cpp | 6 |
9 files changed, 32 insertions, 53 deletions
diff --git a/opengl/libs/Android.bp b/opengl/libs/Android.bp index 3997134f47..e8d3684e4e 100644 --- a/opengl/libs/Android.bp +++ b/opengl/libs/Android.bp @@ -100,6 +100,7 @@ cc_defaults { "libgraphicsenv", "libnativewindow", "libbacktrace", + "libbase", ], target: { vendor: { diff --git a/opengl/libs/EGL/BlobCache.cpp b/opengl/libs/EGL/BlobCache.cpp index 74c4d7d07a..74fb0194f9 100644 --- a/opengl/libs/EGL/BlobCache.cpp +++ b/opengl/libs/EGL/BlobCache.cpp @@ -21,7 +21,7 @@ #include <errno.h> #include <inttypes.h> -#include <cutils/properties.h> +#include <android-base/properties.h> #include <log/log.h> #include <chrono> @@ -165,7 +165,8 @@ static inline size_t align4(size_t size) { } size_t BlobCache::getFlattenedSize() const { - size_t size = align4(sizeof(Header) + PROPERTY_VALUE_MAX); + auto buildId = base::GetProperty("ro.build.id", ""); + size_t size = align4(sizeof(Header) + buildId.size()); for (const CacheEntry& e : mCacheEntries) { std::shared_ptr<Blob> const& keyBlob = e.getKey(); std::shared_ptr<Blob> const& valueBlob = e.getValue(); @@ -185,9 +186,9 @@ int BlobCache::flatten(void* buffer, size_t size) const { header->mBlobCacheVersion = blobCacheVersion; header->mDeviceVersion = blobCacheDeviceVersion; header->mNumEntries = mCacheEntries.size(); - char buildId[PROPERTY_VALUE_MAX]; - header->mBuildIdLength = property_get("ro.build.id", buildId, ""); - memcpy(header->mBuildId, buildId, header->mBuildIdLength); + auto buildId = base::GetProperty("ro.build.id", ""); + header->mBuildIdLength = buildId.size(); + memcpy(header->mBuildId, buildId.c_str(), header->mBuildIdLength); // Write cache entries uint8_t* byteBuffer = reinterpret_cast<uint8_t*>(buffer); @@ -238,12 +239,11 @@ int BlobCache::unflatten(void const* buffer, size_t size) { ALOGE("unflatten: bad magic number: %" PRIu32, header->mMagicNumber); return -EINVAL; } - char buildId[PROPERTY_VALUE_MAX]; - int len = property_get("ro.build.id", buildId, ""); + auto buildId = base::GetProperty("ro.build.id", ""); if (header->mBlobCacheVersion != blobCacheVersion || - header->mDeviceVersion != blobCacheDeviceVersion || - len != header->mBuildIdLength || - strncmp(buildId, header->mBuildId, len)) { + header->mDeviceVersion != blobCacheDeviceVersion || + buildId.size() != header->mBuildIdLength || + strncmp(buildId.c_str(), header->mBuildId, buildId.size())) { // We treat version mismatches as an empty cache. return 0; } diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp index d664e4db97..d66ef2b969 100644 --- a/opengl/libs/EGL/Loader.cpp +++ b/opengl/libs/EGL/Loader.cpp @@ -24,8 +24,8 @@ #include <dirent.h> #include <dlfcn.h> +#include <android-base/properties.h> #include <android/dlext.h> -#include <cutils/properties.h> #include <log/log.h> #include <utils/Timers.h> @@ -241,12 +241,12 @@ void* Loader::open(egl_connection_t* cnx) // i.e.: // libGLES_${prop}.so, or: // libEGL_${prop}.so, libGLESv1_CM_${prop}.so, libGLESv2_${prop}.so - char prop[PROPERTY_VALUE_MAX + 1]; for (auto key : HAL_SUBNAME_KEY_PROPERTIES) { - if (property_get(key, prop, nullptr) <= 0) { + auto prop = base::GetProperty(key, ""); + if (prop.empty()) { continue; } - hnd = attempt_to_load_system_driver(cnx, prop, true); + hnd = attempt_to_load_system_driver(cnx, prop.c_str(), true); if (hnd) { break; } else if (strcmp(key, DRIVER_SUFFIX_PROPERTY) == 0) { @@ -510,9 +510,9 @@ static void* load_updated_driver(const char* kind, android_namespace_t* ns) { .library_namespace = ns, }; void* so = nullptr; - char prop[PROPERTY_VALUE_MAX + 1]; for (auto key : HAL_SUBNAME_KEY_PROPERTIES) { - if (property_get(key, prop, nullptr) <= 0) { + auto prop = base::GetProperty(key, ""); + if (prop.empty()) { continue; } std::string name = std::string("lib") + kind + "_" + prop + ".so"; diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp index d5d57d7c9a..43f7a075a7 100644 --- a/opengl/libs/EGL/egl.cpp +++ b/opengl/libs/EGL/egl.cpp @@ -18,7 +18,7 @@ #include <EGL/egl.h> -#include <cutils/properties.h> +#include <android-base/properties.h> #include <log/log.h> @@ -58,9 +58,7 @@ static int gl_no_context() { } else { LOG_ALWAYS_FATAL(error); } - char value[PROPERTY_VALUE_MAX]; - property_get("debug.egl.callstack", value, "0"); - if (atoi(value)) { + if (base::GetBoolProperty("debug.egl.callstack", false)) { CallStack::log(LOG_TAG); } } @@ -224,9 +222,7 @@ void gl_unimplemented() { pthread_mutex_unlock(&sLogPrintMutex); if (printLog) { ALOGE("called unimplemented OpenGL ES API"); - char value[PROPERTY_VALUE_MAX]; - property_get("debug.egl.callstack", value, "0"); - if (atoi(value)) { + if (base::GetBoolProperty("debug.egl.callstack", false)) { CallStack::log(LOG_TAG); } } diff --git a/opengl/libs/EGL/egl_angle_platform.cpp b/opengl/libs/EGL/egl_angle_platform.cpp index 00caff222b..97dc0f1370 100644 --- a/opengl/libs/EGL/egl_angle_platform.cpp +++ b/opengl/libs/EGL/egl_angle_platform.cpp @@ -16,7 +16,6 @@ #if defined(__ANDROID__) -#include <cutils/properties.h> #include "Loader.h" #include "egl_angle_platform.h" diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp index 6af7cd260b..3b1cf712a2 100644 --- a/opengl/libs/EGL/egl_display.cpp +++ b/opengl/libs/EGL/egl_display.cpp @@ -24,7 +24,6 @@ #include <EGL/eglext_angle.h> #include <private/EGL/display.h> -#include <cutils/properties.h> #include "Loader.h" #include "egl_angle_platform.h" #include "egl_cache.h" @@ -32,6 +31,7 @@ #include "egl_tls.h" #include <SurfaceFlingerProperties.h> +#include <android-base/properties.h> #include <android/dlext.h> #include <dlfcn.h> #include <graphicsenv/GraphicsEnv.h> @@ -73,7 +73,7 @@ bool findExtension(const char* exts, const char* name, size_t nameLen) { } bool needsAndroidPEglMitigation() { - static const int32_t vndk_version = property_get_int32("ro.vndk.version", -1); + static const int32_t vndk_version = base::GetIntProperty("ro.vndk.version", -1); return vndk_version <= 28; } @@ -151,10 +151,8 @@ static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_conn attrs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); attrs.push_back(EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE); - char prop[PROPERTY_VALUE_MAX]; - property_get("debug.angle.validation", prop, "0"); attrs.push_back(EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE); - attrs.push_back(atoi(prop)); + attrs.push_back(base::GetBoolProperty("debug.angle.validation", false)); attrs.push_back(EGL_NONE); @@ -372,16 +370,8 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) { egl_cache_t::get()->initialize(this); - char value[PROPERTY_VALUE_MAX]; - property_get("debug.egl.finish", value, "0"); - if (atoi(value)) { - finishOnSwap = true; - } - - property_get("debug.egl.traceGpuCompletion", value, "0"); - if (atoi(value)) { - traceGpuCompletion = true; - } + finishOnSwap = base::GetBoolProperty("debug.egl.finish", false); + traceGpuCompletion = base::GetBoolProperty("debug.egl.traceGpuCompletion", false); // TODO: If device doesn't provide 1.4 or 1.5 then we'll be // changing the behavior from the past where we always advertise diff --git a/opengl/libs/EGL/egl_layers.cpp b/opengl/libs/EGL/egl_layers.cpp index 44a1c0bcd3..ea86c9a05b 100644 --- a/opengl/libs/EGL/egl_layers.cpp +++ b/opengl/libs/EGL/egl_layers.cpp @@ -18,9 +18,9 @@ #include <EGL/egl.h> #include <android-base/file.h> +#include <android-base/properties.h> #include <android-base/strings.h> #include <android/dlext.h> -#include <cutils/properties.h> #include <dlfcn.h> #include <graphicsenv/GraphicsEnv.h> #include <log/log.h> @@ -157,9 +157,7 @@ std::string LayerLoader::GetDebugLayers() { if (debug_layers.empty()) { // Only check system properties if Java settings are empty - char prop[PROPERTY_VALUE_MAX]; - property_get("debug.gles.layers", prop, ""); - debug_layers = prop; + debug_layers = base::GetProperty("debug.gles.layers", ""); } return debug_layers; diff --git a/opengl/libs/EGL/egl_platform_entries.cpp b/opengl/libs/EGL/egl_platform_entries.cpp index c976c609b7..99283be6e1 100644 --- a/opengl/libs/EGL/egl_platform_entries.cpp +++ b/opengl/libs/EGL/egl_platform_entries.cpp @@ -27,13 +27,13 @@ #include <EGL/eglext.h> #include <EGL/eglext_angle.h> -#include <android/hardware_buffer.h> +#include <android-base/properties.h> #include <android-base/strings.h> +#include <android/hardware_buffer.h> #include <graphicsenv/GraphicsEnv.h> #include <private/android/AHardwareBufferHelpers.h> #include <cutils/compiler.h> -#include <cutils/properties.h> #include <log/log.h> #include <condition_variable> @@ -381,10 +381,7 @@ EGLBoolean eglChooseConfigImpl( EGLDisplay dpy, const EGLint *attrib_list, egl_connection_t* const cnx = &gEGLImpl; if (cnx->dso) { if (attrib_list) { - char value[PROPERTY_VALUE_MAX]; - property_get("debug.egl.force_msaa", value, "false"); - - if (!strcmp(value, "true")) { + if (base::GetBoolProperty("debug.egl.force_msaa", false)) { size_t attribCount = 0; EGLint attrib = attrib_list[0]; diff --git a/opengl/libs/EGL/egl_tls.cpp b/opengl/libs/EGL/egl_tls.cpp index aaecb62194..8d118e07ed 100644 --- a/opengl/libs/EGL/egl_tls.cpp +++ b/opengl/libs/EGL/egl_tls.cpp @@ -18,7 +18,7 @@ #include <stdlib.h> -#include <cutils/properties.h> +#include <android-base/properties.h> #include <log/log.h> #include "CallStack.h" #include "egl_platform_entries.h" @@ -96,9 +96,7 @@ void egl_tls_t::setErrorEtcImpl( if (!quiet) { ALOGE("%s:%d error %x (%s)", caller, line, error, egl_strerror(error)); - char value[PROPERTY_VALUE_MAX]; - property_get("debug.egl.callstack", value, "0"); - if (atoi(value)) { + if (base::GetBoolProperty("debug.egl.callstack", false)) { CallStack::log(LOG_TAG); } } |