| Index: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
|
| index 47d59652794c7580512ef3572ba321554d334c34..990d455e3cd4448fe3d5aecb7b15fb45d465f1ff 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
|
| @@ -7,6 +7,8 @@ package org.chromium.chrome.browser.vr_shell;
|
| import android.annotation.SuppressLint;
|
| import android.app.Activity;
|
| import android.graphics.Point;
|
| +import android.os.Handler;
|
| +import android.os.Looper;
|
| import android.os.StrictMode;
|
| import android.view.MotionEvent;
|
| import android.view.Surface;
|
| @@ -76,6 +78,8 @@ public class VrShellImpl extends GvrLayout implements VrShell, SurfaceHolder.Cal
|
| private WindowAndroid mOriginalWindowAndroid;
|
| private VrWindowAndroid mContentVrWindowAndroid;
|
|
|
| + private Surface mExternalVideoSurface;
|
| +
|
| private WebContents mUiContents;
|
| private ContentViewCore mUiCVC;
|
| private VrWindowAndroid mUiVrWindowAndroid;
|
| @@ -93,6 +97,35 @@ public class VrShellImpl extends GvrLayout implements VrShell, SurfaceHolder.Cal
|
| };
|
| addView(mUiCVCContainer, 0, new FrameLayout.LayoutParams(0, 0));
|
|
|
| + ExternalSurfaceListener videoSurfaceListener =
|
| + new ExternalSurfaceListener() {
|
| + @Override
|
| + public void onSurfaceAvailable(Surface surface) {
|
| + // This should be called after onResume if we were paused.
|
| +
|
| + // Hold onto this surface until full screen is initiated.
|
| + mExternalVideoSurface = surface;
|
| +
|
| + // If we are waiting for a surface somehow (maybe if we full screen right as
|
| + // we start and the surface hasn't come back yet) then we should have some
|
| + // kind of resolver to send this surface down to the web media player as
|
| + // soon as possible.
|
| + }
|
| +
|
| + @Override
|
| + public void onFrameAvailable() {
|
| + // Do something here?
|
| + }
|
| + };
|
| +
|
| + // We must set the reprojection surface before enabling async reprojection.
|
| + // TODO(amp): Check the return value of this and don't return a surface id to the renderer
|
| + // if it didn't work.
|
| + enableAsyncReprojectionVideoSurface(
|
| + videoSurfaceListener,
|
| + new Handler(Looper.getMainLooper()),
|
| + true /* useProtectedBuffers */);
|
| +
|
| mReprojectedRendering = setAsyncReprojectionEnabled(true);
|
| if (mReprojectedRendering) {
|
| // No need render to a Surface if we're reprojected. We'll be rendering with surfaceless
|
| @@ -208,6 +241,50 @@ public class VrShellImpl extends GvrLayout implements VrShell, SurfaceHolder.Cal
|
| return cvc.getWindowAndroid().getViewRoot();
|
| }
|
|
|
| + @CalledByNative
|
| + public void createVideoSurface() {
|
| + // Send the previously created surface back down to the renderer.
|
| + // TODO(amp): Check that the surface was actually created succesfully.
|
| + VrShellImpl.this.nativeSetVideoSurface(mNativeVrShell, mExternalVideoSurface);
|
| +
|
| + // Call into native code to configure the viewports?
|
| + // tell it to use the external surface and hide the content quad
|
| + // might need to pass in the surfaceId need for native variant of this call:
|
| + // videoViewport.setExternalSurfaceId(gvrLayout.getAsyncReprojectionVideoSurfaceId());
|
| +
|
| +
|
| +
|
| + // now we can configure the viewports referencing the external surface id
|
| +
|
| + // Should this be on the native side (ie nativeDrawFrameOnGL)?
|
| +
|
| + // The source UV coords of the video viewport should be the entire video frame.
|
| + //RectF videoUv = new RectF(/*left*/ 0.f, /*top*/ 1.f, /*right*/ 1.f, /*bottom*/ 0.f);
|
| +
|
| + /*
|
| + configureViewports() = {
|
| + viewportList = gvrApi.createBufferViewportList();
|
| + recommendedViewportList = gvrApi.createBufferViewportList();
|
| + BufferViewport videoViewport = gvrApi.createBufferViewport();
|
| +
|
| + // ... other configuring ...
|
| + gvrApi.getRecommendedBufferViewports(recommendedViewportList);
|
| + // Set up the video viewports.
|
| + for (int eye = 0; eye < 2; eye++) {
|
| + recommendedViewportList.get(eye, videoViewport);
|
| + videoViewport.setSourceBufferIndex(GvrApi.BUFFER_INDEX_EXTERNAL_SURFACE);
|
| + // This pulls the surface id that should have been created when the listener was
|
| + // created. It should have called back into native with this id.
|
| + videoViewport.setExternalSurfaceId(gvrLayout.getAsyncReprojectionVideoSurfaceId());
|
| + videoViewport.setTransform(videoTransform);
|
| + videoViewport.setSourceUv(videoUv);
|
| + viewportList.set(eye, videoViewport);
|
| + }
|
| + }
|
| +
|
| + */
|
| + }
|
| +
|
| @Override
|
| public boolean dispatchTouchEvent(MotionEvent event) {
|
| // Normally, touch event is dispatched to presentation view only if the phone is paired with
|
| @@ -238,6 +315,9 @@ public class VrShellImpl extends GvrLayout implements VrShell, SurfaceHolder.Cal
|
| @Override
|
| public void onPause() {
|
| super.onPause();
|
| + // Drop the external video surface as it is no longer valid.
|
| + // TODO(amp): Should this be in shutdown instead? And is there a 'destroy' call to use?
|
| + mExternalVideoSurface = null;
|
| if (mNativeVrShell != 0) {
|
| nativeOnPause(mNativeVrShell);
|
| }
|
| @@ -325,4 +405,5 @@ public class VrShellImpl extends GvrLayout implements VrShell, SurfaceHolder.Cal
|
| private native void nativeUIPhysicalBoundsChanged(long nativeVrShell, int width, int height,
|
| float dpr);
|
| private native void nativeSetWebVrMode(long nativeVrShell, boolean enabled);
|
| + private native void nativeSetVideoSurface(long nativeVrShell, Surface surface);
|
| }
|
|
|