Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShell.java

Issue 2299613003: New Compositor and tab content
Patch Set: more clean up Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java ('k') | chrome/android/java_sources.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShell.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShell.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShell.java
index 6c4b688ad4e7c7059a26103ccd6224bdfc41e3b2..74752b9204fcb73d342e6021cd42be21719bfe2c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShell.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShell.java
@@ -12,20 +12,35 @@ import static android.opengl.GLES20.glGenTextures;
import static android.opengl.GLES20.glTexParameteri;
import android.app.Activity;
+import android.graphics.PixelFormat;
import android.graphics.SurfaceTexture;
import android.graphics.SurfaceTexture.OnFrameAvailableListener;
import android.opengl.GLES11Ext;
import android.opengl.GLSurfaceView;
import android.view.MotionEvent;
+import android.view.Surface;
import com.google.vr.ndk.base.AndroidCompat;
import com.google.vr.ndk.base.GvrLayout;
+import org.chromium.base.Log;
import org.chromium.base.annotations.JNINamespace;
+import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
+import org.chromium.ui.base.WindowAndroid;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
+import java.util.ArrayList;
+import java.util.List;
+import org.chromium.content.browser.ContentViewClient;
+import org.chromium.content.browser.ContentViewCore;
+import org.chromium.chrome.browser.tab.Tab;
+import org.chromium.chrome.browser.tabmodel.TabModelSelector;
+import org.chromium.content_public.browser.WebContents;
+
+import android.os.Handler;
+import android.os.Looper;
/**
* This view extends from GvrLayout which wraps a GLSurfaceView that renders VR shell.
*/
@@ -35,7 +50,13 @@ public class VrShell extends GvrLayout implements GLSurfaceView.Renderer, OnFram
private GLSurfaceView mGlSurfaceView;
+ private static List<ContentViewCore> sCachedCVCList = new ArrayList<ContentViewCore>();
+
private SurfaceTexture mSurfaceTexture;
+ private Surface mSurface;
+
+ private int mWidth = 0;
+ private int mHeight = 0;
private long mNativeVrShell = 0;
@@ -44,8 +65,9 @@ public class VrShell extends GvrLayout implements GLSurfaceView.Renderer, OnFram
mActivity = activity;
}
- public void onNativeLibraryReady() {
- mNativeVrShell = nativeInit();
+ public void onNativeLibraryReady(WindowAndroid windowAndroid) {
+ // lowMemDevice should be false
+ mNativeVrShell = nativeInit(false, windowAndroid.getNativePointer());
mGlSurfaceView = new GLSurfaceView(getContext());
mGlSurfaceView.setEGLContextClientVersion(2);
mGlSurfaceView.setEGLConfigChooser(8, 8, 8, 0, 0, 0);
@@ -58,12 +80,26 @@ public class VrShell extends GvrLayout implements GLSurfaceView.Renderer, OnFram
}
}
+ public void onWebContentsReady(WebContents webContents) {
+ Log.e("bshe", "Web contents ready" + webContents.getUrl());
+ // sCachedCVCList.clear();
+ // mTabModelSelector.getCurrentTab().getAllContentViewCores(sCachedCVCList);
+ // for (int i = 0; i < sCachedCVCList.size(); i++) {
+ // adjustPhysicalBackingSize(sCachedCVCList.get(i), width, height);
+ //}
+ // sCachedCVCList.clear();
+ Log.e("bshe", "width and height" + mWidth + " " + mHeight);
+ adjustPhysicalBackingSize(ContentViewCore.fromWebContents(webContents), mWidth, mHeight);
+ nativeOnWebContentsReady(mNativeVrShell, webContents);
+ }
+
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
mGlSurfaceView.queueEvent(new Runnable() {
@Override
public void run() {
try {
+ Log.e("bshe", "Frame available");
mSurfaceTexture.updateTexImage();
} catch (IllegalStateException e) {
}
@@ -79,14 +115,50 @@ public class VrShell extends GvrLayout implements GLSurfaceView.Renderer, OnFram
int textureDataHandle = createExternalTextureHandle();
mSurfaceTexture = new SurfaceTexture(textureDataHandle);
mSurfaceTexture.setOnFrameAvailableListener(this);
- // TODO(bshe): Use this SurfaceTexture to create a Surface and then pass the Surface to a
- // compositor to get frames of web page.
+ mSurface = new Surface(mSurfaceTexture);
+ mSurfaceTexture.setDefaultBufferSize(196, 95);
+ Log.e("bshe", "surface created");
+ new Handler(Looper.getMainLooper()).post(new Runnable() {
+ @Override
+ public void run() {
+ nativeSurfaceCreated(mNativeVrShell);
+ }
+ });
nativeGvrInit(mNativeVrShell, getGvrApi().getNativeGvrContext());
nativeInitializeGl(mNativeVrShell, textureDataHandle);
}
@Override
- public void onSurfaceChanged(GL10 gl, int width, int height) {}
+ public void onSurfaceChanged(GL10 gl, int width, int height) {
+ // final int format = PixelFormat.RGBA_8888;
+ final int format = 4;
+ mWidth = width;
+ mHeight = height;
+ final int f_width = width;
+ final int f_height = height;
+ new Handler(Looper.getMainLooper()).post(new Runnable() {
+ @Override
+ public void run() {
+ nativeSurfaceChanged(mNativeVrShell, format, f_width, f_height, mSurface);
+ }
+ });
+ }
+
+ private void adjustPhysicalBackingSize(ContentViewCore contentViewCore, int width, int height) {
+ ContentViewClient client = contentViewCore.getContentViewClient();
+
+ int desiredWidthMeasureSpec = client.getDesiredWidthMeasureSpec();
+ if (MeasureSpec.getMode(desiredWidthMeasureSpec) != MeasureSpec.UNSPECIFIED) {
+ width = MeasureSpec.getSize(desiredWidthMeasureSpec);
+ }
+
+ int desiredHeightMeasureSpec = client.getDesiredHeightMeasureSpec();
+ if (MeasureSpec.getMode(desiredHeightMeasureSpec) != MeasureSpec.UNSPECIFIED) {
+ height = MeasureSpec.getSize(desiredHeightMeasureSpec);
+ }
+
+ contentViewCore.onPhysicalBackingSizeChanged(width, height);
+ }
@Override
public boolean onTouchEvent(MotionEvent event) {
@@ -143,17 +215,17 @@ public class VrShell extends GvrLayout implements GLSurfaceView.Renderer, OnFram
}
}
- private native long nativeInit();
-
+ private native long nativeInit(boolean lowMemDevice, long nativeWindowAndroid);
+ private native void nativeOnWebContentsReady(long nativeVrShell, WebContents webContents);
private native void nativeGvrInit(long nativeVrShell, long nativeGvrApi);
-
private native void nativeDestroy(long nativeVrShell);
-
private native void nativeInitializeGl(long nativeVrShell, int textureDataHandle);
-
private native void nativeDrawFrame(long nativeVrShell);
-
private native void nativeOnPause(long nativeVrShell);
-
private native void nativeOnResume(long nativeVrShell);
+ private native void nativeSurfaceCreated(long nativeVrShell);
+ private native void nativeSurfaceDestroyed(long nativeVrShell);
+ private native void nativeSurfaceChanged(
+ long nativeVrShell, int format, int width, int height, Surface surface);
+ private native void nativeSetNeedsComposite(long nativeVrShell);
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java ('k') | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698