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

Unified Diff: remoting/android/java/src/org/chromium/chromoting/cardboard/ShaderHelper.java

Issue 2252123002: [Remoting Android] Remove Cardboard Code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback - Removed unused const and strings 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: remoting/android/java/src/org/chromium/chromoting/cardboard/ShaderHelper.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/cardboard/ShaderHelper.java b/remoting/android/java/src/org/chromium/chromoting/cardboard/ShaderHelper.java
deleted file mode 100644
index bc82c3c6af7f04ff3269ad2b074b420f9e422a0f..0000000000000000000000000000000000000000
--- a/remoting/android/java/src/org/chromium/chromoting/cardboard/ShaderHelper.java
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2015 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.chromoting.cardboard;
-
-import android.opengl.GLES20;
-
-import org.chromium.base.Log;
-
-/**
- * Helper class for working with OpenGL shaders and programs.
- */
-public class ShaderHelper {
- private static final String TAG = "Cardboard";
-
- /**
- * Compile a shader.
- *
- * @param shaderType The shader type.
- * @param shaderSource The shader source code.
- * @return An OpenGL handle to the shader.
- */
- public static int compileShader(int shaderType, String shaderSource) {
- int shaderHandle = GLES20.glCreateShader(shaderType);
-
- if (shaderHandle != 0) {
- // Pass in the shader source.
- GLES20.glShaderSource(shaderHandle, shaderSource);
-
- // Compile the shader.
- GLES20.glCompileShader(shaderHandle);
-
- // Get the compilation status.
- int[] compileStatus = new int[1];
- GLES20.glGetShaderiv(shaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
-
- // If the compilation failed, delete the shader.
- if (compileStatus[0] == 0) {
- Log.e(TAG, "Error compiling shader: %s", GLES20.glGetShaderInfoLog(shaderHandle));
- GLES20.glDeleteShader(shaderHandle);
- shaderHandle = 0;
- }
- }
-
- if (shaderHandle == 0) {
- // TODO(shichengfeng): Handle Exception gracefully.
- throw new RuntimeException("Error creating shader.");
- }
-
- return shaderHandle;
- }
-
- /**
- * Compile and link a program.
- *
- * @param vertexShaderHandle An OpenGL handle to an already-compiled vertex shader.
- * @param fragmentShaderHandle An OpenGL handle to an already-compiled fragment shader.
- * @param attributes Attributes that need to be bound to the program.
- * @return An OpenGL handle to the program.
- */
- public static int createAndLinkProgram(int vertexShaderHandle,
- int fragmentShaderHandle, String[] attributes) {
- int programHandle = GLES20.glCreateProgram();
-
- if (programHandle != 0) {
- // Bind the vertex shader to the program.
- GLES20.glAttachShader(programHandle, vertexShaderHandle);
-
- // Bind the fragment shader to the program.
- GLES20.glAttachShader(programHandle, fragmentShaderHandle);
-
- // Bind attributes
- if (attributes != null) {
- int size = attributes.length;
- for (int i = 0; i < size; i++) {
- GLES20.glBindAttribLocation(programHandle, i, attributes[i]);
- }
- }
-
- // Link the two shaders together into a program.
- GLES20.glLinkProgram(programHandle);
-
- // Get the link status.
- int[] linkStatus = new int[1];
- GLES20.glGetProgramiv(programHandle, GLES20.GL_LINK_STATUS, linkStatus, 0);
-
- // If the link failed, delete the program.
- if (linkStatus[0] == 0) {
- Log.e(TAG, "Error compiling program: %s",
- GLES20.glGetProgramInfoLog(programHandle));
- GLES20.glDeleteProgram(programHandle);
- programHandle = 0;
- }
- }
-
- if (programHandle == 0) {
- // TODO(shichengfeng): Handle Exception gracefully.
- throw new RuntimeException("Error creating program.");
- }
-
- return programHandle;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698