summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-06-04 18:26:32 -0700
committerMathias Agopian <mathias@google.com>2010-06-04 18:57:41 -0700
commitfae5cb2b356a1fef172b43066180a7ab4c32dbac (patch)
tree55e73b81c3a666ab1165603238e7ca43495ff99c /libs
parent7623da435e45c7c03ef6a00a43675deb6645f070 (diff)
downloadframeworks_base-fae5cb2b356a1fef172b43066180a7ab4c32dbac.zip
frameworks_base-fae5cb2b356a1fef172b43066180a7ab4c32dbac.tar.gz
frameworks_base-fae5cb2b356a1fef172b43066180a7ab4c32dbac.tar.bz2
optimize Surface.readFromParcel()
this is called for each relayout() and used to create a full Surface (cpp) which in turn did some heavy work (including an IPC with surfaceflinger), most of the time to destroy it immediatelly when the returned surface (the one in the parcel) was the same. we now more intelligentely read from the parcel and construct the new object only if needed. Change-Id: Idfd40d9ac96ffc6d4ae5fd99bcc0773e131e2267
Diffstat (limited to 'libs')
-rw-r--r--libs/surfaceflinger_client/Surface.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp
index 01420fe..6fe4c4a 100644
--- a/libs/surfaceflinger_client/Surface.cpp
+++ b/libs/surfaceflinger_client/Surface.cpp
@@ -334,13 +334,13 @@ Surface::Surface(const sp<SurfaceControl>& surface)
init();
}
-Surface::Surface(const Parcel& parcel)
+Surface::Surface(const Parcel& parcel, const sp<IBinder>& ref)
: mBufferMapper(GraphicBufferMapper::get()),
mClient(SurfaceClient::getInstance()),
mSharedBufferClient(NULL),
mInitCheck(NO_INIT)
{
- mSurface = interface_cast<ISurface>(parcel.readStrongBinder());
+ mSurface = interface_cast<ISurface>(ref);
mIdentity = parcel.readInt32();
mWidth = parcel.readInt32();
mHeight = parcel.readInt32();
@@ -349,6 +349,17 @@ Surface::Surface(const Parcel& parcel)
init();
}
+sp<Surface> Surface::readFromParcel(
+ const Parcel& data, const sp<Surface>& other)
+{
+ sp<Surface> result(other);
+ sp<IBinder> binder(data.readStrongBinder());
+ if (other==0 || binder != other->mSurface->asBinder()) {
+ result = new Surface(data, binder);
+ }
+ return result;
+}
+
void Surface::init()
{
android_native_window_t::setSwapInterval = setSwapInterval;
@@ -443,12 +454,6 @@ status_t Surface::validate() const
return NO_ERROR;
}
-bool Surface::isSameSurface(const sp<Surface>& lhs, const sp<Surface>& rhs) {
- if (lhs == 0 || rhs == 0)
- return false;
- return lhs->mSurface->asBinder() == rhs->mSurface->asBinder();
-}
-
sp<ISurface> Surface::getISurface() const {
return mSurface;
}