Re-use existing Surface objects when reading them from parcels.

This change adds a process-global cache of previously deserialized Surface
objects so that if a Surface object wrapping the same ISurface gets received
again the same Surface can be used.  This is important because the 'tail'
pointer in the SharedBufferClient is stored only on the client side, and needs
to be the same for all the Surface objects wrapping an ISurface instance.  This
solves the problem by making there only be one Surface object wrapping an
ISurface per process.

Change-Id: I4bf0b8787885c56277622fca053022d2bb638902
This commit is contained in:
Jamie Gennis
2010-07-15 17:29:15 -07:00
parent eec69d2923
commit 5ee65f0d44
3 changed files with 38 additions and 13 deletions

View File

@@ -237,7 +237,7 @@ static void Surface_initParcel(JNIEnv* env, jobject clazz, jobject argParcel)
return;
}
sp<Surface> sur(Surface::readFromParcel(*parcel, 0));
sp<Surface> sur(Surface::readFromParcel(*parcel));
setSurface(env, clazz, sur);
}
@@ -616,8 +616,7 @@ static void Surface_readFromParcel(
return;
}
const sp<Surface>& curr(getSurface(env, clazz));
sp<Surface> sur(Surface::readFromParcel(*parcel, curr));
sp<Surface> sur(Surface::readFromParcel(*parcel));
setSurface(env, clazz, sur);
}
@@ -729,4 +728,3 @@ int register_android_view_Surface(JNIEnv* env)
}
};