Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 639a1e19 authored by Chong Zhang's avatar Chong Zhang
Browse files

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
parent ab158ab6
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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",
+21 −12
Original line number Diff line number Diff line
@@ -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