diff options
author | Mathias Agopian <mathias@google.com> | 2012-08-31 15:41:24 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2012-08-31 18:38:22 -0700 |
commit | 2401ead70099c982796ecc3ec63ec8a5570948fc (patch) | |
tree | 70b4464149c060bf808a5cb7e15de67b612d3fe1 /libs/ui | |
parent | 3ab68558fa5a4b8f792a54965a010f03385bd271 (diff) | |
download | frameworks_native-2401ead70099c982796ecc3ec63ec8a5570948fc.zip frameworks_native-2401ead70099c982796ecc3ec63ec8a5570948fc.tar.gz frameworks_native-2401ead70099c982796ecc3ec63ec8a5570948fc.tar.bz2 |
Add a way to retrieve a Region as a SharedBuffer
Change-Id: Ia53cb905fbc88f899521658545f990fb9217b1e1
Diffstat (limited to 'libs/ui')
-rw-r--r-- | libs/ui/Region.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp index cdc2894..94fb1d5 100644 --- a/libs/ui/Region.cpp +++ b/libs/ui/Region.cpp @@ -606,6 +606,18 @@ Rect const* Region::getArray(size_t* count) const { return b; } +SharedBuffer const* Region::getSharedBuffer(size_t* count) const { + // We can get to the SharedBuffer of a Vector<Rect> because Rect has + // a trivial destructor. + SharedBuffer const* sb = SharedBuffer::bufferFromData(mStorage.array()); + if (count) { + size_t numRects = isRect() ? 1 : mStorage.size() - 1; + count[0] = numRects; + } + sb->acquire(); + return sb; +} + // ---------------------------------------------------------------------------- void Region::dump(String8& out, const char* what, uint32_t flags) const |