diff options
author | Mathias Agopian <mathias@google.com> | 2012-04-16 18:40:30 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2012-04-16 18:40:30 -0700 |
commit | 3aecbb0715cb6928e0530ff1e4caa9c0993cc371 (patch) | |
tree | fa74d2ee33fab79da3a3c96b3a4721f6949392a6 | |
parent | 0c8ecacb370b5f7ee6f0fc1fb2ae978f9b670c6d (diff) | |
download | frameworks_native-3aecbb0715cb6928e0530ff1e4caa9c0993cc371.zip frameworks_native-3aecbb0715cb6928e0530ff1e4caa9c0993cc371.tar.gz frameworks_native-3aecbb0715cb6928e0530ff1e4caa9c0993cc371.tar.bz2 |
fix Region const_iterator.
- it returned an empty rect when the region was empty, instead
of returning an empty list of rect.
- also fixed an infinite loop when boolean_operation was given
an empty list of rects
Change-Id: I62225c7dcd2832025bb8f12e6cb3762f2a7b36cb
-rw-r--r-- | include/private/ui/RegionHelper.h | 43 | ||||
-rw-r--r-- | libs/ui/Region.cpp | 10 |
2 files changed, 39 insertions, 14 deletions
diff --git a/include/private/ui/RegionHelper.h b/include/private/ui/RegionHelper.h index 8d76533..421bdda 100644 --- a/include/private/ui/RegionHelper.h +++ b/include/private/ui/RegionHelper.h @@ -96,6 +96,11 @@ private: class SpannerBase { public: + SpannerBase() + : lhs_head(max_value), lhs_tail(max_value), + rhs_head(max_value), rhs_tail(max_value) { + } + enum { lhs_before_rhs = 0, lhs_after_rhs = 1, @@ -158,12 +163,16 @@ private: public: inline Spanner(const region& lhs, const region& rhs) - : lhs(lhs), rhs(rhs) + : lhs(lhs), rhs(rhs) { - SpannerBase::lhs_head = lhs.rects->top + lhs.dy; - SpannerBase::lhs_tail = lhs.rects->bottom + lhs.dy; - SpannerBase::rhs_head = rhs.rects->top + rhs.dy; - SpannerBase::rhs_tail = rhs.rects->bottom + rhs.dy; + if (lhs.count) { + SpannerBase::lhs_head = lhs.rects->top + lhs.dy; + SpannerBase::lhs_tail = lhs.rects->bottom + lhs.dy; + } + if (rhs.count) { + SpannerBase::rhs_head = rhs.rects->top + rhs.dy; + SpannerBase::rhs_tail = rhs.rects->bottom + rhs.dy; + } } inline bool isDone() const { @@ -221,20 +230,28 @@ private: inline void prepare(int inside) { if (inside == SpannerBase::lhs_before_rhs) { - SpannerBase::lhs_head = lhs.rects->left + lhs.dx; - SpannerBase::lhs_tail = lhs.rects->right + lhs.dx; + if (lhs.count) { + SpannerBase::lhs_head = lhs.rects->left + lhs.dx; + SpannerBase::lhs_tail = lhs.rects->right + lhs.dx; + } SpannerBase::rhs_head = max_value; SpannerBase::rhs_tail = max_value; } else if (inside == SpannerBase::lhs_after_rhs) { SpannerBase::lhs_head = max_value; SpannerBase::lhs_tail = max_value; - SpannerBase::rhs_head = rhs.rects->left + rhs.dx; - SpannerBase::rhs_tail = rhs.rects->right + rhs.dx; + if (rhs.count) { + SpannerBase::rhs_head = rhs.rects->left + rhs.dx; + SpannerBase::rhs_tail = rhs.rects->right + rhs.dx; + } } else { - SpannerBase::lhs_head = lhs.rects->left + lhs.dx; - SpannerBase::lhs_tail = lhs.rects->right + lhs.dx; - SpannerBase::rhs_head = rhs.rects->left + rhs.dx; - SpannerBase::rhs_tail = rhs.rects->right + rhs.dx; + if (lhs.count) { + SpannerBase::lhs_head = lhs.rects->left + lhs.dx; + SpannerBase::lhs_tail = lhs.rects->right + lhs.dx; + } + if (rhs.count) { + SpannerBase::rhs_head = rhs.rects->left + rhs.dx; + SpannerBase::rhs_tail = rhs.rects->right + rhs.dx; + } } } diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp index 6e2e731..2c7cdf0 100644 --- a/libs/ui/Region.cpp +++ b/libs/ui/Region.cpp @@ -619,7 +619,15 @@ Region::const_iterator Region::begin() const { } Region::const_iterator Region::end() const { - return isRect() ? ((&mBounds) + 1) : (mStorage.array() + mStorage.size()); + if (isRect()) { + if (isEmpty()) { + return &mBounds; + } else { + return &mBounds + 1; + } + } else { + return mStorage.array() + mStorage.size(); + } } Rect const* Region::getArray(size_t* count) const { |