summaryrefslogtreecommitdiff
path: root/chromium/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureBridge.java
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureBridge.java')
-rw-r--r--chromium/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureBridge.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/chromium/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureBridge.java b/chromium/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureBridge.java
new file mode 100644
index 00000000000..2333a01bb2f
--- /dev/null
+++ b/chromium/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureBridge.java
@@ -0,0 +1,64 @@
+// Copyright 2013 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.ui.gfx;
+
+import android.graphics.SurfaceTexture;
+import android.os.Build;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+
+/**
+ * Wrapper class for the underlying platform's SurfaceTexture in order to
+ * provide a stable JNI API.
+ */
+@JNINamespace("gfx")
+class SurfaceTextureBridge {
+ @CalledByNative
+ private static SurfaceTexture create(int textureId) {
+ return new SurfaceTexture(textureId);
+ }
+
+ @CalledByNative
+ private static void destroy(SurfaceTexture surfaceTexture) {
+ surfaceTexture.setOnFrameAvailableListener(null);
+ surfaceTexture.release();
+ }
+
+ @CalledByNative
+ private static void setFrameAvailableCallback(SurfaceTexture surfaceTexture,
+ int nativeSurfaceTextureListener) {
+ surfaceTexture.setOnFrameAvailableListener(
+ new SurfaceTextureListener(nativeSurfaceTextureListener));
+ }
+
+ @CalledByNative
+ private static void updateTexImage(SurfaceTexture surfaceTexture) {
+ surfaceTexture.updateTexImage();
+ }
+
+ @CalledByNative
+ private static void setDefaultBufferSize(SurfaceTexture surfaceTexture, int width,
+ int height) {
+ surfaceTexture.setDefaultBufferSize(width, height);
+ }
+
+ @CalledByNative
+ private static void getTransformMatrix(SurfaceTexture surfaceTexture, float[] matrix) {
+ surfaceTexture.getTransformMatrix(matrix);
+ }
+
+ @CalledByNative
+ private static void attachToGLContext(SurfaceTexture surfaceTexture, int texName) {
+ assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
+ surfaceTexture.attachToGLContext(texName);
+ }
+
+ @CalledByNative
+ private static void detachFromGLContext(SurfaceTexture surfaceTexture) {
+ assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
+ surfaceTexture.detachFromGLContext();
+ }
+} \ No newline at end of file