summaryrefslogtreecommitdiff
path: root/libs/gui/LayerState.cpp
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2012-08-12 19:37:16 -0700
committer Mathias Agopian <mathias@google.com> 2012-08-13 02:46:05 -0700
commit8683fca395d01734ec7946e9f0595ec5d7b754c6 (patch)
treefe3f6b92245be46902760c129e395c94589b9895 /libs/gui/LayerState.cpp
parente57f292595bec48f65c8088b00ff6beea01217e9 (diff)
improve [un]marshalling of non-binder objects
this change introduces a new class LightFlattenable<> which is a protocol to flatten simple objects that don't require binders or file descriptors; the benefit of this protocol is that it doesn't require the objects to have a virtual table and give us a consitant way of doing this. we also introduce an implementation of this protocol for POD structures, LightFlattenablePod<>. Parcel has been update to handle this protocol automatically. Sensor, Rect, Point and Region now use this new protocol. Change-Id: Icb3ce7fa1d785249eb666f39c2129f2fc143ea4a
Diffstat (limited to 'libs/gui/LayerState.cpp')
-rw-r--r--libs/gui/LayerState.cpp22
1 files changed, 6 insertions, 16 deletions
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 07f62c40e8..e2604f8e20 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -26,14 +26,7 @@ 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);
+ err = output.write(transparentRegion);
if (err < NO_ERROR) return err;
// NOTE: regions are at the end of the structure
@@ -46,11 +39,8 @@ status_t layer_state_t::write(Parcel& output) const
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);
+ err = input.read(transparentRegion);
if (err < NO_ERROR) return err;
// NOTE: regions are at the end of the structure
@@ -77,8 +67,8 @@ status_t DisplayState::write(Parcel& output) const {
output.writeInt32(what);
output.writeInt32(layerStack);
output.writeInt32(orientation);
- memcpy(output.writeInplace(sizeof(Rect)), &viewport, sizeof(Rect));
- memcpy(output.writeInplace(sizeof(Rect)), &frame, sizeof(Rect));
+ output.write(viewport);
+ output.write(frame);
return NO_ERROR;
}
@@ -88,8 +78,8 @@ status_t DisplayState::read(const Parcel& input) {
what = input.readInt32();
layerStack = input.readInt32();
orientation = input.readInt32();
- memcpy(&viewport, input.readInplace(sizeof(Rect)), sizeof(Rect));
- memcpy(&frame, input.readInplace(sizeof(Rect)), sizeof(Rect));
+ input.read(viewport);
+ input.read(frame);
return NO_ERROR;
}