Merge "Properly identify how much metadata we need to cache in order to instantiate" into ics-mr1
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 2b254af..edaa262 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -282,10 +282,24 @@
/**
* Copy another surface to this one. This surface now holds a reference
* to the same data as the original surface, and is -not- the owner.
+ * This is for use by the window manager when returning a window surface
+ * back from a client, converting it from the representation being managed
+ * by the window manager to the representation the client uses to draw
+ * in to it.
* @hide
*/
public native void copyFrom(Surface o);
-
+
+ /**
+ * Transfer the native state from 'o' to this surface, releasing it
+ * from 'o'. This is for use in the client side for drawing into a
+ * surface; not guaranteed to work on the window manager side.
+ * This is for use by the client to move the underlying surface from
+ * one Surface object to another, in particular in SurfaceFlinger.
+ * @hide.
+ */
+ public native void transferFrom(Surface o);
+
/** @hide */
public int getGenerationId() {
return mSurfaceGenerationId;
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 0e68490..6726c56e 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -88,8 +88,8 @@
final int[] mLocation = new int[2];
final ReentrantLock mSurfaceLock = new ReentrantLock();
- Surface mSurface = new Surface(); // Current surface in use
- Surface mNewSurface = new Surface(); // New surface we are switching to
+ final Surface mSurface = new Surface(); // Current surface in use
+ final Surface mNewSurface = new Surface(); // New surface we are switching to
boolean mDrawingStopped = true;
final WindowManager.LayoutParams mLayout
@@ -519,10 +519,7 @@
}
}
- Surface tmpSurface = mSurface;
- mSurface = mNewSurface;
- mNewSurface = tmpSurface;
- mNewSurface.release();
+ mSurface.transferFrom(mNewSurface);
if (visible) {
if (!mSurfaceCreated && (surfaceChanged || visibleChanged)) {
diff --git a/core/java/android/webkit/HTML5VideoFullScreen.java b/core/java/android/webkit/HTML5VideoFullScreen.java
index cb555ea..e1eff58 100644
--- a/core/java/android/webkit/HTML5VideoFullScreen.java
+++ b/core/java/android/webkit/HTML5VideoFullScreen.java
@@ -4,15 +4,12 @@
import android.content.Context;
import android.media.MediaPlayer;
import android.media.Metadata;
-import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
-import android.webkit.HTML5VideoView;
-import android.webkit.HTML5VideoViewProxy;
import android.widget.FrameLayout;
import android.widget.MediaController;
import android.widget.MediaController.MediaPlayerControl;
@@ -150,7 +147,7 @@
private void prepareForFullScreen() {
// So in full screen, we reset the MediaPlayer
mPlayer.reset();
- MediaController mc = new MediaController(mProxy.getContext());
+ MediaController mc = new FullScreenMediaController(mProxy.getContext(), mLayout);
mc.setSystemUiVisibility(mLayout.getSystemUiVisibility());
setMediaController(mc);
mPlayer.setScreenOnWhilePlaying(true);
@@ -261,9 +258,6 @@
mLayout.addView(getSurfaceView(), layoutParams);
mLayout.setVisibility(View.VISIBLE);
- mLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
-
WebChromeClient client = webView.getWebChromeClient();
if (client != null) {
client.onShowCustomView(mLayout, mCallback);
@@ -340,4 +334,33 @@
}
return;
}
+
+ static class FullScreenMediaController extends MediaController {
+
+ View mVideoView;
+
+ public FullScreenMediaController(Context context, View video) {
+ super(context);
+ mVideoView = video;
+ }
+
+ @Override
+ public void show() {
+ super.show();
+ if (mVideoView != null) {
+ mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
+ }
+ }
+
+ @Override
+ public void hide() {
+ if (mVideoView != null) {
+ mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
+ }
+ super.hide();
+ }
+
+ }
+
}
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index 49441eb..bba4b47 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -752,6 +752,25 @@
}
}
+static void Surface_transferFrom(
+ JNIEnv* env, jobject clazz, jobject other)
+{
+ if (clazz == other)
+ return;
+
+ if (other == NULL) {
+ doThrowNPE(env);
+ return;
+ }
+
+ sp<SurfaceControl> control(getSurfaceControl(env, other));
+ sp<Surface> surface(Surface_getSurface(env, other));
+ setSurfaceControl(env, clazz, control);
+ setSurface(env, clazz, surface);
+ setSurfaceControl(env, other, 0);
+ setSurface(env, other, 0);
+}
+
static void Surface_readFromParcel(
JNIEnv* env, jobject clazz, jobject argParcel)
{
@@ -820,6 +839,7 @@
{"destroy", "()V", (void*)Surface_destroy },
{"release", "()V", (void*)Surface_release },
{"copyFrom", "(Landroid/view/Surface;)V", (void*)Surface_copyFrom },
+ {"transferFrom", "(Landroid/view/Surface;)V", (void*)Surface_transferFrom },
{"isValid", "()Z", (void*)Surface_isValid },
{"lockCanvasNative", "(Landroid/graphics/Rect;)Landroid/graphics/Canvas;", (void*)Surface_lockCanvas },
{"unlockCanvasAndPost", "(Landroid/graphics/Canvas;)V", (void*)Surface_unlockCanvasAndPost },