summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-02-17 20:22:26 -0800
committerMathias Agopian <mathias@google.com>2010-02-17 20:26:47 -0800
commite59a54c0edc65f6092a62a137226ddf540361022 (patch)
tree65e95cec486c7b5b9ce7a02819d6ec4eca6eb7a1 /libs
parent41207b6eb0524c6a2fe9e85f6373785e2937e90f (diff)
downloadframeworks_base-e59a54c0edc65f6092a62a137226ddf540361022.zip
frameworks_base-e59a54c0edc65f6092a62a137226ddf540361022.tar.gz
frameworks_base-e59a54c0edc65f6092a62a137226ddf540361022.tar.bz2
Remove a dependency of Region (libui) on Parcel (libbinder).
Diffstat (limited to 'libs')
-rw-r--r--libs/surfaceflinger_client/LayerState.cpp28
-rw-r--r--libs/ui/Region.cpp53
2 files changed, 33 insertions, 48 deletions
diff --git a/libs/surfaceflinger_client/LayerState.cpp b/libs/surfaceflinger_client/LayerState.cpp
index 114a9e9..01c4c7e 100644
--- a/libs/surfaceflinger_client/LayerState.cpp
+++ b/libs/surfaceflinger_client/LayerState.cpp
@@ -22,17 +22,37 @@ namespace android {
status_t layer_state_t::write(Parcel& output) const
{
+ status_t err;
+
+ size_t len = transparentRegion.write(NULL, 0);
+ err = output.writeInt32(len);
+ if (err < NO_ERROR) return err;
+
+ void* buf = output.writeInplace(len);
+ if (buf == NULL) return NO_MEMORY;
+
+ err = transparentRegion.write(buf, len);
+ if (err < NO_ERROR) return err;
+
+ // NOTE: regions are at the end of the structure
size_t size = sizeof(layer_state_t);
- transparentRegion.write(output);
size -= sizeof(transparentRegion);
- output.write(this, size);
- return NO_ERROR;
+ err = output.write(this, size);
+ return err;
}
status_t layer_state_t::read(const Parcel& input)
{
+ status_t err;
+ size_t len = input.readInt32();
+ void const* buf = input.readInplace(len);
+ if (buf == NULL) return NO_MEMORY;
+
+ err = transparentRegion.read(buf);
+ if (err < NO_ERROR) return err;
+
+ // NOTE: regions are at the end of the structure
size_t size = sizeof(layer_state_t);
- transparentRegion.read(input);
size -= sizeof(transparentRegion);
input.read(this, size);
return NO_ERROR;
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index d21ed57..12db908 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -63,16 +63,10 @@ Region::Region(const Rect& rhs)
{
}
-Region::Region(const Parcel& parcel)
-{
- status_t err = read(parcel);
- LOGE_IF(err<0, "error %s reading Region from parcel", strerror(err));
-}
-
Region::Region(const void* buffer)
{
status_t err = read(buffer);
- LOGE_IF(err<0, "error %s reading Region from parcel", strerror(err));
+ LOGE_IF(err<0, "error %s reading Region from buffer", strerror(err));
}
Region::~Region()
@@ -532,37 +526,6 @@ void Region::translate(Region& dst, const Region& reg, int dx, int dy)
// ----------------------------------------------------------------------------
-status_t Region::write(Parcel& parcel) const
-{
-#if VALIDATE_REGIONS
- validate(*this, "write(Parcel)");
-#endif
- status_t err;
- const size_t count = mStorage.size();
- const size_t sizeNeeded = sizeof(int32_t) + (1+count)*sizeof(Rect);
- void* buffer = parcel.writeInplace(sizeNeeded);
- if (!buffer) return NO_MEMORY;
- ssize_t written = Region::write(buffer, sizeNeeded);
- if (written < 0) return status_t(written);
- return NO_ERROR;
-}
-
-status_t Region::read(const Parcel& parcel)
-{
- void const* buffer = parcel.readInplace(sizeof(int32_t));
- if (!buffer) return NO_MEMORY;
- const size_t count = *static_cast<int32_t const *>(buffer);
- void const* dummy = parcel.readInplace((1+count)*sizeof(Rect));
- if (!dummy) return NO_MEMORY;
- const size_t sizeNeeded = sizeof(int32_t) + (1+count)*sizeof(Rect);
- const ssize_t read = Region::read(buffer);
- if (read < 0) return status_t(read);
-#if VALIDATE_REGIONS
- validate(*this, "read(Parcel)");
-#endif
- return NO_ERROR;
-}
-
ssize_t Region::write(void* buffer, size_t size) const
{
#if VALIDATE_REGIONS
@@ -570,12 +533,14 @@ ssize_t Region::write(void* buffer, size_t size) const
#endif
const size_t count = mStorage.size();
const size_t sizeNeeded = sizeof(int32_t) + (1+count)*sizeof(Rect);
- if (sizeNeeded > size) return NO_MEMORY;
- int32_t* const p = static_cast<int32_t*>(buffer);
- *p = count;
- memcpy(p+1, &mBounds, sizeof(Rect));
- if (count) {
- memcpy(p+5, mStorage.array(), count*sizeof(Rect));
+ if (buffer != NULL) {
+ if (sizeNeeded > size) return NO_MEMORY;
+ int32_t* const p = static_cast<int32_t*>(buffer);
+ *p = count;
+ memcpy(p+1, &mBounds, sizeof(Rect));
+ if (count) {
+ memcpy(p+5, mStorage.array(), count*sizeof(Rect));
+ }
}
return ssize_t(sizeNeeded);
}