From 3ab68558fa5a4b8f792a54965a010f03385bd271 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 31 Aug 2012 14:31:40 -0700 Subject: change how we store Region data internally We used to keep the bounds of the region as a separate rectangle. Instead we now store it as the last element of the Vector<> of Rects. This has the benefit of being slightly more efficient when copying regions and reduces the overhead of small regions, but more importantly will allow us to export the underlaying SharedBuffer (eventually). Change-Id: I80790e4fb1a09a747a5616000cfef852ac4ce9e9 --- include/ui/Region.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'include/ui/Region.h') diff --git a/include/ui/Region.h b/include/ui/Region.h index f0819af..46a36ed 100644 --- a/include/ui/Region.h +++ b/include/ui/Region.h @@ -41,10 +41,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 @@ -114,7 +114,6 @@ public: /* no user serviceable parts here... */ - size_t getRects(Vector& rectList) const; Rect const* getArray(size_t* count) const; @@ -156,8 +155,11 @@ private: static bool validate(const Region& reg, const char* name); - Rect mBounds; - Vector 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 mStorage; }; -- cgit v1.1