diff options
author | 2020-04-02 09:31:08 -0700 | |
---|---|---|
committer | 2020-04-28 17:57:54 -0700 | |
commit | 547808b38c83f071438a4677f75860228b30b075 (patch) | |
tree | d6e8dddf195d036c72e6e2060fcd5591ddc426ca | |
parent | 59083056e43676ec35ab639af083e65cf757fc20 (diff) |
Fast path Region::orSelf when empty
If a Region is empty, orSelf is equivalent to just assigning from the
other Region/Rect, so we don't need to perform a whole rasterization
pass.
Test: libsurfaceflinger_unittest
Test: simpleperf measurement of SF shows workload reduction
Bug: 153112939
Change-Id: Iefa0e0177a0e85ce72e37842885d3c8b68ce6025
-rw-r--r-- | libs/ui/Region.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp index bf487c4aec..d929cc30ba 100644 --- a/libs/ui/Region.cpp +++ b/libs/ui/Region.cpp @@ -306,6 +306,10 @@ void Region::addRectUnchecked(int l, int t, int r, int b) // ---------------------------------------------------------------------------- Region& Region::orSelf(const Rect& r) { + if (isEmpty()) { + set(r); + return *this; + } return operationSelf(r, op_or); } Region& Region::xorSelf(const Rect& r) { @@ -326,6 +330,10 @@ Region& Region::operationSelf(const Rect& r, uint32_t op) { // ---------------------------------------------------------------------------- Region& Region::orSelf(const Region& rhs) { + if (isEmpty()) { + *this = rhs; + return *this; + } return operationSelf(rhs, op_or); } Region& Region::xorSelf(const Region& rhs) { |