summaryrefslogtreecommitdiffstats
path: root/core/jni/android_view_Surface.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-04-16 20:30:22 -0700
committerMathias Agopian <mathias@google.com>2009-04-16 20:30:22 -0700
commit69d62097e8195c947de7e4cdc4a491181aa56e61 (patch)
tree9711d12c764f5ff8bfac6fb285b41ea6c4314a8e /core/jni/android_view_Surface.cpp
parent17f638b39f2e8b610ecfa1290e5bc42ab7700c98 (diff)
downloadframeworks_base-69d62097e8195c947de7e4cdc4a491181aa56e61.zip
frameworks_base-69d62097e8195c947de7e4cdc4a491181aa56e61.tar.gz
frameworks_base-69d62097e8195c947de7e4cdc4a491181aa56e61.tar.bz2
cleanup, remove unused fields. Also make sure that we don't systematically allocate a Surface in Surface.java if only a SurfaceControl is needed (Common case).
Diffstat (limited to 'core/jni/android_view_Surface.cpp')
-rw-r--r--core/jni/android_view_Surface.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index c2eb5e8..823fafd 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -145,8 +145,27 @@ static void setSurfaceControl(JNIEnv* env, jobject clazz,
static sp<Surface> getSurface(JNIEnv* env, jobject clazz)
{
- Surface* const p = (Surface*)env->GetIntField(clazz, so.surface);
- return sp<Surface>(p);
+ sp<Surface> result((Surface*)env->GetIntField(clazz, so.surface));
+ if (result == 0) {
+ /*
+ * if this method is called from the WindowManager's process, it means
+ * the client is is not remote, and therefore is allowed to have
+ * a Surface (data), so we create it here.
+ * If we don't have a SurfaceControl, it means we're in a different
+ * process.
+ */
+
+ SurfaceControl* const control =
+ (SurfaceControl*)env->GetIntField(clazz, so.surfaceControl);
+ if (control) {
+ result = control->getSurface();
+ if (result != 0) {
+ result->incStrong(clazz);
+ env->SetIntField(clazz, so.surface, (int)result.get());
+ }
+ }
+ }
+ return result;
}
static void setSurface(JNIEnv* env, jobject clazz, const sp<Surface>& surface)
@@ -510,7 +529,6 @@ static void Surface_copyFrom(
* This is used by the WindowManagerService just after constructing
* a Surface and is necessary for returning the Surface reference to
* the caller. At this point, we should only have a SurfaceControl.
- *
*/
const sp<SurfaceControl>& surface = getSurfaceControl(env, clazz);
@@ -519,7 +537,6 @@ static void Surface_copyFrom(
// we reassign the surface only if it's a different one
// otherwise we would loose our client-side state.
setSurfaceControl(env, clazz, rhs);
- setSurface(env, clazz, rhs->getSurface());
}
}