From 639a1e19fceab7909a5ad2df70483155910619bb Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Mon, 22 Apr 2019 14:01:20 -0700 Subject: 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 --- libs/ui/Region.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'libs/ui/Region.cpp') 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 #include -#include #include #include @@ -31,10 +30,18 @@ #include // ---------------------------------------------------------------------------- -#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 +#endif + #if VALIDATE_WITH_CORECG #include #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 -- cgit v1.2.3-59-g8ed1b