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
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index 623f8ed..e5abcf5 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -715,14 +715,17 @@
 
 // ----------------------------------------------------------------------------
 
-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;