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

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

Issue 2343023002: Switch WebVR to handle GvrApi management through VrShellDelegate (Closed)
Patch Set: Rebase Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.vr_shell; 5 package org.chromium.chrome.browser.vr_shell;
6 6
7 import static android.opengl.GLES20.GL_NEAREST; 7 import static android.opengl.GLES20.GL_NEAREST;
8 import static android.opengl.GLES20.GL_TEXTURE_MAG_FILTER; 8 import static android.opengl.GLES20.GL_TEXTURE_MAG_FILTER;
9 import static android.opengl.GLES20.GL_TEXTURE_MIN_FILTER; 9 import static android.opengl.GLES20.GL_TEXTURE_MIN_FILTER;
10 import static android.opengl.GLES20.glBindTexture; 10 import static android.opengl.GLES20.glBindTexture;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 mGlSurfaceView.setPreserveEGLContextOnPause(true); 55 mGlSurfaceView.setPreserveEGLContextOnPause(true);
56 mGlSurfaceView.setRenderer(this); 56 mGlSurfaceView.setRenderer(this);
57 setPresentationView(mGlSurfaceView); 57 setPresentationView(mGlSurfaceView);
58 58
59 if (setAsyncReprojectionEnabled(true)) { 59 if (setAsyncReprojectionEnabled(true)) {
60 AndroidCompat.setSustainedPerformanceMode(mActivity, true); 60 AndroidCompat.setSustainedPerformanceMode(mActivity, true);
61 } 61 }
62 } 62 }
63 63
64 @Override 64 @Override
65 public void onNativeLibraryReady() { 65 public void onNativeLibraryReady(long nativeDelegate) {
Ted C 2016/09/20 20:31:11 try not to pass around raw pointers in java. inst
66 mNativeVrShell = nativeInit(); 66 mNativeVrShell = nativeInit();
67 nativeSetDelegate(mNativeVrShell, nativeDelegate);
67 } 68 }
68 69
69 private static class FrameListener implements OnFrameAvailableListener { 70 private static class FrameListener implements OnFrameAvailableListener {
70 final SurfaceTexture mSurfaceTexture; 71 final SurfaceTexture mSurfaceTexture;
71 final GLSurfaceView mGlSurfaceView; 72 final GLSurfaceView mGlSurfaceView;
72 boolean mFirstTex = true; 73 boolean mFirstTex = true;
73 74
74 final Runnable mUpdateTexImage = new Runnable() { 75 final Runnable mUpdateTexImage = new Runnable() {
75 @Override 76 @Override
76 public void run() { 77 public void run() {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 public void teardown() { 169 public void teardown() {
169 shutdown(); 170 shutdown();
170 } 171 }
171 172
172 @Override 173 @Override
173 public void setVrModeEnabled(boolean enabled) { 174 public void setVrModeEnabled(boolean enabled) {
174 AndroidCompat.setVrModeEnabled(mActivity, enabled); 175 AndroidCompat.setVrModeEnabled(mActivity, enabled);
175 } 176 }
176 177
177 @Override 178 @Override
179 public void setWebVrModeEnabled(boolean enabled) {
180 nativeSetWebVrMode(mNativeVrShell, enabled);
181 }
182
183 @Override
178 public boolean onTouchEvent(MotionEvent event) { 184 public boolean onTouchEvent(MotionEvent event) {
179 return true; 185 return true;
180 } 186 }
181 187
182 @Override 188 @Override
183 public FrameLayout getContainer() { 189 public FrameLayout getContainer() {
184 return (FrameLayout) this; 190 return (FrameLayout) this;
185 } 191 }
186 192
187 /** 193 /**
188 * Create a new GLES11Ext.GL_TEXTURE_EXTERNAL_OES texture handle. 194 * Create a new GLES11Ext.GL_TEXTURE_EXTERNAL_OES texture handle.
189 * @return New texture handle. 195 * @return New texture handle.
190 */ 196 */
191 private int createExternalTextureHandle() { 197 private int createExternalTextureHandle() {
192 int[] textureDataHandle = new int[1]; 198 int[] textureDataHandle = new int[1];
193 glGenTextures(1, textureDataHandle, 0); 199 glGenTextures(1, textureDataHandle, 0);
194 if (textureDataHandle[0] != 0) { 200 if (textureDataHandle[0] != 0) {
195 glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureDataHandle[0 ]); 201 glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureDataHandle[0 ]);
196 glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FI LTER, GL_NEAREST); 202 glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FI LTER, GL_NEAREST);
197 glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FI LTER, GL_NEAREST); 203 glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FI LTER, GL_NEAREST);
198 return textureDataHandle[0]; 204 return textureDataHandle[0];
199 } else { 205 } else {
200 throw new RuntimeException("Error generating texture handle."); 206 throw new RuntimeException("Error generating texture handle.");
201 } 207 }
202 } 208 }
203 209
204 private native long nativeInit(); 210 private native long nativeInit();
205 211
Ted C 2016/09/20 20:31:11 fwiw, we usually don't add spaces between our nati
212 private native void nativeSetDelegate(long nativeVrShell, long nativeVrShell Delegate);
213
206 private native void nativeGvrInit(long nativeVrShell, long nativeGvrApi); 214 private native void nativeGvrInit(long nativeVrShell, long nativeGvrApi);
207 215
208 private native void nativeDestroy(long nativeVrShell); 216 private native void nativeDestroy(long nativeVrShell);
209 217
210 private native void nativeInitializeGl( 218 private native void nativeInitializeGl(
211 long nativeVrShell, int contentDataHandle); 219 long nativeVrShell, int contentDataHandle);
212 220
213 private native void nativeDrawFrame(long nativeVrShell); 221 private native void nativeDrawFrame(long nativeVrShell);
214 222
215 private native void nativeOnPause(long nativeVrShell); 223 private native void nativeOnPause(long nativeVrShell);
216 224
217 private native void nativeOnResume(long nativeVrShell); 225 private native void nativeOnResume(long nativeVrShell);
226
227 private native void nativeSetWebVrMode(long nativeVrShell, boolean enabled);
218 } 228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698