Guard against overflow errors for transparent regions

Applications may send arbitrary transparent regions to SurfaceFlinger
by overriding ViewGroup#gatherTransparentRegion, or a savvy binary may
apply a custom transparent region directly on a transaction. Arbitrary
transparent regions may cause SurfaceFlinger to crash on malformed
input.

We can guard against some of these crashes by constraining the
transparent region to be within the layer bounds

Bug: 230227800
Test: Stress tests
Test: libcompositionengine_test
Change-Id: I38f6f42dce38cdf2f34ba41af658adfdad290417
(cherry picked from commit e60f0b9057c99cdbb5ca55e85c8f1ef5479d38a6)
Merged-In: I38f6f42dce38cdf2f34ba41af658adfdad290417
2 files changed