diff options
Diffstat (limited to 'include/ui')
-rw-r--r-- | include/ui/Region.h | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/include/ui/Region.h b/include/ui/Region.h index f0819af..0049fde 100644 --- a/include/ui/Region.h +++ b/include/ui/Region.h @@ -28,6 +28,7 @@ namespace android { // --------------------------------------------------------------------------- +class SharedBuffer; class String8; // --------------------------------------------------------------------------- @@ -41,10 +42,10 @@ public: Region& operator = (const Region& rhs); - inline bool isEmpty() const { return mBounds.isEmpty(); } - inline bool isRect() const { return mStorage.isEmpty(); } + inline bool isEmpty() const { return getBounds().isEmpty(); } + inline bool isRect() const { return mStorage.size() == 1; } - inline Rect getBounds() const { return mBounds; } + inline Rect getBounds() const { return mStorage[mStorage.size() - 1]; } inline Rect bounds() const { return getBounds(); } // the region becomes its bounds @@ -106,17 +107,23 @@ public: /* various ways to access the rectangle list */ + + // STL-like iterators typedef Rect const* const_iterator; - - const_iterator begin() const; - const_iterator end() const; + const_iterator begin() const; + const_iterator end() const; - /* no user serviceable parts here... */ - - size_t getRects(Vector<Rect>& rectList) const; - Rect const* getArray(size_t* count) const; + // returns an array of rect which has the same life-time has this + // Region object. + Rect const* getArray(size_t* count) const; + + // returns a SharedBuffer as well as the number of rects. + // ownership is transfered to the caller. + // the caller must call SharedBuffer::release() to free the memory. + SharedBuffer const* getSharedBuffer(size_t* count) const; + /* no user serviceable parts here... */ // add a rectangle to the internal list. This rectangle must // be sorted in Y and X and must not make the region invalid. @@ -156,8 +163,11 @@ private: static bool validate(const Region& reg, const char* name); - Rect mBounds; - Vector<Rect> mStorage; + // mStorage is a (manually) sorted array of Rects describing the region + // with an extra Rect as the last element which is set to the + // bounds of the region. However, if the region is + // a simple Rect then mStorage contains only that rect. + Vector<Rect> mStorage; }; |