| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.ui.gl; | 5 package org.chromium.ui.gl; |
| 6 | 6 |
| 7 import android.graphics.SurfaceTexture; | 7 import android.graphics.SurfaceTexture; |
| 8 | 8 |
| 9 import org.chromium.base.annotations.JNINamespace; | 9 import org.chromium.base.annotations.JNINamespace; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Listener to an android SurfaceTexture object for frame availability. | 12 * Listener to an android SurfaceTexture object for frame availability. |
| 13 */ | 13 */ |
| 14 @JNINamespace("gfx") | 14 @JNINamespace("gl") |
| 15 class SurfaceTextureListener implements SurfaceTexture.OnFrameAvailableListener
{ | 15 class SurfaceTextureListener implements SurfaceTexture.OnFrameAvailableListener
{ |
| 16 // Used to determine the class instance to dispatch the native call to. | 16 // Used to determine the class instance to dispatch the native call to. |
| 17 private final long mNativeSurfaceTextureListener; | 17 private final long mNativeSurfaceTextureListener; |
| 18 | 18 |
| 19 SurfaceTextureListener(long nativeSurfaceTextureListener) { | 19 SurfaceTextureListener(long nativeSurfaceTextureListener) { |
| 20 assert nativeSurfaceTextureListener != 0; | 20 assert nativeSurfaceTextureListener != 0; |
| 21 mNativeSurfaceTextureListener = nativeSurfaceTextureListener; | 21 mNativeSurfaceTextureListener = nativeSurfaceTextureListener; |
| 22 } | 22 } |
| 23 | 23 |
| 24 @Override | 24 @Override |
| 25 public void onFrameAvailable(SurfaceTexture surfaceTexture) { | 25 public void onFrameAvailable(SurfaceTexture surfaceTexture) { |
| 26 nativeFrameAvailable(mNativeSurfaceTextureListener); | 26 nativeFrameAvailable(mNativeSurfaceTextureListener); |
| 27 } | 27 } |
| 28 | 28 |
| 29 @Override | 29 @Override |
| 30 protected void finalize() throws Throwable { | 30 protected void finalize() throws Throwable { |
| 31 try { | 31 try { |
| 32 nativeDestroy(mNativeSurfaceTextureListener); | 32 nativeDestroy(mNativeSurfaceTextureListener); |
| 33 } finally { | 33 } finally { |
| 34 super.finalize(); | 34 super.finalize(); |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 | 37 |
| 38 private native void nativeFrameAvailable(long nativeSurfaceTextureListener); | 38 private native void nativeFrameAvailable(long nativeSurfaceTextureListener); |
| 39 private native void nativeDestroy(long nativeSurfaceTextureListener); | 39 private native void nativeDestroy(long nativeSurfaceTextureListener); |
| 40 } | 40 } |
| OLD | NEW |