Loading include/ui/Region.h +14 −6 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ namespace android { namespace android { // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- class SharedBuffer; class String8; class String8; // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- Loading Loading @@ -107,15 +108,22 @@ public: /* various ways to access the rectangle list */ /* various ways to access the rectangle list */ typedef Rect const* const_iterator; // STL-like iterators typedef Rect const* const_iterator; const_iterator begin() const; const_iterator begin() const; const_iterator end() const; const_iterator end() const; /* no user serviceable parts here... */ // returns an array of rect which has the same life-time has this // Region object. Rect const* getArray(size_t* count) const; 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 // add a rectangle to the internal list. This rectangle must // be sorted in Y and X and must not make the region invalid. // be sorted in Y and X and must not make the region invalid. Loading include/utils/SharedBuffer.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -96,7 +96,7 @@ private: inline ~SharedBuffer() { } inline ~SharedBuffer() { } inline SharedBuffer(const SharedBuffer&); inline SharedBuffer(const SharedBuffer&); // 16 bytes. must be sized to preserve correct alingment. // 16 bytes. must be sized to preserve correct alignment. mutable int32_t mRefs; mutable int32_t mRefs; size_t mSize; size_t mSize; uint32_t mReserved[2]; uint32_t mReserved[2]; Loading libs/ui/Region.cpp +12 −0 Original line number Original line Diff line number Diff line Loading @@ -606,6 +606,18 @@ Rect const* Region::getArray(size_t* count) const { return b; 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 void Region::dump(String8& out, const char* what, uint32_t flags) const Loading Loading
include/ui/Region.h +14 −6 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ namespace android { namespace android { // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- class SharedBuffer; class String8; class String8; // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- Loading Loading @@ -107,15 +108,22 @@ public: /* various ways to access the rectangle list */ /* various ways to access the rectangle list */ typedef Rect const* const_iterator; // STL-like iterators typedef Rect const* const_iterator; const_iterator begin() const; const_iterator begin() const; const_iterator end() const; const_iterator end() const; /* no user serviceable parts here... */ // returns an array of rect which has the same life-time has this // Region object. Rect const* getArray(size_t* count) const; 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 // add a rectangle to the internal list. This rectangle must // be sorted in Y and X and must not make the region invalid. // be sorted in Y and X and must not make the region invalid. Loading
include/utils/SharedBuffer.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -96,7 +96,7 @@ private: inline ~SharedBuffer() { } inline ~SharedBuffer() { } inline SharedBuffer(const SharedBuffer&); inline SharedBuffer(const SharedBuffer&); // 16 bytes. must be sized to preserve correct alingment. // 16 bytes. must be sized to preserve correct alignment. mutable int32_t mRefs; mutable int32_t mRefs; size_t mSize; size_t mSize; uint32_t mReserved[2]; uint32_t mReserved[2]; Loading
libs/ui/Region.cpp +12 −0 Original line number Original line Diff line number Diff line Loading @@ -606,6 +606,18 @@ Rect const* Region::getArray(size_t* count) const { return b; 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 void Region::dump(String8& out, const char* what, uint32_t flags) const Loading