summaryrefslogtreecommitdiff
path: root/libs/ui/Region.cpp
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2013-07-29 21:24:40 -0700
committer Mathias Agopian <mathias@google.com> 2013-07-30 21:19:13 -0700
commite142428a9c8b9d2380032cd4d7b55ee440fe8770 (patch)
tree7c55a190ef023bc7aba348d040211901448c13d3 /libs/ui/Region.cpp
parent1d76781b7aa19611c4045fdf6b848af6c6094e0b (diff)
Make Flattenable not virtual
Fallout from the Flattenable change, update all its uses. Additionnaly, fix/tighten size checks when (un)flatten()ing things. Removed the assumption by some flattenables (e.g.: Fence) that the size passed to them would be exact (it can and will be larger in some cases) The code in Parcel is a bit complicated so that we don't have to expose the full implementation (and also to keep the code smallish). Change-Id: I0bf1c8aca2a3128491b4f45510bc46667e566dde
Diffstat (limited to 'libs/ui/Region.cpp')
-rw-r--r--libs/ui/Region.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index 623f8edacd..e5abcf5c84 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -715,14 +715,17 @@ void Region::translate(Region& dst, const Region& reg, int dx, int dy)
// ----------------------------------------------------------------------------
-size_t Region::getSize() const {
+size_t Region::getFlattenedSize() const {
return mStorage.size() * sizeof(Rect);
}
-status_t Region::flatten(void* buffer) const {
+status_t Region::flatten(void* buffer, size_t size) const {
#if VALIDATE_REGIONS
validate(*this, "Region::flatten");
#endif
+ if (size < mStorage.size() * sizeof(Rect)) {
+ return NO_MEMORY;
+ }
Rect* rects = reinterpret_cast<Rect*>(buffer);
memcpy(rects, mStorage.array(), mStorage.size() * sizeof(Rect));
return NO_ERROR;