diff options
author | yfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-22 19:08:31 +0000 |
---|---|---|
committer | yfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-22 19:08:31 +0000 |
commit | d2e0fc204f6f5da4b7dd7887c6af7c60eec660c2 (patch) | |
tree | 887ee48af40918d7763129d1e005caa0847aafdc /ui/android/java | |
parent | ede07b9667a3f067d7146093844c13b6ecb12e57 (diff) | |
download | chromium_src-d2e0fc204f6f5da4b7dd7887c6af7c60eec660c2.zip chromium_src-d2e0fc204f6f5da4b7dd7887c6af7c60eec660c2.tar.gz chromium_src-d2e0fc204f6f5da4b7dd7887c6af7c60eec660c2.tar.bz2 |
Introduce facade for interaction with Android SurfaceTexture.
Cleans up some of the JNI and makes usage of Android APIs more explicit.
BUG=261717
TBR=apatrick
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/22912020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219061 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/android/java')
-rw-r--r-- | ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureBridge.java | 64 | ||||
-rw-r--r-- | ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java | 10 |
2 files changed, 66 insertions, 8 deletions
diff --git a/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureBridge.java b/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureBridge.java new file mode 100644 index 0000000..2333a01 --- /dev/null +++ b/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 diff --git a/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java b/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java index 8efe6dd..1b77370 100644 --- a/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java +++ b/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java @@ -6,7 +6,6 @@ package org.chromium.ui.gfx; import android.graphics.SurfaceTexture; -import org.chromium.base.CalledByNative; import org.chromium.base.JNINamespace; /** @@ -15,9 +14,9 @@ import org.chromium.base.JNINamespace; @JNINamespace("gfx") class SurfaceTextureListener implements SurfaceTexture.OnFrameAvailableListener { // Used to determine the class instance to dispatch the native call to. - private int mNativeSurfaceTextureListener = 0; + private final int mNativeSurfaceTextureListener; - private SurfaceTextureListener(int nativeSurfaceTextureListener) { + SurfaceTextureListener(int nativeSurfaceTextureListener) { assert nativeSurfaceTextureListener != 0; mNativeSurfaceTextureListener = nativeSurfaceTextureListener; } @@ -36,11 +35,6 @@ class SurfaceTextureListener implements SurfaceTexture.OnFrameAvailableListener } } - @CalledByNative - private static SurfaceTextureListener create(int nativeSurfaceTextureListener) { - return new SurfaceTextureListener(nativeSurfaceTextureListener); - } - private native void nativeFrameAvailable(int nativeSurfaceTextureListener); private native void nativeDestroy(int nativeSurfaceTextureListener); } |