diff options
author | 2019-05-28 18:07:56 +0100 | |
---|---|---|
committer | 2019-05-28 18:35:29 +0100 | |
commit | a02a12d765f69325a1d844548e41370bda9dcc6d (patch) | |
tree | db95ff0ea203d56d5a613cad06e547af9117f2f5 /libs/hwui/Properties.cpp | |
parent | 3074f10b41fd1b622dc698d89e4c9e1bcb5b05cf (diff) |
Use libbase API to access system properties in libhwui
Calls to licutils properties API are replaced by calls to libbase
properties API. This will make it easier to make a host target for
libhwui as libbase provides a host implementation for its properties
API.
Bug: 117921091
Test: N/A
Change-Id: I15b4fe1a16d2bc7b271387d8cf3403940b8aae2d
Diffstat (limited to 'libs/hwui/Properties.cpp')
-rw-r--r-- | libs/hwui/Properties.cpp | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp index af20c4f4f20e..2196b0fde90f 100644 --- a/libs/hwui/Properties.cpp +++ b/libs/hwui/Properties.cpp @@ -23,8 +23,8 @@ #include <algorithm> #include <cstdlib> +#include <android-base/properties.h> #include <cutils/compiler.h> -#include <cutils/properties.h> #include <log/log.h> namespace android { @@ -67,64 +67,54 @@ bool Properties::isolatedProcess = false; int Properties::contextPriority = 0; int Properties::defaultRenderAhead = -1; -static int property_get_int(const char* key, int defaultValue) { - char buf[PROPERTY_VALUE_MAX] = { - '\0', - }; - - if (property_get(key, buf, "") > 0) { - return atoi(buf); - } - return defaultValue; -} - bool Properties::load() { - char property[PROPERTY_VALUE_MAX]; bool prevDebugLayersUpdates = debugLayersUpdates; bool prevDebugOverdraw = debugOverdraw; debugOverdraw = false; - if (property_get(PROPERTY_DEBUG_OVERDRAW, property, nullptr) > 0) { - INIT_LOGD(" Overdraw debug enabled: %s", property); - if (!strcmp(property, "show")) { + std::string debugOverdrawProperty = base::GetProperty(PROPERTY_DEBUG_OVERDRAW, ""); + if (debugOverdrawProperty != "") { + INIT_LOGD(" Overdraw debug enabled: %s", debugOverdrawProperty); + if (debugOverdrawProperty == "show") { debugOverdraw = true; overdrawColorSet = OverdrawColorSet::Default; - } else if (!strcmp(property, "show_deuteranomaly")) { + } else if (debugOverdrawProperty == "show_deuteranomaly") { debugOverdraw = true; overdrawColorSet = OverdrawColorSet::Deuteranomaly; } } sProfileType = ProfileType::None; - if (property_get(PROPERTY_PROFILE, property, "") > 0) { - if (!strcmp(property, PROPERTY_PROFILE_VISUALIZE_BARS)) { + std::string profileProperty = base::GetProperty(PROPERTY_PROFILE, ""); + if (profileProperty != "") { + if (profileProperty == PROPERTY_PROFILE_VISUALIZE_BARS) { sProfileType = ProfileType::Bars; - } else if (!strcmp(property, "true")) { + } else if (profileProperty == "true") { sProfileType = ProfileType::Console; } } - debugLayersUpdates = property_get_bool(PROPERTY_DEBUG_LAYERS_UPDATES, false); + debugLayersUpdates = base::GetBoolProperty(PROPERTY_DEBUG_LAYERS_UPDATES, false); INIT_LOGD(" Layers updates debug enabled: %d", debugLayersUpdates); - showDirtyRegions = property_get_bool(PROPERTY_DEBUG_SHOW_DIRTY_REGIONS, false); + showDirtyRegions = base::GetBoolProperty(PROPERTY_DEBUG_SHOW_DIRTY_REGIONS, false); - debugLevel = (DebugLevel)property_get_int(PROPERTY_DEBUG, kDebugDisabled); + debugLevel = (DebugLevel)base::GetIntProperty(PROPERTY_DEBUG, (int)kDebugDisabled); - skipEmptyFrames = property_get_bool(PROPERTY_SKIP_EMPTY_DAMAGE, true); - useBufferAge = property_get_bool(PROPERTY_USE_BUFFER_AGE, true); - enablePartialUpdates = property_get_bool(PROPERTY_ENABLE_PARTIAL_UPDATES, true); + skipEmptyFrames = base::GetBoolProperty(PROPERTY_SKIP_EMPTY_DAMAGE, true); + useBufferAge = base::GetBoolProperty(PROPERTY_USE_BUFFER_AGE, true); + enablePartialUpdates = base::GetBoolProperty(PROPERTY_ENABLE_PARTIAL_UPDATES, true); - filterOutTestOverhead = property_get_bool(PROPERTY_FILTER_TEST_OVERHEAD, false); + filterOutTestOverhead = base::GetBoolProperty(PROPERTY_FILTER_TEST_OVERHEAD, false); - skpCaptureEnabled = debuggingEnabled && property_get_bool(PROPERTY_CAPTURE_SKP_ENABLED, false); + skpCaptureEnabled = debuggingEnabled && base::GetBoolProperty(PROPERTY_CAPTURE_SKP_ENABLED, false); SkAndroidFrameworkTraceUtil::setEnableTracing( - property_get_bool(PROPERTY_SKIA_ATRACE_ENABLED, false)); + base::GetBoolProperty(PROPERTY_SKIA_ATRACE_ENABLED, false)); - runningInEmulator = property_get_bool(PROPERTY_QEMU_KERNEL, false); + runningInEmulator = base::GetBoolProperty(PROPERTY_QEMU_KERNEL, false); - defaultRenderAhead = std::max(-1, std::min(2, property_get_int(PROPERTY_RENDERAHEAD, + defaultRenderAhead = std::max(-1, std::min(2, base::GetIntProperty(PROPERTY_RENDERAHEAD, render_ahead().value_or(0)))); return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw); @@ -175,9 +165,8 @@ RenderPipelineType Properties::peekRenderPipelineType() { return sRenderPipelineType; } bool useVulkan = use_vulkan().value_or(false); - char prop[PROPERTY_VALUE_MAX]; - property_get(PROPERTY_RENDERER, prop, useVulkan ? "skiavk" : "skiagl"); - if (!strcmp(prop, "skiavk")) { + std::string rendererProperty = base::GetProperty(PROPERTY_RENDERER, useVulkan ? "skiavk" : "skiagl"); + if (rendererProperty == "skiavk") { return RenderPipelineType::SkiaVulkan; } return RenderPipelineType::SkiaGL; |