diff options
author | 2019-04-22 14:01:20 -0700 | |
---|---|---|
committer | 2019-04-23 11:35:26 -0700 | |
commit | 639a1e19fceab7909a5ad2df70483155910619bb (patch) | |
tree | 54c9165a06072726100e84b3e6e82d400b3b6fc1 | |
parent | ab158ab6878ec1ab1e7854842a05a8a6929a68bd (diff) |
link libutilscallstack only when VALIDATE_REGIONS is defined
Add cc_defaults in Android.bp to enable this macro and add the lib.
It is not an issue for system build as the lib always exist in system
partition. However some apex builds may use vendor version of the binaries
and we don't want to include unused libs into the apex, since they not
only increase the apex size, but also incur runtime memory cost.
Removing libutilscallstack from the deps will also get rid of its
transitive dependencies such as libbacktrace, liblzma, liblibunwindstack
and libutilscallstack.
bug: 128894663
test: build; manually check that libbacktrace, liblzma, liblibunwindstack
and libutilscallstack are not packaged into com.android.media.swcodec apex.
Change-Id: Ib64b8aa29e8cefe8d1f9eb2bd095221eb5c9a174
-rw-r--r-- | libs/ui/Android.bp | 11 | ||||
-rw-r--r-- | libs/ui/Region.cpp | 33 |
2 files changed, 31 insertions, 13 deletions
diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp index 755418e706..0407d8802c 100644 --- a/libs/ui/Android.bp +++ b/libs/ui/Android.bp @@ -82,6 +82,9 @@ cc_library_shared { "frameworks/native/include", ], + // Uncomment the following line to enable VALIDATE_REGIONS traces + //defaults: ["libui-validate-regions-defaults"], + shared_libs: [ "android.frameworks.bufferhub@1.0", "android.hardware.graphics.allocator@2.0", @@ -98,7 +101,6 @@ cc_library_shared { "libhwbinder", "libsync", "libutils", - "libutilscallstack", "liblog", ], @@ -175,6 +177,13 @@ cc_library_headers { ], } +// defaults to enable VALIDATE_REGIONS traces +cc_defaults { + name: "libui-validate-regions-defaults", + shared_libs: ["libutilscallstack"], + cflags: ["-DVALIDATE_REGIONS"], +} + subdirs = [ "tests", "tools", diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp index 224dc2c122..55e3b99aa1 100644 --- a/libs/ui/Region.cpp +++ b/libs/ui/Region.cpp @@ -22,7 +22,6 @@ #include <android-base/stringprintf.h> #include <utils/Log.h> -#include <utils/CallStack.h> #include <ui/Rect.h> #include <ui/Region.h> @@ -31,10 +30,18 @@ #include <private/ui/RegionHelper.h> // ---------------------------------------------------------------------------- -#define VALIDATE_REGIONS (false) + +// ### VALIDATE_REGIONS ### +// To enable VALIDATE_REGIONS traces, use the "libui-validate-regions-defaults" +// in Android.bp. Do not #define VALIDATE_REGIONS here as it requires extra libs. + #define VALIDATE_WITH_CORECG (false) // ---------------------------------------------------------------------------- +#if defined(VALIDATE_REGIONS) +#include <utils/CallStack.h> +#endif + #if VALIDATE_WITH_CORECG #include <core/SkRegion.h> #endif @@ -67,7 +74,7 @@ Region::Region() { Region::Region(const Region& rhs) : mStorage(rhs.mStorage) { -#if VALIDATE_REGIONS +#if defined(VALIDATE_REGIONS) validate(rhs, "rhs copy-ctor"); #endif } @@ -203,7 +210,7 @@ Region Region::createTJunctionFreeRegion(const Region& r) { outputRegion.mStorage, direction_LTR); outputRegion.mStorage.add(r.getBounds()); // to make region valid, mStorage must end with bounds -#if VALIDATE_REGIONS +#if defined(VALIDATE_REGIONS) validate(outputRegion, "T-Junction free region"); #endif @@ -212,7 +219,7 @@ Region Region::createTJunctionFreeRegion(const Region& r) { Region& Region::operator = (const Region& rhs) { -#if VALIDATE_REGIONS +#if defined(VALIDATE_REGIONS) validate(*this, "this->operator="); validate(rhs, "rhs.operator="); #endif @@ -599,10 +606,12 @@ bool Region::validate(const Region& reg, const char* name, bool silent) result = false; ALOGE_IF(!silent, "%s: mStorage size is 2, which is never valid", name); } +#if defined(VALIDATE_REGIONS) if (result == false && !silent) { reg.dump(name); CallStack stack(LOG_TAG); } +#endif return result; } @@ -610,7 +619,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, const Region& lhs, const Region& rhs, int dx, int dy) { -#if VALIDATE_REGIONS +#if defined(VALIDATE_REGIONS) validate(lhs, "boolean_operation (before): lhs"); validate(rhs, "boolean_operation (before): rhs"); validate(dst, "boolean_operation (before): dst"); @@ -630,7 +639,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, operation(r); } -#if VALIDATE_REGIONS +#if defined(VALIDATE_REGIONS) validate(lhs, "boolean_operation: lhs"); validate(rhs, "boolean_operation: rhs"); validate(dst, "boolean_operation: dst"); @@ -728,7 +737,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, return; } -#if VALIDATE_WITH_CORECG || VALIDATE_REGIONS +#if VALIDATE_WITH_CORECG || defined(VALIDATE_REGIONS) boolean_operation(op, dst, lhs, Region(rhs), dx, dy); #else size_t lhs_count; @@ -760,7 +769,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, void Region::translate(Region& reg, int dx, int dy) { if ((dx || dy) && !reg.isEmpty()) { -#if VALIDATE_REGIONS +#if defined(VALIDATE_REGIONS) validate(reg, "translate (before)"); #endif size_t count = reg.mStorage.size(); @@ -770,7 +779,7 @@ void Region::translate(Region& reg, int dx, int dy) rects++; count--; } -#if VALIDATE_REGIONS +#if defined(VALIDATE_REGIONS) validate(reg, "translate (after)"); #endif } @@ -789,7 +798,7 @@ size_t Region::getFlattenedSize() const { } status_t Region::flatten(void* buffer, size_t size) const { -#if VALIDATE_REGIONS +#if defined(VALIDATE_REGIONS) validate(*this, "Region::flatten"); #endif if (size < getFlattenedSize()) { @@ -836,7 +845,7 @@ status_t Region::unflatten(void const* buffer, size_t size) { result.mStorage.push_back(rect); } -#if VALIDATE_REGIONS +#if defined(VALIDATE_REGIONS) validate(result, "Region::unflatten"); #endif |