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

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

Issue 2252103002: Introduce ChromeVR to Chrome on Android (behind a build flag) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/TextureHelper.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/TextureHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/TextureHelper.java
new file mode 100644
index 0000000000000000000000000000000000000000..63bcf4c3806ce61325e355ee1510e182199c2b87
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/TextureHelper.java
@@ -0,0 +1,36 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.vr_shell;
+
+import static android.opengl.GLES20.GL_NEAREST;
+import static android.opengl.GLES20.GL_TEXTURE_MAG_FILTER;
+import static android.opengl.GLES20.GL_TEXTURE_MIN_FILTER;
+import static android.opengl.GLES20.glBindTexture;
+import static android.opengl.GLES20.glGenTextures;
+import static android.opengl.GLES20.glTexParameteri;
+
+import android.opengl.GLES11Ext;
+
+/**
+ * Helper class for working with OpenGL textures.
+ */
+public class TextureHelper {
+ /**
+ * Create a new GLES11Ext.GL_TEXTURE_EXTERNAL_OES texture handle.
+ * @return New texture handle.
+ */
+ public static int createExternalTextureHandle() {
+ int[] textureDataHandle = new int[1];
+ glGenTextures(1, textureDataHandle, 0);
+ if (textureDataHandle[0] != 0) {
+ glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureDataHandle[0]);
+ glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ return textureDataHandle[0];
+ } else {
+ throw new RuntimeException("Error generating texture handle.");
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698